diff options
| author | 2025-05-27 08:31:39 +0200 | |
|---|---|---|
| committer | 2025-05-27 08:31:39 +0200 | |
| commit | a6b795713e61a4d74159815d7c160b30a50c669c (patch) | |
| tree | 04efadc9f22e5fe9e8417b017819768615ad16a0 /pydis_site/apps/api/viewsets/bot | |
| parent | Merge pull request #1508 from python-discord/dependabot/pip/markdown-3.8 (diff) | |
| parent | Do not activate infractions on partial updates (diff) | |
Merge pull request #1530 from python-discord/fix-infraction-active-regression
Do not activate infractions on partial updates
Diffstat (limited to 'pydis_site/apps/api/viewsets/bot')
| -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() |