diff options
author | 2025-05-27 08:27:04 +0200 | |
---|---|---|
committer | 2025-05-27 08:29:43 +0200 | |
commit | cf7b9958146329b7350c99cc8216fc866f7c37c8 (patch) | |
tree | 04efadc9f22e5fe9e8417b017819768615ad16a0 /pydis_site/apps/api/viewsets | |
parent | Merge pull request #1508 from python-discord/dependabot/pip/markdown-3.8 (diff) |
Do not activate infractions on partial updates
Diffstat (limited to 'pydis_site/apps/api/viewsets')
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/infraction.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pydis_site/apps/api/viewsets/bot/infraction.py b/pydis_site/apps/api/viewsets/bot/infraction.py index 066b296f..1d16232c 100644 --- a/pydis_site/apps/api/viewsets/bot/infraction.py +++ b/pydis_site/apps/api/viewsets/bot/infraction.py @@ -161,7 +161,12 @@ class InfractionViewSet( def partial_update(self, request: HttpRequest, *_args, **_kwargs) -> Response: """Method that handles the nuts and bolts of updating an Infraction.""" instance = self.get_object() - request.data.setdefault("active", True) + # DRF presently errors out if we are not specifying all fields here. + # See this issue: + # https://github.com/encode/django-rest-framework/issues/9358. The + # merged PR that closed the issue does not appear to work either, so + # here's a workaround. + request.data.setdefault("active", instance.active) serializer = self.get_serializer(instance, data=request.data, partial=True) serializer.is_valid(raise_exception=True) serializer.save() |