From 640a110f5847fcde5137f3e1390911c08026baed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4ki?= Date: Mon, 23 Oct 2023 10:01:22 +0300 Subject: [PATCH] Cyberstorm API: add CyberstormPackageCategorySerializer It felt a bit dirty to import such a simple serializer from another app, especially since that serializer is marked experimental. Refs TS-1860 --- .../api/cyberstorm/serializers/community.py | 10 +++------- .../thunderstore/api/cyberstorm/serializers/shared.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 django/thunderstore/api/cyberstorm/serializers/shared.py diff --git a/django/thunderstore/api/cyberstorm/serializers/community.py b/django/thunderstore/api/cyberstorm/serializers/community.py index 71061ee22..84d4218c8 100644 --- a/django/thunderstore/api/cyberstorm/serializers/community.py +++ b/django/thunderstore/api/cyberstorm/serializers/community.py @@ -1,11 +1,7 @@ from rest_framework import serializers -from thunderstore.community.api.experimental.serializers import ( - PackageCategoryExperimentalSerializer, -) -from thunderstore.community.models import PackageCategory -from thunderstore.repository.api.experimental.serializers import ( - CommunityFilteredModelChoiceField, +from thunderstore.api.cyberstorm.serializers.shared import ( + CyberstormPackageCategorySerializer, ) @@ -19,7 +15,7 @@ class CyberstormCommunitySerializer(serializers.Serializer): icon_url = serializers.CharField(required=False) total_download_count = serializers.SerializerMethodField() total_package_count = serializers.SerializerMethodField() - package_categories = PackageCategoryExperimentalSerializer(many=True) + package_categories = CyberstormPackageCategorySerializer(many=True) def get_total_download_count(self, obj) -> int: return obj.aggregated.download_count diff --git a/django/thunderstore/api/cyberstorm/serializers/shared.py b/django/thunderstore/api/cyberstorm/serializers/shared.py new file mode 100644 index 000000000..eb5ffcebc --- /dev/null +++ b/django/thunderstore/api/cyberstorm/serializers/shared.py @@ -0,0 +1,10 @@ +""" +Do not import/export these through __init__.py to avoid circular imports +in other serializer files. +""" +from rest_framework import serializers + + +class CyberstormPackageCategorySerializer(serializers.Serializer): + name = serializers.CharField() + slug = serializers.SlugField()