Roistat & dev docker & fix roistat counter See merge request lilcity/backend!58remotes/origin/hasaccess^2
commit
43bfd29782
19 changed files with 284 additions and 20 deletions
@ -0,0 +1,50 @@ |
||||
import requests |
||||
|
||||
from paymentwall import Pingback |
||||
|
||||
from django.conf import settings |
||||
from django.core.management.base import BaseCommand, CommandError |
||||
|
||||
|
||||
class Command(BaseCommand): |
||||
help = 'Update statuses on Roistat' |
||||
|
||||
def handle(self, *args, **options): |
||||
body = [ |
||||
{ |
||||
'id': str(Pingback.PINGBACK_TYPE_REGULAR), |
||||
'name': 'PINGBACK_TYPE_REGULAR', |
||||
'type': 'paid', |
||||
}, |
||||
{ |
||||
'id': str(Pingback.PINGBACK_TYPE_GOODWILL), |
||||
'name': 'PINGBACK_TYPE_GOODWILL', |
||||
'type': 'paid', |
||||
}, |
||||
{ |
||||
'id': str(Pingback.PINGBACK_TYPE_NEGATIVE), |
||||
'name': 'PINGBACK_TYPE_NEGATIVE', |
||||
'type': 'canceled', |
||||
}, |
||||
{ |
||||
'id': str(Pingback.PINGBACK_TYPE_RISK_UNDER_REVIEW), |
||||
'name': 'PINGBACK_TYPE_RISK_UNDER_REVIEW', |
||||
'type': 'progress', |
||||
}, |
||||
{ |
||||
'id': str(Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED), |
||||
'name': 'PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED', |
||||
'type': 'paid', |
||||
}, |
||||
{ |
||||
'id': str(Pingback.PINGBACK_TYPE_RISK_REVIEWED_DECLINED), |
||||
'name': 'PINGBACK_TYPE_RISK_REVIEWED_DECLINED', |
||||
'type': 'canceled', |
||||
}, |
||||
] |
||||
project = settings.ROISTAT_PROJECT |
||||
key = settings.ROISTAT_KEY |
||||
url = settings.ROISTAT_API_URL + f'/project/set-statuses?key={key}&project={project}' |
||||
resp = requests.post(url, json=body) |
||||
self.stdout.write(str(resp)) |
||||
self.stdout.write(str(resp.json())) |
||||
@ -0,0 +1,32 @@ |
||||
import requests |
||||
|
||||
from django.conf import settings |
||||
from django.contrib.auth import get_user_model |
||||
from django.core.management.base import BaseCommand, CommandError |
||||
|
||||
# User = get_user_model() |
||||
|
||||
from apps.user.models import User |
||||
|
||||
|
||||
class Command(BaseCommand): |
||||
help = 'Upload users to Roistat' |
||||
|
||||
def handle(self, *args, **options): |
||||
users_queryset = User.objects.all() |
||||
users = [ |
||||
{ |
||||
'id': str(user.id), |
||||
'name': user.get_full_name(), |
||||
'phone': str(user.phone), |
||||
'email': user.email, |
||||
'birth_date': user.birthday.strftime('%d%m%Y') if user.birthday else None, |
||||
} |
||||
for user in users_queryset |
||||
] |
||||
project = settings.ROISTAT_PROJECT |
||||
key = settings.ROISTAT_KEY |
||||
url = settings.ROISTAT_API_URL + f'/project/clients/import?key={key}&project={project}' |
||||
resp = requests.post(url, json=users) |
||||
self.stdout.write(str(resp)) |
||||
self.stdout.write(str(resp.json())) |
||||
@ -0,0 +1,18 @@ |
||||
FROM node:9.11.1-alpine as front |
||||
RUN apk update && apk add python alpine-sdk --no-cache |
||||
WORKDIR /web/ |
||||
ADD ./web/yarn.lock /web/ |
||||
ADD ./web/package.json /web/ |
||||
RUN yarn install |
||||
ADD ./web/ /web/ |
||||
RUN yarn build |
||||
|
||||
FROM python:3.6 |
||||
ENV PYTHONUNBUFFERED 1 |
||||
RUN mkdir /app |
||||
WORKDIR /app |
||||
ADD requirements.txt /app/ |
||||
RUN pip install --no-cache-dir -r requirements.txt |
||||
ADD . /app/ |
||||
COPY --from=front /web/build/ /app/web/build/ |
||||
RUN python manage.py collectstatic --no-input |
||||
Loading…
Reference in new issue