Skip to content
Snippets Groups Projects
Commit 0b04fde4 authored by florimondmanca's avatar florimondmanca
Browse files

add project participation cancel endpoint

parent b4abe860
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ class ProjectViewSet(viewsets.ReadOnlyModelViewSet):
"id": 1,
"url": "http://localhost:8000/api/projects/1/",
"name": "Oser la Prépa",
"description": "Oser la Prépa est un stage d'acclimatation aux Classes Préparatoires de deux semaines qui se déroule chaque été.",
"description": "Oser la Prépa est un stage d'acclimatation",
"logo": null
}
]
......@@ -421,6 +421,19 @@ class ParticipationViewSet(mixins.CreateModelMixin, mixins.DestroyModelMixin,
filter_backends = (filters.backends.DjangoFilterBackend,)
filter_fields = ('user', 'state',)
@action(methods=['post'], detail=True)
def cancel(self, request, pk=None):
"""Cancel a participation.
Note: the participation is not removed from the database,
it is only marked as cancelled.
Use [destroy](#project-participation-destroy) to delete it.
"""
participation = self.get_object()
participation.state = Participation.STATE_CANCELLED
participation.save()
return Response(None, status=status.HTTP_204_NO_CONTENT)
@action(methods=['get'], detail=True)
def form_entry(self, request, pk=None):
"""Return the answers to the edition form for a participation.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment