Merge pull request 'feat: auto-evaluation update api serializer class changed' (#50) from behruz into main
Some checks failed
Deploy to Production / build-and-deploy (push) Failing after 1m19s
Some checks failed
Deploy to Production / build-and-deploy (push) Failing after 1m19s
Reviewed-on: #50
This commit is contained in:
@@ -99,6 +99,122 @@ class RetrieveAutoevaluationSerializer(BaseAutoevaluationSerializer):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateAutoevaluationSerializer(serializers.ModelSerializer):
|
||||||
|
property_rights = serializers.PrimaryKeyRelatedField(
|
||||||
|
queryset=ReferenceitemModel.objects.all(),
|
||||||
|
required=False,
|
||||||
|
allow_null=True,
|
||||||
|
)
|
||||||
|
value_determined = serializers.PrimaryKeyRelatedField(
|
||||||
|
queryset=ReferenceitemModel.objects.all(),
|
||||||
|
required=False,
|
||||||
|
allow_null=True,
|
||||||
|
)
|
||||||
|
form_ownership = serializers.PrimaryKeyRelatedField(
|
||||||
|
queryset=ReferenceitemModel.objects.all(),
|
||||||
|
required=False,
|
||||||
|
allow_null=True,
|
||||||
|
)
|
||||||
|
value_determined = serializers.PrimaryKeyRelatedField(
|
||||||
|
queryset=ReferenceitemModel.objects.all(),
|
||||||
|
required=False,
|
||||||
|
allow_null=True,
|
||||||
|
)
|
||||||
|
rate_type = serializers.PrimaryKeyRelatedField(
|
||||||
|
queryset=ReferenceitemModel.objects.all(),
|
||||||
|
required=False,
|
||||||
|
allow_null=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = AutoEvaluationModel
|
||||||
|
fields = [
|
||||||
|
# Step 1
|
||||||
|
"registration_number",
|
||||||
|
"contract_date",
|
||||||
|
"object_inspection_date",
|
||||||
|
"rate_date",
|
||||||
|
"rate_report_date",
|
||||||
|
"rate_object_name",
|
||||||
|
"object_type",
|
||||||
|
# Step 2
|
||||||
|
"object_owner_type",
|
||||||
|
"object_owner_individual_person_f_name",
|
||||||
|
"object_owner_individual_person_l_name",
|
||||||
|
"object_owner_individual_person_p_name",
|
||||||
|
"object_owner_individual_person_passport_num",
|
||||||
|
"object_owner_legal_entity",
|
||||||
|
"object_owner_legal_inn",
|
||||||
|
"property_rights",
|
||||||
|
"form_ownership",
|
||||||
|
"value_determined",
|
||||||
|
"rate_type",
|
||||||
|
# Step 3
|
||||||
|
"object_location_province",
|
||||||
|
"object_location_district",
|
||||||
|
"object_location_city",
|
||||||
|
"object_location_neighborhood",
|
||||||
|
"object_location_street",
|
||||||
|
"object_location_home",
|
||||||
|
"object_location_highways",
|
||||||
|
"object_location_covenience",
|
||||||
|
# Step 4
|
||||||
|
"tex_passport_serie_num",
|
||||||
|
"tex_passport_gived_date",
|
||||||
|
"tex_passport_gived_location",
|
||||||
|
"car_type",
|
||||||
|
"car_wheel",
|
||||||
|
"car_brand",
|
||||||
|
"car_model",
|
||||||
|
"car_number",
|
||||||
|
"manufacture_year",
|
||||||
|
"car_dvigatel_number",
|
||||||
|
"car_color",
|
||||||
|
]
|
||||||
|
|
||||||
|
def validate_tex_passport_serie_num(self, value):
|
||||||
|
if value and not re.match(r"^[A-Z]{3}\s?\d{7}$", value):
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
"Format: AAA 1234567 (3 harf + 7 raqam)"
|
||||||
|
)
|
||||||
|
return value
|
||||||
|
|
||||||
|
def validate_object_owner_individual_person_passport_num(self, value):
|
||||||
|
if value and not re.match(r"^[A-Z]{2}\s?\d{7}$", value):
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
"Format: AA 1234567 (2 harf + 7 raqam)"
|
||||||
|
)
|
||||||
|
return value
|
||||||
|
|
||||||
|
def validate(self, attrs):
|
||||||
|
owner_type = attrs.get("object_owner_type")
|
||||||
|
|
||||||
|
if owner_type == 1:
|
||||||
|
required_fields = {
|
||||||
|
"object_owner_individual_person_f_name": "Ismi",
|
||||||
|
"object_owner_individual_person_l_name": "Familiyasi",
|
||||||
|
"object_owner_individual_person_p_name": "Sharifi",
|
||||||
|
"object_owner_individual_person_passport_num": "Passport raqami",
|
||||||
|
}
|
||||||
|
for field, label in required_fields.items():
|
||||||
|
if not attrs.get(field):
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
{field: f"Jismoniy shaxs uchun {label} majburiy."}
|
||||||
|
)
|
||||||
|
|
||||||
|
elif owner_type == 2:
|
||||||
|
if not attrs.get("object_owner_legal_entity"):
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
{"object_owner_legal_entity": "Yuridik shaxs nomi majburiy."}
|
||||||
|
)
|
||||||
|
if not attrs.get("object_owner_legal_inn"):
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
{"object_owner_legal_inn": "INN raqami majburiy."}
|
||||||
|
)
|
||||||
|
|
||||||
|
return attrs
|
||||||
|
|
||||||
class CreateAutoevaluationSerializer(serializers.ModelSerializer):
|
class CreateAutoevaluationSerializer(serializers.ModelSerializer):
|
||||||
property_rights = serializers.PrimaryKeyRelatedField(
|
property_rights = serializers.PrimaryKeyRelatedField(
|
||||||
queryset=ReferenceitemModel.objects.all(),
|
queryset=ReferenceitemModel.objects.all(),
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ from core.apps.evaluation.serializers.auto import (
|
|||||||
CreateAutoevaluationSerializer,
|
CreateAutoevaluationSerializer,
|
||||||
ListAutoevaluationSerializer,
|
ListAutoevaluationSerializer,
|
||||||
RetrieveAutoevaluationSerializer,
|
RetrieveAutoevaluationSerializer,
|
||||||
AutoEvaluationAppraisersSerializer
|
AutoEvaluationAppraisersSerializer,
|
||||||
|
UpdateAutoevaluationSerializer
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ class AutoEvaluationView(BaseViewSetMixin, ModelViewSet):
|
|||||||
"vehicle",
|
"vehicle",
|
||||||
).all()
|
).all()
|
||||||
serializer_class = ListAutoevaluationSerializer
|
serializer_class = ListAutoevaluationSerializer
|
||||||
permission_classes = [AllowAny]
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||||
filterset_class = AutoevaluationFilter
|
filterset_class = AutoevaluationFilter
|
||||||
@@ -72,6 +73,8 @@ class AutoEvaluationView(BaseViewSetMixin, ModelViewSet):
|
|||||||
"list": ListAutoevaluationSerializer,
|
"list": ListAutoevaluationSerializer,
|
||||||
"retrieve": RetrieveAutoevaluationSerializer,
|
"retrieve": RetrieveAutoevaluationSerializer,
|
||||||
"create": CreateAutoevaluationSerializer,
|
"create": CreateAutoevaluationSerializer,
|
||||||
|
"update": UpdateAutoevaluationSerializer,
|
||||||
|
"partial_update": UpdateAutoevaluationSerializer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -136,8 +139,8 @@ class AutoEvaluationListAppraisersView(GenericAPIView):
|
|||||||
query = auto_evaluation.appraisers.all()
|
query = auto_evaluation.appraisers.all()
|
||||||
if search_query:
|
if search_query:
|
||||||
query = query.filter(
|
query = query.filter(
|
||||||
Q(phone__icontains=search_query) |
|
Q(phone__icontains=search_query) |
|
||||||
Q(first_name__icontains=search_query) |
|
Q(first_name__icontains=search_query) |
|
||||||
Q(last_name__icontains=search_query)
|
Q(last_name__icontains=search_query)
|
||||||
)
|
)
|
||||||
page = self.paginate_queryset(query)
|
page = self.paginate_queryset(query)
|
||||||
|
|||||||
@@ -71,11 +71,28 @@ class AdminEvaluationrequestView(BaseViewSetMixin, ModelViewSet):
|
|||||||
"tex_passport",
|
"tex_passport",
|
||||||
]
|
]
|
||||||
ordering_fields = [
|
ordering_fields = [
|
||||||
|
"id",
|
||||||
|
"rate_type",
|
||||||
|
"rate_type_display",
|
||||||
|
"object_type",
|
||||||
|
"object_type_display",
|
||||||
|
"customer_inn_number",
|
||||||
|
"owner_inn_number",
|
||||||
|
"tex_passport",
|
||||||
|
"value_determined",
|
||||||
|
"rate_goal",
|
||||||
|
"property_rights",
|
||||||
|
"form_ownership",
|
||||||
|
"worked_hours",
|
||||||
|
"chassi",
|
||||||
|
"need_delivering",
|
||||||
|
"location",
|
||||||
|
"location_name",
|
||||||
|
"status",
|
||||||
|
"status_display",
|
||||||
|
"user",
|
||||||
"created_at",
|
"created_at",
|
||||||
"updated_at",
|
"updated_at",
|
||||||
"rate_type",
|
|
||||||
"object_type",
|
|
||||||
"status",
|
|
||||||
]
|
]
|
||||||
ordering = ["-created_at"]
|
ordering = ["-created_at"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user