From bec15fbca440f9b6b2ffeac19714e6467a1769a8 Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Fri, 31 May 2024 22:00:55 +0200 Subject: [PATCH 1/4] TokenDestroyView bug in Swagger docs fixed --- BackEnd/forum/apps.py | 8 ++++++++ BackEnd/forum/schema.py | 18 ++++++++++++++++++ BackEnd/forum/settings.py | 1 + 3 files changed, 27 insertions(+) create mode 100644 BackEnd/forum/apps.py create mode 100644 BackEnd/forum/schema.py 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 = [ From 0d9007c83aa7d99446b4a0524f98cf573ad948cb Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Fri, 31 May 2024 22:08:30 +0200 Subject: [PATCH 2/4] type annotations, extend_schema - Swagger docs bugs fixed --- BackEnd/profiles/serializers.py | 14 +++++++------- BackEnd/profiles/views.py | 17 +++++++++++++++++ BackEnd/search/serializers.py | 6 +++--- 3 files changed, 27 insertions(+), 10 deletions(-) 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) From 952836356a1fad107e82ef72b85d745d912c6610 Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Mon, 3 Jun 2024 17:52:11 +0200 Subject: [PATCH 3/4] link to company profile moved --- .../components/CompanyCard/CompanyCard.jsx | 160 +++++++++--------- .../CompanyCard/CompanyCard.module.css | 6 + .../MiniComponents/StarForLike.module.css | 2 +- 3 files changed, 88 insertions(+), 80 deletions(-) diff --git a/FrontEnd/src/components/CompanyCard/CompanyCard.jsx b/FrontEnd/src/components/CompanyCard/CompanyCard.jsx index 172f253fc..43637b0e1 100644 --- a/FrontEnd/src/components/CompanyCard/CompanyCard.jsx +++ b/FrontEnd/src/components/CompanyCard/CompanyCard.jsx @@ -60,96 +60,98 @@ export default function CompanyCard({ }; return ( -
-
-
- {profile.banner_image ? ( - Company Banner - ) : ( - {profile.name} - )} -
-
- -
- {activitiesSliceString} -
-
-
-
- - {profile.name} - -
+
+ +
+
+ {profile.banner_image ? ( + Company Banner + ) : ( + {profile.name} + )}
- -
- {profile.regions_ukr_display - ? profile.regions_ukr_display.length < lengthOfRegion - ? `${profile.regions_ukr_display}` - : `${profile.regions_ukr_display.substring(0, 35)}...` - : ''} +
+ +
+ {activitiesSliceString} +
+
+
+
+ {profile.name} +
- -
element.name).join(', ') - } + title={profile.regions_ukr_display} placement="bottom" pointAtCenter={true} > -
- +
+ {profile.regions_ukr_display + ? profile.regions_ukr_display.length < lengthOfRegion + ? profile.regions_ukr_display + : `${profile.regions_ukr_display.substring(0, 35)}...` + : ''}
- +
+ element.name).join(', ') + } + placement="bottom" + pointAtCenter={true} + > +
+ +
+
+
+
+
+ {profile.logo_image ? ( + Logo + ) : ( + + )} +
+
+ +
+ +
-
-
- {profile.logo_image ? ( - Logo - ) : ( - - )} -
-
-
); } diff --git a/FrontEnd/src/components/CompanyCard/CompanyCard.module.css b/FrontEnd/src/components/CompanyCard/CompanyCard.module.css index 593c6529c..44a38ae2f 100644 --- a/FrontEnd/src/components/CompanyCard/CompanyCard.module.css +++ b/FrontEnd/src/components/CompanyCard/CompanyCard.module.css @@ -180,3 +180,9 @@ .company-card__buttons:hover { cursor: pointer; } + +.company-card__star { + position: absolute; + margin-left: 320px; + margin-top: -35px; +} \ No newline at end of file diff --git a/FrontEnd/src/components/MiniComponents/StarForLike.module.css b/FrontEnd/src/components/MiniComponents/StarForLike.module.css index f06b39487..c71b2d7e1 100644 --- a/FrontEnd/src/components/MiniComponents/StarForLike.module.css +++ b/FrontEnd/src/components/MiniComponents/StarForLike.module.css @@ -1,4 +1,4 @@ .star { color: #ffd800; font-size: 24px; -} +} \ No newline at end of file From 4c7dda2bdfefef37b3736d7e85546a604a9df779 Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Mon, 3 Jun 2024 17:54:03 +0200 Subject: [PATCH 4/4] styles in company address fixed --- .../ProfileDetail/DetailedInfo/DataContacts.module.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FrontEnd/src/components/ProfileDetail/DetailedInfo/DataContacts.module.css b/FrontEnd/src/components/ProfileDetail/DetailedInfo/DataContacts.module.css index 3d41963af..3b3704405 100644 --- a/FrontEnd/src/components/ProfileDetail/DetailedInfo/DataContacts.module.css +++ b/FrontEnd/src/components/ProfileDetail/DetailedInfo/DataContacts.module.css @@ -26,8 +26,8 @@ .data-block__field { display: flex; - height: 32px; - align-items: center; + min-height: 32px; + align-items: self-start; gap: 8px; }