|
|
|
@ -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 |
|
|
|
) |
|
|
|
# ) |
|
|
|
|