import changes in notification

This commit is contained in:
2025-10-08 11:13:01 +03:30
parent cad4ccbe4b
commit f1a209a166
9 changed files with 104 additions and 25 deletions

View File

@@ -9,6 +9,7 @@ from rest_framework.response import Response
from rest_framework import viewsets
from rest_framework import status
from django.db import transaction
from django.db.models import Q
class NotificationViewSet(SoftDeleteMixin, POSDeviceMixin, DynamicSearchMixin, viewsets.ModelViewSet):
@@ -22,12 +23,26 @@ class NotificationViewSet(SoftDeleteMixin, POSDeviceMixin, DynamicSearchMixin, v
organization = self.get_device_organization()
device = self.get_pos_device()
queryset = self.queryset.filter(
device=device,
organization=organization,
delivered=False,
is_read=False
)
show_type = self.request.query_params.get('show')
if show_type == 'undelivered':
queryset = self.queryset.filter(
Q(delivering_type='general') | Q(delivering_type='private'),
device=device,
organization=organization,
delivered=False,
is_read=False,
)
elif show_type == 'unread':
queryset = self.queryset.filter(
Q(delivering_type='general') | Q(delivering_type='private'),
device=device,
organization=organization,
delivered=True,
is_read=False
)
else:
queryset = self.queryset
# paginate & response
page = self.paginate_queryset(queryset)