diff options
author | 2022-11-07 18:26:51 +0100 | |
---|---|---|
committer | 2022-11-07 18:26:51 +0100 | |
commit | 1f22c1410afa7965b1f1f2e4dffd37f540bc0d5a (patch) | |
tree | a26f7f5e10290322827c6c02679a1c0c9a3c4de3 /pydis_site/apps/api/viewsets | |
parent | push forgotten model update (diff) |
add validation criteria for thread_id modification
Diffstat (limited to 'pydis_site/apps/api/viewsets')
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/nomination.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/pydis_site/apps/api/viewsets/bot/nomination.py b/pydis_site/apps/api/viewsets/bot/nomination.py index 6af42bcb..ecbf217e 100644 --- a/pydis_site/apps/api/viewsets/bot/nomination.py +++ b/pydis_site/apps/api/viewsets/bot/nomination.py @@ -273,6 +273,11 @@ class NominationViewSet(CreateModelMixin, RetrieveModelMixin, ListModelMixin, Ge {'reviewed': ['This field cannot be set while you are ending a nomination.']} ) + if 'thread_id' in request.data: + raise ValidationError( + {'thread_id': ['This field cannot be set when ending a nomination.']} + ) + instance.ended_at = timezone.now() elif 'active' in data: @@ -289,6 +294,13 @@ class NominationViewSet(CreateModelMixin, RetrieveModelMixin, ListModelMixin, Ge {'reviewed': ['This field cannot be set if the nomination is inactive.']} ) + elif 'thread_id' in request.data: + # 5. We are altering the thread_id of the nomination. + if not instance.active: + raise ValidationError( + {'thread_id': ['This field cannot be set if the nomination is inactive.']} + ) + if 'reason' in request.data: if 'actor' not in request.data: raise ValidationError( |