Merge branch 'fix_push' into 'dev'

Fix push

See merge request !118
feature/fix_generate_pass
Andrey 8 years ago
commit a2e180b28c
  1. 11
      access/urls.py
  2. 56
      access/views.py

@ -18,9 +18,10 @@ urlpatterns = [
url(r'logout/$', views.LogoutView.as_view()),
url(r'reset/$', views.ResetPasswordView.as_view()),
url(r'progress_detail/upload/(?P<token>[0-9A-Fa-f-]+)/$', progress.views.UploadCourseProgressUserView.as_view()),
url(
r'management/password/$',
views.ManagementPassword.as_view(),
name='management-password'
)
# url(
# r'management/password/$',
# views.ManagementPassword.as_view(),
# name='management-password'
# )
]

@ -292,31 +292,31 @@ class MinUserView(APIView):
return Response("User not found", status=404)
class ManagementPassword(generics.GenericAPIView):
permission_classes = (permissions.IsAuthenticated, permissions.IsAdminUser)
serializer_class = UserEmailSerializer
def post(self, request):
"""
Set password to the student in admin area by manager
---
Generate new password to the student and send email with new password
"""
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
serializer.save()
logger.info(f'set password: {serializer.password} to the '
f'student with email: {serializer.user.email}')
send_mail(
subject='Установлен новый пароль',
message=f'Ваш новый пароль {serializer.password} '
f'(в последствии вы сможите сменить его в личном кабинете).',
from_email='robo@skillbox.ru',
recipient_list=[serializer.user.email],
)
logger.info(f'send email to {serializer.user.email} '
f'with new password')
return Response(
data={'message': 'Письмо с новым паролем отправлено на email студента.'},
status=status.HTTP_201_CREATED
)
# class ManagementPassword(generics.GenericAPIView):
# permission_classes = (permissions.IsAuthenticated, permissions.IsAdminUser)
# serializer_class = UserEmailSerializer
#
# def post(self, request):
# """
# Set password to the student in admin area by manager
# ---
# Generate new password to the student and send email with new password
# """
# serializer = self.get_serializer(data=request.data)
# serializer.is_valid(raise_exception=True)
# serializer.save()
# logger.info(f'set password: {serializer.password} to the '
# f'student with email: {serializer.user.email}')
# send_mail(
# subject='Установлен новый пароль',
# message=f'Ваш новый пароль {serializer.password} '
# f'(в последствии вы сможите сменить его в личном кабинете).',
# from_email='robo@skillbox.ru',
# recipient_list=[serializer.user.email],
# )
# logger.info(f'send email to {serializer.user.email} '
# f'with new password')
# return Response(
# data={'message': 'Письмо с новым паролем отправлено на email студента.'},
# status=status.HTTP_201_CREATED
# )

Loading…
Cancel
Save