mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
feat: Ajout des évenements à venir
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
from django.http.response import JsonResponse
|
||||
from rest_framework.views import APIView
|
||||
from django.utils import timezone
|
||||
|
||||
from .models import Planning, Events
|
||||
|
||||
@ -86,4 +87,11 @@ class EventsWithIdView(APIView):
|
||||
return JsonResponse({'error': 'Event not found'}, status=404)
|
||||
|
||||
event.delete()
|
||||
return JsonResponse({'message': 'Event deleted'}, status=204)
|
||||
return JsonResponse({'message': 'Event deleted'}, status=204)
|
||||
|
||||
class UpcomingEventsView(APIView):
|
||||
def get(self, request):
|
||||
current_date = timezone.now()
|
||||
upcoming_events = Events.objects.filter(start__gte=current_date)
|
||||
events_serializer = EventsSerializer(upcoming_events, many=True)
|
||||
return JsonResponse(events_serializer.data, safe=False)
|
||||
Reference in New Issue
Block a user