Skip to content

Commit

Permalink
Merge branch 'develop' into 561-tech-debt-remove-redundant-responces-…
Browse files Browse the repository at this point in the history
…in-views-fe
  • Loading branch information
YanZhylavy committed Jun 6, 2024
2 parents 870e47d + 1045435 commit d51d7aa
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 10 deletions.
8 changes: 8 additions & 0 deletions BackEnd/forum/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig


class ForumConfig(AppConfig):
name = "forum"

def ready(self):
import forum.schema # noqa: E402
18 changes: 18 additions & 0 deletions BackEnd/forum/schema.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions BackEnd/forum/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"search",
"drf_spectacular",
"images",
"forum.apps.ForumConfig",
]

MIDDLEWARE = [
Expand Down
14 changes: 7 additions & 7 deletions BackEnd/profiles/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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
17 changes: 17 additions & 0 deletions BackEnd/profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -55,6 +56,7 @@ class SavedCompaniesCreate(CreateAPIView):
pagination_class = ForumPagination


@extend_schema(responses={204: {}})
class SavedCompaniesDestroy(DestroyAPIView):
"""
Remove the company from the saved list.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions BackEnd/search/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)

0 comments on commit d51d7aa

Please sign in to comment.