diff options
Diffstat (limited to 'pydis_site')
| -rw-r--r-- | pydis_site/apps/api/viewsets/bot/off_topic_channel_name.py | 10 | 
1 files changed, 7 insertions, 3 deletions
| diff --git a/pydis_site/apps/api/viewsets/bot/off_topic_channel_name.py b/pydis_site/apps/api/viewsets/bot/off_topic_channel_name.py index 29978015..826ad25e 100644 --- a/pydis_site/apps/api/viewsets/bot/off_topic_channel_name.py +++ b/pydis_site/apps/api/viewsets/bot/off_topic_channel_name.py @@ -1,4 +1,4 @@ -from django.db.models import Case, When, Value +from django.db.models import Case, Value, When  from django.db.models.query import QuerySet  from django.http.request import HttpRequest  from django.shortcuts import get_object_or_404 @@ -114,9 +114,13 @@ class OffTopicChannelNameViewSet(DestroyModelMixin, ViewSet):              # When any name is used in our listing then this means we reached end of round              # and we need to reset all other names `used` to False              if any(offtopic_name.used for offtopic_name in queryset): +                # These names that we just got have to be excluded from updating used to False                  self.get_queryset().update( -                    used=Case(  # These names that we just got have to be excluded from updating to False -                        When(name__in=(offtopic_name.name for offtopic_name in queryset), then=Value(True)), +                    used=Case( +                        When( +                            name__in=(offtopic_name.name for offtopic_name in queryset), +                            then=Value(True) +                        ),                          default=Value(False)                      )                  ) | 
