Introduce notifications app and integrate emails
Add a new notifications app (models, serializers, views, admin, tasks, consumers, routing, urls, tests) with Notification.notify for in-app websocket pushes and optional email delivery. Centralize email sending in notifications.tasks.send_email_with_context and re-export it from account.tasks for compatibility. Update account and commerce and advertisement tasks to use Notification.notify/_notify_order and the new email helper; adjust order/notification tasks to consolidate logic. Wire notifications into ASGI routing, settings and URL conf. Misc: handle OSError when importing weasyprint, add tmp/ to .gitignore, add local .claude PowerShell checks, add social.blog skeleton, and remove legacy ews-component test files.
This commit is contained in:
@@ -237,7 +237,9 @@ class UserView(viewsets.ModelViewSet):
|
||||
|
||||
def get_serializer_class(self):
|
||||
user = getattr(self.request, 'user', None)
|
||||
|
||||
is_admin = user and (getattr(user, 'role', None) == 'admin' or getattr(user, 'is_superuser', False))
|
||||
|
||||
if self.action in ['retrieve', 'list'] and not is_admin:
|
||||
return PublicUserSerializer
|
||||
return CustomUserSerializer
|
||||
@@ -277,11 +279,15 @@ class ChangePasswordView(APIView):
|
||||
def post(self, request):
|
||||
serializer = ChangePasswordSerializer(data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
|
||||
user = request.user
|
||||
|
||||
if not user.check_password(serializer.validated_data['current_password']):
|
||||
return Response({"current_password": "Nesprávné heslo."}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
user.set_password(serializer.validated_data['new_password'])
|
||||
user.save()
|
||||
|
||||
return Response({"detail": "Heslo bylo úspěšně změněno."})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user