Skip to content

Commit

Permalink
Add DELETE handling for moderator settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 committed May 26, 2024
1 parent 0654e66 commit e6a8668
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pydis_site/apps/api/viewsets/bot/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,19 @@ def mod_settings(self, request: Request, pk: str) -> Response:

return Response(mod_settings.data, status=status.HTTP_200_OK)

@mod_settings.mapping.delete
def delete_mod_settings(self, request: Request, pk: str) -> Response:
"""Delete all moderator settings registered for a user."""
user = self.get_object()
maybe_mod_settings = UserModSettings.objects.filter(moderator=user).first()

if not maybe_mod_settings:
return Response(status=status.HTTP_204_NO_CONTENT)

maybe_mod_settings.delete()

return Response(status=status.HTTP_200_OK)


@action(detail=True, methods=['POST'], name="Add alternate account",
url_name='alts', url_path='alts')
Expand Down

0 comments on commit e6a8668

Please sign in to comment.