Skip to content

Commit 56697a6

Browse files
authored
Do not require "active" to be sent in PATCH infraction (#1518)
Regression from the DRF update.
1 parent 7a6effe commit 56697a6

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

pydis_site/apps/api/tests/test_infractions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def test_partial_update(self):
329329

330330
def test_partial_update_returns_400_for_frozen_field(self):
331331
url = reverse('api:bot:infraction-detail', args=(self.ban_hidden.id,))
332-
data = {'user': 6, 'active': True}
332+
data = {'user': 6}
333333

334334
response = self.client.patch(url, data=data)
335335
self.assertEqual(response.status_code, 400)

pydis_site/apps/api/viewsets/bot/infraction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ class InfractionViewSet(
161161
def partial_update(self, request: HttpRequest, *_args, **_kwargs) -> Response:
162162
"""Method that handles the nuts and bolts of updating an Infraction."""
163163
instance = self.get_object()
164+
request.data.setdefault("active", True)
164165
serializer = self.get_serializer(instance, data=request.data, partial=True)
165166
serializer.is_valid(raise_exception=True)
166167
serializer.save()

0 commit comments

Comments
 (0)