diff options
| -rw-r--r-- | pydis_site/apps/api/serializers.py | 19 | 
1 files changed, 17 insertions, 2 deletions
diff --git a/pydis_site/apps/api/serializers.py b/pydis_site/apps/api/serializers.py index 8f61073e..e09c383e 100644 --- a/pydis_site/apps/api/serializers.py +++ b/pydis_site/apps/api/serializers.py @@ -200,14 +200,29 @@ class ExpandedInfractionSerializer(InfractionSerializer):          return ret +class OffTopicChannelNameListSerializer(ListSerializer): +    def update(self, instance, validated_data): +        pass + +    def to_representation(self, obj: OffTopicChannelName) -> str: +        """ +        Return the representation of this `OffTopicChannelName`. +        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. +        Additionally, this allows off topic channel name routes to simply return an +        array of names instead of objects, saving on bandwidth. +        """ +        return obj.name + +  class OffTopicChannelNameSerializer(ModelSerializer):      """A class providing (de-)serialization of `OffTopicChannelName` instances."""      class Meta:          """Metadata defined for the Django REST Framework.""" - +        list_serializer_class = OffTopicChannelNameListSerializer          model = OffTopicChannelName -        fields = ('name', 'active') +        fields = ('name', 'used', 'active')  class ReminderSerializer(ModelSerializer):  |