diff --git a/BackEnd/forum/apps.py b/BackEnd/forum/apps.py new file mode 100644 index 000000000..d82466734 --- /dev/null +++ b/BackEnd/forum/apps.py @@ -0,0 +1,8 @@ +from django.apps import AppConfig + + +class ForumConfig(AppConfig): + name = "forum" + + def ready(self): + import forum.schema # noqa: E402 diff --git a/BackEnd/forum/schema.py b/BackEnd/forum/schema.py new file mode 100644 index 000000000..380f4254f --- /dev/null +++ b/BackEnd/forum/schema.py @@ -0,0 +1,18 @@ +from drf_spectacular.extensions import OpenApiViewExtension +from drf_spectacular.utils import extend_schema +from djoser.views import TokenDestroyView + + +class TokenDestroyViewExtension(OpenApiViewExtension): + target_class = TokenDestroyView + + def view_replacement(self): + + class Fixed(self.target_class): + serializer_class = None + + @extend_schema(responses={204: {}}) + def post(self, request, *args, **kwargs): + pass + + return Fixed diff --git a/BackEnd/forum/settings.py b/BackEnd/forum/settings.py index da86aa98a..0a594cb77 100644 --- a/BackEnd/forum/settings.py +++ b/BackEnd/forum/settings.py @@ -57,6 +57,7 @@ "search", "drf_spectacular", "images", + "forum.apps.ForumConfig", ] MIDDLEWARE = [ diff --git a/BackEnd/profiles/serializers.py b/BackEnd/profiles/serializers.py index 18bf8dcd5..648878122 100644 --- a/BackEnd/profiles/serializers.py +++ b/BackEnd/profiles/serializers.py @@ -56,13 +56,13 @@ class Meta: "is_saved", ) - def get_is_saved(self, obj): + def get_is_saved(self, obj) -> bool: user = self.context["request"].user if user.is_authenticated: return obj.pk in self.context["saved_companies_pk"] return False - def get_regions_ukr_display(self, obj): + def get_regions_ukr_display(self, obj) -> str: return get_regions_ukr_names_as_string(obj) @@ -128,13 +128,13 @@ class Meta: "logo_image", ) - def get_is_saved(self, obj): + def get_is_saved(self, obj) -> bool: user = self.context["request"].user if user.is_authenticated: return obj.pk in self.context["saved_companies_pk"] return False - def get_regions_ukr_display(self, obj): + def get_regions_ukr_display(self, obj) -> str: return get_regions_ukr_names_as_string(obj) @@ -202,7 +202,7 @@ class Meta: "is_deleted", ) - def get_regions_ukr_display(self, obj): + def get_regions_ukr_display(self, obj) -> str: return get_regions_ukr_names_as_string(obj) @@ -348,10 +348,10 @@ class Meta: "company", ) - def get_user_profile_name(self, obj): + def get_user_profile_name(self, obj) -> str: if obj.user: return obj.user_profile_name return None - def get_company_name(self, obj): + def get_company_name(self, obj) -> str: return obj.company_name diff --git a/BackEnd/profiles/views.py b/BackEnd/profiles/views.py index 3d60c6b59..09584f631 100644 --- a/BackEnd/profiles/views.py +++ b/BackEnd/profiles/views.py @@ -17,6 +17,7 @@ ) from rest_framework.response import Response from utils.completeness_counter import completeness_count +from drf_spectacular.utils import extend_schema, PolymorphicProxySerializer from forum.pagination import ForumPagination from .models import SavedCompany, Profile, Category, Activity, Region @@ -55,6 +56,7 @@ class SavedCompaniesCreate(CreateAPIView): pagination_class = ForumPagination +@extend_schema(responses={204: {}}) class SavedCompaniesDestroy(DestroyAPIView): """ Remove the company from the saved list. @@ -120,6 +122,21 @@ def create(self, request): return super().create(request) +@extend_schema( + responses={ + 200: PolymorphicProxySerializer( + component_name="profile_detail", + serializers=[ + ProfileOwnerDetailViewSerializer, + ProfileSensitiveDataROSerializer, + ProfileDetailSerializer, + ProfileOwnerDetailEditSerializer, + ], + resource_type_field_name=None, + ), + 204: {}, + } +) class ProfileDetail(RetrieveUpdateDestroyAPIView): """ Retrieve, update or delete a profile instance. diff --git a/BackEnd/search/serializers.py b/BackEnd/search/serializers.py index 929c0dabf..de6ad38c6 100644 --- a/BackEnd/search/serializers.py +++ b/BackEnd/search/serializers.py @@ -33,13 +33,13 @@ class Meta: "is_saved", ) - def get_is_saved(self, obj): + def get_is_saved(self, obj) -> bool: user = self.context["request"].user if user.is_authenticated: return obj.pk in self.context["saved_companies_pk"] return False - def get_regions_ukr_display(self, obj): + def get_regions_ukr_display(self, obj) -> str: return get_regions_ukr_names_as_string(obj) @@ -69,5 +69,5 @@ class Meta: "person", ) - def get_regions_ukr_display(self, obj): + def get_regions_ukr_display(self, obj) -> str: return get_regions_ukr_names_as_string(obj)