Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Jun 23, 2024
1 parent cb927f2 commit 2cb842c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from django.contrib.auth.models import User
from django.db.models import Q, Sum
from django.utils import timezone
from django.utils.datetime_safe import parse_datetime
from django.http import HttpResponseBadRequest
from drf_spectacular.utils import extend_schema
from rest_framework import status, viewsets
from rest_framework.authentication import TokenAuthentication
Expand Down Expand Up @@ -746,15 +748,15 @@ class NotificationsView(ListAPIView):

@extend_schema(**NotificationSchema.get)
def get(self, request, format=None):
# robot = request.user.robot
queryset = Notification.objects.all().order_by("created_at")
# created_at = request.GET.get("created_at")

# if created_at:
# created_at = parse_datetime(created_at)
# if not created_at:
# return HttpResponseBadRequest("Invalid date format")
# queryset = queryset.filter(created_at__gte=created_at)
robot = request.user.robot
queryset = Notification.objects.filter(robot=robot).order_by("created_at")
created_at = request.GET.get("created_at")

if created_at:
created_at = parse_datetime(created_at)
if not created_at:
return HttpResponseBadRequest("Invalid date format")
queryset = queryset.filter(created_at__gte=created_at)

notification_data = []
for notification in queryset:
Expand Down

0 comments on commit 2cb842c

Please sign in to comment.