diff --git a/BackEnd/administration/filters.py b/BackEnd/administration/filters.py index 14d0b69e..2ed3235e 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 is_deleted_filter(self, queryset, name, value): @@ -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=( diff --git a/BackEnd/administration/serializers.py b/BackEnd/administration/serializers.py index b5d7932f..e4a26f5a 100644 --- a/BackEnd/administration/serializers.py +++ b/BackEnd/administration/serializers.py @@ -1,14 +1,16 @@ from django.contrib.auth import get_user_model from rest_framework import serializers +from rest_framework.validators import UniqueValidator from utils.administration.feedback_category import FeedbackCategory from authentication.models import CustomUser from profiles.models import ( Profile, - Region, Activity, + Region, Category, + 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,17 +147,14 @@ class Meta: "representative", ) - @staticmethod - def get_company_type(obj) -> str: - return get_company_type_as_string(obj) + def get_company_type(self, obj) -> str: + return format_company_type(obj) - @staticmethod - def get_representative(obj): - return get_representative_as_string(obj) + def get_representative(self, obj) -> str: + return format_representative(obj) - @staticmethod - def get_business_entity(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 "Юридична особа"