Skip to content
Snippets Groups Projects
Commit e0c4e316 authored by s2536528's avatar s2536528
Browse files

Added method get_object in class viewsets/event.py

parent 883ba89f
Branches
No related tags found
No related merge requests found
from django.shortcuts import get_object_or_404
from django.utils import timezone from django.utils import timezone
from guardian.shortcuts import get_objects_for_user from guardian.shortcuts import get_objects_for_user
from guardian.shortcuts import Q from guardian.shortcuts import Q
...@@ -59,6 +60,12 @@ class EventViewSet(viewsets.ModelViewSet): ...@@ -59,6 +60,12 @@ class EventViewSet(viewsets.ModelViewSet):
def get_serializer_class(self): def get_serializer_class(self):
return EventSerializer return EventSerializer
def get_object(self):
obj = get_object_or_404(self.get_queryset(), pk=self.kwargs["id"]) # maybe instead of id, name ?
print("method for retrieving the object was used ! [TEST]")
self.check_object_permissions(self.request, obj)
return obj
def get_queryset(self): def get_queryset(self):
associations = get_objects_for_user(self.request.user, 'board', klass=Association) associations = get_objects_for_user(self.request.user, 'board', klass=Association)
queryset = Event.objects.filter( queryset = Event.objects.filter(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment