From eb016280ce30382eeaf93d23c5810c98b4e304f2 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 18 Dec 2024 23:24:55 +0200 Subject: [PATCH 1/4] Adjusted profiles filter administration --- BackEnd/administration/filters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BackEnd/administration/filters.py b/BackEnd/administration/filters.py index 874a9ccb..14b580c0 100644 --- a/BackEnd/administration/filters.py +++ b/BackEnd/administration/filters.py @@ -60,8 +60,8 @@ class ProfilesFilter(FilterSet): official_name = filters.CharFilter(lookup_expr="icontains") phone = filters.CharFilter(lookup_expr="icontains") address = filters.CharFilter(lookup_expr="icontains") - created_at = filters.DateFilter(lookup_expr="icontains") - updated_at = filters.DateFilter(lookup_expr="icontains") + created_at = filters.DateFilter() + updated_at = filters.DateFilter() ordering = filters.OrderingFilter( fields=( From 8e62d95a10cd33561bf8b14715755a20bcde9820 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 18 Dec 2024 23:26:08 +0200 Subject: [PATCH 2/4] Adjusted users filter administration --- BackEnd/administration/filters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BackEnd/administration/filters.py b/BackEnd/administration/filters.py index 14b580c0..103cdecb 100644 --- a/BackEnd/administration/filters.py +++ b/BackEnd/administration/filters.py @@ -21,8 +21,8 @@ class UsersFilter(FilterSet): company_name = filters.CharFilter( field_name="profile__name", lookup_expr="icontains" ) - registration_date = filters.CharFilter( - field_name="profile__created_at", lookup_expr="icontains" + registration_date = filters.DateFilter( + field_name="profile__created_at", ) def filter_is_deleted(self, queryset, name, value): From 100b5b8dac9cd81ca698b8719eea8d64442f4e91 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 18 Dec 2024 23:27:04 +0200 Subject: [PATCH 3/4] Adjusted AdminCompanyListSerializer --- BackEnd/administration/serializers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BackEnd/administration/serializers.py b/BackEnd/administration/serializers.py index 3f387258..76145681 100644 --- a/BackEnd/administration/serializers.py +++ b/BackEnd/administration/serializers.py @@ -23,6 +23,7 @@ class Meta: "name_ukr", ) + class ActivitiesSerializer(serializers.ModelSerializer): class Meta: model = Activity @@ -143,17 +144,16 @@ class Meta: "representative", ) - @staticmethod - def get_company_type(obj) -> str: + def get_company_type(self, obj) -> str: return get_company_type_as_string(obj) - @staticmethod - def get_representative(obj): + def get_representative(self, obj): return get_representative_as_string(obj) - @staticmethod - def get_business_entity(obj): + def get_business_entity(self, obj): return get_business_entity_as_string(obj) + + class AdminCompanyDetailSerializer(serializers.ModelSerializer): person = AdminUserDetailSerializer(read_only=True) categories = serializers.SlugRelatedField( From 41949791ed780e0882167237992d8a2b258dd79c Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 19 Dec 2024 00:13:01 +0200 Subject: [PATCH 4/4] Renamed methods in AdminCompanyListSerializer --- BackEnd/administration/serializers.py | 16 ++++++++-------- .../utils/administration/profiles/profiles.py | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/BackEnd/administration/serializers.py b/BackEnd/administration/serializers.py index 76145681..2ed38903 100644 --- a/BackEnd/administration/serializers.py +++ b/BackEnd/administration/serializers.py @@ -4,10 +4,10 @@ from authentication.models import CustomUser from profiles.models import ( Profile, - Region, Category, Activity, + Region, Activity, ) -from utils.administration.profiles.profiles import get_company_type_as_string, get_representative_as_string, \ - get_business_entity_as_string +from utils.administration.profiles.profiles import format_company_type, format_representative, \ + format_business_entity from utils.administration.create_password import generate_password from utils.administration.send_email import send_email_about_admin_registration from .models import AutoModeration, ModerationEmail @@ -145,13 +145,13 @@ class Meta: ) def get_company_type(self, obj) -> str: - return get_company_type_as_string(obj) + return format_company_type(obj) - def get_representative(self, obj): - return get_representative_as_string(obj) + def get_representative(self, obj) -> str: + return format_representative(obj) - def get_business_entity(self, obj): - return get_business_entity_as_string(obj) + def get_business_entity(self, obj) -> str: + return format_business_entity(obj) class AdminCompanyDetailSerializer(serializers.ModelSerializer): diff --git a/BackEnd/utils/administration/profiles/profiles.py b/BackEnd/utils/administration/profiles/profiles.py index f1d53186..1c3c06b6 100644 --- a/BackEnd/utils/administration/profiles/profiles.py +++ b/BackEnd/utils/administration/profiles/profiles.py @@ -1,4 +1,4 @@ -def get_company_type_as_string(obj): +def format_company_type(obj): if obj.is_startup and obj.is_registered: return "Компанія і стартап" if obj.is_registered: @@ -8,13 +8,13 @@ def get_company_type_as_string(obj): return None -def get_representative_as_string(obj): +def format_representative(obj): if obj.person: return f'{obj.person.name} {obj.person.surname}' return None -def get_business_entity_as_string(obj): +def format_business_entity(obj): if obj.is_fop: return "ФОП" return "Юридична особа"