Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:ita-social-projects/Forum into #584
Browse files Browse the repository at this point in the history
-LogOut
  • Loading branch information
ohorodnykostap committed Jun 10, 2024
2 parents 0f2823e + 1045435 commit 0952d80
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 92 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)
160 changes: 81 additions & 79 deletions FrontEnd/src/components/CompanyCard/CompanyCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,96 +60,98 @@ export default function CompanyCard({
};

return (
<div className={styles['company-card']}>
<div className={styles['company-card__block']}>
<div className={styles['company-card__image-frame']}>
{profile.banner_image ? (
<img
src={profile.banner_image}
alt="Company Banner"
className={styles['company-card__image']}
/>
) : (
<img
className={styles['company-card__empty-image']}
src={`${process.env.REACT_APP_PUBLIC_URL}/svg/profile-view-image-empty.svg`}
alt={profile.name}
/>
)}
</div>
<div className={styles['company-card__text-block']}>
<Tooltip
title={activitiesString}
placement="bottom"
pointAtCenter={true}
>
<div className={styles['company-card__category-text']}>
{activitiesSliceString}
</div>
</Tooltip>
<div className={styles['company-card__text-block__header']}>
<div className={styles['company-card__name-text']}>
<Link
className={styles['company-card__name-text_link']}
to={`/profile-detail/${profile.id}`}
>
{profile.name}
</Link>
</div>
<div className={styles['company-card']}>
<Link
className={styles['company-card__link']}
to={`/profile-detail/${profile.id}`}
>
<div className={styles['company-card__block']}>
<div className={styles['company-card__image-frame']}>
{profile.banner_image ? (
<img
src={profile.banner_image}
alt="Company Banner"
className={styles['company-card__image']}
/>
) : (
<img
className={styles['company-card__empty-image']}
src={`${process.env.REACT_APP_PUBLIC_URL}/svg/profile-view-image-empty.svg`}
alt={profile.name}
/>
)}
</div>
<Tooltip
title={profile.regions_ukr_display}
placement="bottom"
pointAtCenter={true}
>
<div className={styles['company-card__region-text']}>
{profile.regions_ukr_display
? profile.regions_ukr_display.length < lengthOfRegion
? `${profile.regions_ukr_display}`
: `${profile.regions_ukr_display.substring(0, 35)}...`
: ''}
<div className={styles['company-card__text-block']}>
<Tooltip
title={activitiesString}
placement="bottom"
pointAtCenter={true}
>
<div className={styles['company-card__category-text']}>
{activitiesSliceString}
</div>
</Tooltip>
<div className={styles['company-card__text-block__header']}>
<div className={styles['company-card__name-text']}>
{profile.name}
</div>
</div>
</Tooltip>
<div className={styles['company-card__footer_content']}>
<Tooltip
title={
profile.categories &&
profile.categories.map((element) => element.name).join(', ')
}
title={profile.regions_ukr_display}
placement="bottom"
pointAtCenter={true}
>
<div className={styles['company-card__badges_block']}>
<CategoryBadges categories={profile.categories.slice(0, 3)} />
<div className={styles['company-card__region-text']}>
{profile.regions_ukr_display
? profile.regions_ukr_display.length < lengthOfRegion
? profile.regions_ukr_display
: `${profile.regions_ukr_display.substring(0, 35)}...`
: ''}
</div>
</Tooltip>
<StarForLike
isSaved={profile.is_saved}
isAuthorized={isAuthorized}
ownProfile={ownProfile}
handleClick={handleClick}
></StarForLike>
<div className={styles['company-card__footer_content']}>
<Tooltip
title={
profile.categories &&
profile.categories.map((element) => element.name).join(', ')
}
placement="bottom"
pointAtCenter={true}
>
<div className={styles['company-card__badges_block']}>
<CategoryBadges categories={profile.categories.slice(0, 3)} />
</div>
</Tooltip>
</div>
</div>
</div>
<div className={styles['company-card__logo']}>
<div className={styles['company-card__logo-ellipse']}>
{profile.logo_image ? (
<img
src={profile.logo_image}
alt="Logo"
className={styles['company-card__logo-image']}
/>
) : (
<img
className={styles['company-card__logo-image']}
src={`${process.env.REACT_APP_PUBLIC_URL}/companies-logos/default_logo.png`}
alt=""
/>
)}
</div>
</div>
</Link>
<div className={styles['company-card__star']}>
<StarForLike
isSaved={profile.is_saved}
isAuthorized={isAuthorized}
ownProfile={ownProfile}
handleClick={handleClick}
/>
</div>
</div>
<div className={styles['company-card__logo']}>
<div className={styles['company-card__logo-ellipse']}>
{profile.logo_image ? (
<img
src={profile.logo_image}
alt="Logo"
className={styles['company-card__logo-image']}
/>
) : (
<img
className={styles['company-card__logo-image']}
src={`${process.env.REACT_APP_PUBLIC_URL}/companies-logos/default_logo.png`}
alt=""
/>
)}
</div>
</div>
</div>
);
}

Expand Down
6 changes: 6 additions & 0 deletions FrontEnd/src/components/CompanyCard/CompanyCard.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,9 @@
.company-card__buttons:hover {
cursor: pointer;
}

.company-card__star {
position: absolute;
margin-left: 320px;
margin-top: -35px;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.star {
color: #ffd800;
font-size: 24px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

.data-block__field {
display: flex;
height: 32px;
align-items: center;
min-height: 32px;
align-items: self-start;
gap: 8px;
}

Expand Down

0 comments on commit 0952d80

Please sign in to comment.