diff options
-rw-r--r-- | pydis_site/apps/api/serializers.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/pydis_site/apps/api/serializers.py b/pydis_site/apps/api/serializers.py index 957c85f3..9b351be2 100644 --- a/pydis_site/apps/api/serializers.py +++ b/pydis_site/apps/api/serializers.py @@ -1,6 +1,4 @@ """Converters from Django models to data interchange formats and back.""" -from typing import List - from django.db.models.query import QuerySet from django.db.utils import IntegrityError from rest_framework.exceptions import NotFound @@ -205,12 +203,12 @@ class ExpandedInfractionSerializer(InfractionSerializer): class OffTopicChannelNameListSerializer(ListSerializer): """Custom ListSerializer to override to_representation() when list views are triggered.""" - def to_representation(self, objects: List[OffTopicChannelName]) -> List[str]: + def to_representation(self, objects: list[OffTopicChannelName]) -> list[str]: """ - Return a list representing a list of `OffTopicChannelName`. + Return a list with all `OffTopicChannelName`s in the database. - This only returns the name of the off topic channel name. As the model - only has a single attribute, it is unnecessary to create a nested dictionary. + This returns the list of off topic channel names. We want to only return + the name attribute, hence it is unnecessary to create a nested dictionary. Additionally, this allows off topic channel name routes to simply return an array of names instead of objects, saving on bandwidth. """ |