Skip to content

Commit

Permalink
feat: delete user when deleting representative
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed Sep 17, 2024
1 parent c5f390d commit 34e1c69
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions backend/tprm/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ class RepresentativeViewSet(BaseModelViewSet):
API endpoint that allows representatives to be viewed or edited.
"""

def destroy(self, request, *args, **kwargs):
instance = self.get_object()
if instance.user:
instance.user.delete()

return super().destroy(request, *args, **kwargs)

model = Representative
filterset_fields = ["entity"]

Expand Down

0 comments on commit 34e1c69

Please sign in to comment.