update api прохождения

feature/fix_generate_pass
Andrey 8 years ago
parent 404d6da093
commit fdeed92ab6
  1. 3
      access/models/user.py
  2. 23
      access/views.py
  3. 160
      finance/signals.py
  4. 12
      lms/settings.py
  5. 18
      storage/views.py

@ -2,6 +2,7 @@ import random
import string import string
import uuid import uuid
from django.conf import settings
from django.contrib.auth.base_user import BaseUserManager, AbstractBaseUser from django.contrib.auth.base_user import BaseUserManager, AbstractBaseUser
from django.contrib.auth.models import Group, PermissionsMixin from django.contrib.auth.models import Group, PermissionsMixin
from django.core.mail import send_mail from django.core.mail import send_mail
@ -73,7 +74,7 @@ class CustomUserManager(BaseUserManager):
Вы были успешны зарегистрированны на портале go.skillbox.ru Вы были успешны зарегистрированны на портале go.skillbox.ru
ваш пароль %s ваш пароль %s
для подтверждения регистрации перейдите по ссылке для подтверждения регистрации перейдите по ссылке
https://go.skillbox.ru/api/v1/users/registration/?hash=%s''' %(password, invite.hash), %s/api/v1/users/registration/?hash=%s''' % (password, settings.DOMAIN, invite.hash),
"from_email": 'robo@skillbox.ru', "from_email": 'robo@skillbox.ru',
"recipient_list": [user.email], "recipient_list": [user.email],
} }

@ -3,6 +3,7 @@ import random
import string import string
from django.contrib import auth from django.contrib import auth
from django.conf import settings
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.core.mail import send_mail from django.core.mail import send_mail
from django.db.models import Q from django.db.models import Q
@ -74,8 +75,8 @@ class ResetPasswordView(APIView):
message=''' message='''
Ваш новый пароль %s, (в последствии вы сможите сменить его в личном кабинете), Ваш новый пароль %s, (в последствии вы сможите сменить его в личном кабинете),
если вы не отправляли заявку на сброс пароля просто проигнорируйте это сообщение, если вы не отправляли заявку на сброс пароля просто проигнорируйте это сообщение,
для подтверждения смены пароля перейдите по https://go.skillbox.ru/api/v1/users/reset/?hash=%s для подтверждения смены пароля перейдите по %s/api/v1/users/reset/?hash=%s
(ссылке ссылка действительна в течении 5 минут)''' % (invite.password, invite.hash), (ссылке ссылка действительна в течении 5 минут)''' % (invite.password, settings.DOMAIN, invite.hash),
from_email='robo@skillbox.ru', from_email='robo@skillbox.ru',
recipient_list=[user.email], recipient_list=[user.email],
) )
@ -118,6 +119,24 @@ class FindUserView(APIView):
class DetailUserView(APIView): class DetailUserView(APIView):
renderer_classes = (JSONRenderer,) renderer_classes = (JSONRenderer,)
@staticmethod
def post(request, pk=None):
if pk is None:
return Response("out_key mast be set", status=400)
if not request.user.out_key == pk:
return Response("You can't change this profile", status=403)
f_n = request.JSON.get('first_name', None)
l_n = request.JSON.get('last_name', None)
acc = request.JSON.get('account', None)
serialized_user = UserSelfSerializer(request.user).data
serialized_user['is_i'] = True
return Response(serialized_user, status=200)
@staticmethod @staticmethod
def get(request, pk=None): def get(request, pk=None):
if pk is None: if pk is None:

@ -1,79 +1,81 @@
# from django.core.mail import EmailMessage from django.core.mail import EmailMessage
# from django.db.models.signals import pre_save, post_save from django.db.models.signals import pre_save, post_save
# from django.dispatch import receiver from django.dispatch import receiver
# from yandex_money.models import Payment from yandex_money.models import Payment
# from django.conf import settings
# from finance.models import Invoice
# from access.models.other import Progress from finance.models import Invoice
# from course_service.maps.api import OutApiRoute from courses.models import Course
# from progress.models import Progress
# api = OutApiRoute
#
# @receiver(pre_save, sender=Invoice)
# @receiver(pre_save, sender=Invoice) def invoice_signal(instance, **kwargs):
# def invoice_signal(instance, **kwargs): """Отправка сообщения после сохранения платежа"""
# """Отправка сообщения после сохранения платежа"""
# if instance.yandex_pay and instance.method == 'Y' and instance.status == 'P': course = Course.objects.get(token=instance.bill.course_token)
# msg = EmailMessage(
# 'Вам выставлен новый счёт', if instance.yandex_pay and instance.method == 'Y' and instance.status == 'P':
# '''Вам выставлен счёт, для оплаты перейдите по ссылке msg = EmailMessage(
# https://go.skillbox.ru/api/v1/finance/payment/%s/''' % instance.yandex_pay.id, 'Вам выставлен новый счёт',
# 'robo@skillbox.ru', '''Вам выставлен счёт, для оплаты перейдите по ссылке
# [instance.yandex_pay.cps_email], %s/api/v1/finance/payment/%s/''' % (settings.DOMAIN, instance.yandex_pay.id,),
# [instance.bill.opener.email], 'robo@skillbox.ru',
# reply_to=[instance.bill.opener.email], [instance.yandex_pay.cps_email],
# ) [instance.bill.opener.email],
# msg.send() reply_to=[instance.bill.opener.email],
# )
# if instance.status == 'F': msg.send()
# if instance.is_open:
# Progress.objects.get_or_create( if instance.status == 'F':
# route=instance.bill.route, if instance.is_open:
# user=instance.bill.user, Progress.objects.get_or_create(
# ) course_token=instance.bill.course_token,
# msg = EmailMessage( user=instance.bill.user,
# 'Ваш платёж прошёл успешно', )
# '''Вам открыт доступ к курсу "%s", вы можете перейти по ссылке и msg = EmailMessage(
# ознакомиться с материалами https://go.skillbox.ru/course/%s''' 'Ваш платёж прошёл успешно',
# % (api.get_route(instance.bill.route).name, api.get_route(instance.bill.route).course.slug), '''Вам открыт доступ к курсу "%s", вы можете перейти по ссылке и
# 'robo@skillbox.ru', ознакомиться с материалами %s/course/%s'''
# [instance.bill.user.email], % (course.title, settings.DOMAIN, course.slug),
# cc=[instance.bill.opener.email], 'robo@skillbox.ru',
# reply_to=[instance.bill.opener.email], [instance.bill.user.email],
# ) cc=[instance.bill.opener.email],
# else: reply_to=[instance.bill.opener.email],
# msg = EmailMessage( )
# 'Ваш платёж прошёл успешно', else:
# '''Курс "%s" был забронирован''' % instance.bill.course.title, msg = EmailMessage(
# 'robo@skillbox.ru', 'Ваш платёж прошёл успешно',
# [instance.yandex_pay.cps_email], '''Курс "%s" был забронирован''' % instance.bill.course.title,
# cc=[instance.bill.opener.email], 'robo@skillbox.ru',
# reply_to=[instance.bill.opener.email], [instance.yandex_pay.cps_email],
# ) cc=[instance.bill.opener.email],
# msg.send() reply_to=[instance.bill.opener.email],
# )
# if instance.status == 'C': msg.send()
# msg = EmailMessage(
# 'Ошибка платежа!' if instance.status == 'C':
# """Внимание не прошёл платёж пользавателю %s, msg = EmailMessage(
# по курсу "%s" ID платежа: %s. Если не получается 'Ошибка платежа!'
# решить проблему самостоятельно, ответьте на это письмо, """Внимание не прошёл платёж пользавателю %s,
# постарайтесь подробно описать последовательность действий, по курсу "%s" ID платежа: %s. Если не получается
# которая привела к ошибке""" решить проблему самостоятельно, ответьте на это письмо,
# % (instance.bill.user.get_full_name(), api.get_route(instance.bill.route).course.title, instance.id), постарайтесь подробно описать последовательность действий,
# instance.bill.opener.email, которая привела к ошибке"""
# reply_to=["it@skillbox.ru"] % (instance.bill.user.get_full_name(), course.title, instance.id),
# ) instance.bill.opener.email,
# msg.send() reply_to=["it@skillbox.ru"]
# )
# msg.send()
# @receiver(post_save, sender=Payment)
# def access_pay(instance, **kwargs):
# if instance.status == 'success': @receiver(post_save, sender=Payment)
# instance.invoice.status = "F" def access_pay(instance, **kwargs):
# instance.invoice.real_price = instance.shop_amount if instance.status == 'success':
# instance.invoice.save() instance.invoice.status = "F"
# instance.invoice.real_price = instance.shop_amount
# if instance.status == 'fail': instance.invoice.save()
# instance.invoice.status = "C"
# instance.invoice.save() if instance.status == 'fail':
instance.invoice.status = "C"
instance.invoice.save()

@ -50,17 +50,7 @@ AUTH_USER_MODEL = 'access.User'
VZAAR = 'f1e965defc6fbaa92c544cf84267e830' VZAAR = 'f1e965defc6fbaa92c544cf84267e830'
SMS = '5ED9C6BB-41E8-C760-10FA-F8A310D88952' SMS = '5ED9C6BB-41E8-C760-10FA-F8A310D88952'
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['*']
DOMAIN = 'https://go.skillbox.ru' DOMAIN = "http://31.186.103.4" #'https://go.skillbox.ru'
BILL_LOGIN = '1501'
BILL_URL = 'https://api.simplepay.pro/sp/payment'
BILL_KEY = u'848360a6b0b8cdfaca3603ede75e4d8b'
BILL_RESULT_KEY = u'82a513fc6a0bd9cb087e0df4be5520f6'
BILL_TOKEN = u'c63fc7fdc74de318e1f9b078b6d4406a3e62f522b00fb305afe61c0ead238eb9c88dcab6b324727537fe5c1631cba3a9bcb76955364aa269334b42fb4099d236'
AMO_USER_LOGIN = 'baryshnikov@mokselle.com'
AMO_USER_HASH = 'd639c26c1c1900e5a8cee66cd3395bdc'
AMO_SUBDOMAIN = 'mokselle'
DEFAULT_FROM_EMAIL = 'robo@skillbox.ru'
YANDEX_MONEY_DEBUG = False YANDEX_MONEY_DEBUG = False
YANDEX_MONEY_SCID = '149639' YANDEX_MONEY_SCID = '149639'

@ -44,20 +44,12 @@ class CommentView(APIView):
@staticmethod @staticmethod
def get(request): def get(request):
tokens = request.GET.getlist('tokens', None) token = request.GET.get('token', None)
if not tokens:
return Response("Attribute tokens not set", status=400)
if tokens == ["null"]: if not token:
return Response([], status=200) return Response("Attribute token not set", status=400)
comment_list = []
for token in tokens:
try: try:
comment_list.append(CommentSerializer(Comment.objects.get(token=token)).data) return Response(CommentSerializer(Comment.objects.get(token=token)).data, status=200)
except Comment.DoesNotExist: except Comment.DoesNotExist:
comment_list.append({'upload': 'error'}) return Response("Comment not found", status=404)
return Response(comment_list, status=200)

Loading…
Cancel
Save