|
|
|
@ -4,8 +4,8 @@ from rest_framework.authentication import TokenAuthentication |
|
|
|
from drf_yasg.utils import swagger_auto_schema |
|
|
|
from drf_yasg import openapi |
|
|
|
from rest_framework.permissions import IsAuthenticated |
|
|
|
from apps.account.serializers import NotificationSerializer, NotificationSendSerializer, AdminNotificationSerializer |
|
|
|
from apps.account.models import Notification, User |
|
|
|
from apps.account.serializers import NotificationSerializer, NotificationSendSerializer, AdminNotificationSerializer, NotificationTemplateSerializer |
|
|
|
from apps.account.models import Notification, User, NotificationTemplate |
|
|
|
from apps.account.tasks import send_notification |
|
|
|
from utils.pagination import StandardResultsSetPagination |
|
|
|
from django.db.models import Q |
|
|
|
@ -380,3 +380,18 @@ class TestNotificationAPIView(generics.GenericAPIView): |
|
|
|
'results': results, |
|
|
|
'fcm_token_registered': bool(user.fcm) |
|
|
|
}, status=status.HTTP_200_OK) |
|
|
|
|
|
|
|
|
|
|
|
class AdminNotificationTemplateViewSet(ModelViewSet): |
|
|
|
permission_classes = [IsSuperAdmin] |
|
|
|
authentication_classes = [TokenAuthentication] |
|
|
|
serializer_class = NotificationTemplateSerializer |
|
|
|
queryset = NotificationTemplate.objects.all().order_by('id') |
|
|
|
pagination_class = StandardResultsSetPagination |
|
|
|
|
|
|
|
# Disable create and destroy actions as templates are system-defined |
|
|
|
def create(self, request, *args, **kwargs): |
|
|
|
return Response({'error': 'Method not allowed.'}, status=status.HTTP_405_METHOD_NOT_ALLOWED) |
|
|
|
|
|
|
|
def destroy(self, request, *args, **kwargs): |
|
|
|
return Response({'error': 'Method not allowed.'}, status=status.HTTP_405_METHOD_NOT_ALLOWED) |