Skip to content
Snippets Groups Projects
Commit 122c68c9 authored by florimondmanca's avatar florimondmanca
Browse files

add endpoint to reactive a project participation

parent 0b04fde4
No related branches found
No related tags found
No related merge requests found
......@@ -434,6 +434,24 @@ class ParticipationViewSet(mixins.CreateModelMixin, mixins.DestroyModelMixin,
participation.save()
return Response(None, status=status.HTTP_204_NO_CONTENT)
@action(methods=['post'], detail=True)
def reactivate(self, request, pk=None):
"""Reactivate a participation if it is cancelled.
It is sent back to the "pending" state.
If the participation is not cancelled, a `400 Bad Request` error
response is returned.
"""
participation = self.get_object()
if participation.state == Participation.STATE_CANCELLED:
participation.state = Participation.STATE_PENDING
participation.save()
return Response(None, status=status.HTTP_204_NO_CONTENT)
else:
error = {'detail': 'Participation must be in cancelled state'}
return Response(error, status=status.HTTP_400_BAD_REQUEST)
@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