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 36ba55b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 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,18 @@ 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 maybe_mod_settings:
maybe_mod_settings.delete()
return Response(status=status.HTTP_200_OK)
else:

Check failure on line 399 in pydis_site/apps/api/viewsets/bot/user.py

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Ruff (RET505)

pydis_site/apps/api/viewsets/bot/user.py:399:9: RET505 Unnecessary `else` after `return` statement
return Response(status=status.HTTP_204_NO_CONTENT)


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

0 comments on commit 36ba55b

Please sign in to comment.