Skip to content

Commit

Permalink
Merge branch 'refs/heads/1003-admin-backend-management-with-search-an…
Browse files Browse the repository at this point in the history
…d-filter-capabilities' into 1004-admin-frontend-management-with-search-and-filter-capabilities

# Conflicts:
#	BackEnd/administration/serializers.py
  • Loading branch information
AlexanderSychev2005 committed Dec 19, 2024
2 parents d71f3bf + 2ca7879 commit 6bde603
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
8 changes: 4 additions & 4 deletions BackEnd/administration/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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=(
Expand Down
23 changes: 11 additions & 12 deletions BackEnd/administration/serializers.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions BackEnd/utils/administration/profiles/profiles.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 "Юридична особа"

0 comments on commit 6bde603

Please sign in to comment.