Merge remote-tracking branch 'origin/fix_req' into fix_req

# Conflicts:
#	requirements.txt
feature/fix_generate_pass^2
Andrey 8 years ago
parent a808a9f9ba
commit 326820d94f
  1. 10
      access/urls.py
  2. 56
      access/views.py

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

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

Loading…
Cancel
Save