Compare commits
29 Commits
feat/auto-
...
d5a132c75b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5a132c75b | ||
| 09862985e1 | |||
| e9d779d489 | |||
| b8dcbe811d | |||
|
|
0dbd246120 | ||
|
|
9d8fd8e6de | ||
| 41b63b1645 | |||
| 22740e59a7 | |||
| 43e6d8190e | |||
| ea020ae500 | |||
| ad1e61498c | |||
| 2492583f43 | |||
|
|
c4330fd6f7 | ||
| 11f967da42 | |||
|
|
f13f1eb16f | ||
|
|
2ed50e10d9 | ||
| b3f60b257a | |||
|
|
7f8858ac7e | ||
|
|
28fdf82c08 | ||
| a06cf173b6 | |||
|
|
9593b02c2d | ||
| 386e9ead89 | |||
|
|
9a13a2b4f0 | ||
|
|
9b57611b62 | ||
| 4479a0c1a5 | |||
|
|
0d574a92a9 | ||
|
|
397f239b1d | ||
| 7bcf7bdc7f | |||
|
|
93757b0342 |
@@ -48,6 +48,11 @@ PAGES = [
|
|||||||
"title": _("Arizalar"),
|
"title": _("Arizalar"),
|
||||||
"separator": True,
|
"separator": True,
|
||||||
"items": [
|
"items": [
|
||||||
|
{
|
||||||
|
"title": _("Baholash so'rovlari"),
|
||||||
|
"icon": "rate_review",
|
||||||
|
"link": reverse_lazy("admin:evaluation_evaluationrequestmodel_changelist"),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"title": _("Barcha arizalar"),
|
"title": _("Barcha arizalar"),
|
||||||
"icon": "description",
|
"icon": "description",
|
||||||
@@ -107,6 +112,22 @@ PAGES = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"title": _("Tarix"),
|
||||||
|
"separator": True,
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"title": _("Avto baholash tarixi"),
|
||||||
|
"icon": "history",
|
||||||
|
"link": reverse_lazy("admin:evaluation_autoevaluationhistorymodel_changelist"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": _("Tezkor baholash tarixi"),
|
||||||
|
"icon": "manage_history",
|
||||||
|
"link": reverse_lazy("admin:evaluation_quickevaluationhistorymodel_changelist"),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"title": _("Ma'lumotnomalari"),
|
"title": _("Ma'lumotnomalari"),
|
||||||
"separator": True,
|
"separator": True,
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
|
|
||||||
REST_FRAMEWORK: Union[Any] = {
|
REST_FRAMEWORK: Union[Any] = {
|
||||||
"DEFAULT_AUTHENTICATION_CLASSES": ("rest_framework_simplejwt.authentication.JWTAuthentication",),
|
"DEFAULT_AUTHENTICATION_CLASSES": (
|
||||||
|
"rest_framework.authentication.SessionAuthentication",
|
||||||
|
"rest_framework.authentication.BaseAuthentication",
|
||||||
|
"rest_framework_simplejwt.authentication.JWTAuthentication",
|
||||||
|
),
|
||||||
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
|
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
|
||||||
"DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated"],
|
"DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated"],
|
||||||
"DEFAULT_PAGINATION_CLASS": "django_core.paginations.CustomPagination",
|
"DEFAULT_PAGINATION_CLASS": "django_core.paginations.CustomPagination",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from config.env import env
|
|||||||
|
|
||||||
|
|
||||||
def home(request):
|
def home(request):
|
||||||
return HttpResponse("OK: #5bb3dcd432ba0c045e6f2ef91c23bd4a16a1d256")
|
return HttpResponse("OK: #41b63b164568ae8a39bf2da91742e783736bf9cb")
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from django.contrib.auth import admin
|
from django.contrib.auth import admin
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
from unfold.admin import ModelAdmin
|
from unfold.admin import ModelAdmin
|
||||||
from unfold.forms import AdminPasswordChangeForm # UserCreationForm,
|
from unfold.forms import AdminPasswordChangeForm # UserCreationForm,
|
||||||
from unfold.forms import UserChangeForm
|
from unfold.forms import UserChangeForm
|
||||||
@@ -10,6 +11,7 @@ class CustomUserAdmin(admin.UserAdmin, ModelAdmin):
|
|||||||
# add_form = UserCreationForm
|
# add_form = UserCreationForm
|
||||||
form = UserChangeForm
|
form = UserChangeForm
|
||||||
list_display = (
|
list_display = (
|
||||||
|
"display_avatar",
|
||||||
"first_name",
|
"first_name",
|
||||||
"last_name",
|
"last_name",
|
||||||
"phone",
|
"phone",
|
||||||
@@ -17,7 +19,7 @@ class CustomUserAdmin(admin.UserAdmin, ModelAdmin):
|
|||||||
)
|
)
|
||||||
search_fields = ("phone", "first_name", "last_name", "username")
|
search_fields = ("phone", "first_name", "last_name", "username")
|
||||||
autocomplete_fields = ["groups", "user_permissions"]
|
autocomplete_fields = ["groups", "user_permissions"]
|
||||||
fieldsets = ((None, {"fields": ("phone",)}),) + (
|
fieldsets = ((None, {"fields": ("phone", "avatar",)}),) + (
|
||||||
(None, {"fields": ("username", "password")}),
|
(None, {"fields": ("username", "password")}),
|
||||||
(_("Personal info"), {"fields": ("first_name", "last_name", "email")}),
|
(_("Personal info"), {"fields": ("first_name", "last_name", "email")}),
|
||||||
(
|
(
|
||||||
@@ -36,6 +38,15 @@ class CustomUserAdmin(admin.UserAdmin, ModelAdmin):
|
|||||||
(_("Important dates"), {"fields": ("last_login", "date_joined")}),
|
(_("Important dates"), {"fields": ("last_login", "date_joined")}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def display_avatar(self, obj):
|
||||||
|
if obj.avatar:
|
||||||
|
return mark_safe(
|
||||||
|
f'<img src="{obj.avatar.url}" width="35" height="35" style="border-radius: 50%; object-fit: cover;" />'
|
||||||
|
)
|
||||||
|
return _("No Image")
|
||||||
|
|
||||||
|
display_avatar.short_description = _("Avatar")
|
||||||
|
|
||||||
|
|
||||||
class PermissionAdmin(ModelAdmin):
|
class PermissionAdmin(ModelAdmin):
|
||||||
list_display = ("name",)
|
list_display = ("name",)
|
||||||
|
|||||||
18
core/apps/accounts/migrations/0003_user_avatar.py
Normal file
18
core/apps/accounts/migrations/0003_user_avatar.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-03-17 12:32
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('accounts', '0002_alter_user_role'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='user',
|
||||||
|
name='avatar',
|
||||||
|
field=models.ImageField(blank=True, null=True, upload_to='avatars/'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -16,6 +16,7 @@ class User(auth_models.AbstractUser):
|
|||||||
choices=RoleChoice,
|
choices=RoleChoice,
|
||||||
default=RoleChoice.USER,
|
default=RoleChoice.USER,
|
||||||
)
|
)
|
||||||
|
avatar = models.ImageField(upload_to="avatars/", null=True, blank=True)
|
||||||
|
|
||||||
USERNAME_FIELD = "phone"
|
USERNAME_FIELD = "phone"
|
||||||
objects = UserManager()
|
objects = UserManager()
|
||||||
|
|||||||
@@ -19,5 +19,6 @@ class UserUpdateSerializer(serializers.ModelSerializer):
|
|||||||
model = get_user_model()
|
model = get_user_model()
|
||||||
fields = [
|
fields = [
|
||||||
"first_name",
|
"first_name",
|
||||||
"last_name"
|
"last_name",
|
||||||
|
"avatar"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from django.contrib.auth import get_user_model
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django_core import exceptions
|
from django_core import exceptions
|
||||||
from drf_spectacular.utils import extend_schema
|
from drf_spectacular.utils import extend_schema
|
||||||
from rest_framework import status, throttling, request
|
from rest_framework import status, throttling, request, parsers
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.exceptions import PermissionDenied
|
from rest_framework.exceptions import PermissionDenied
|
||||||
from rest_framework.viewsets import GenericViewSet
|
from rest_framework.viewsets import GenericViewSet
|
||||||
@@ -160,6 +160,11 @@ class ResetPasswordView(BaseViewSetMixin, GenericViewSet, UserService):
|
|||||||
@extend_schema(tags=["me"])
|
@extend_schema(tags=["me"])
|
||||||
class MeView(BaseViewSetMixin, GenericViewSet, UserService):
|
class MeView(BaseViewSetMixin, GenericViewSet, UserService):
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
|
parser_classes = (
|
||||||
|
parsers.MultiPartParser,
|
||||||
|
parsers.FormParser,
|
||||||
|
parsers.JSONParser,
|
||||||
|
)
|
||||||
|
|
||||||
def get_serializer_class(self):
|
def get_serializer_class(self):
|
||||||
match self.action:
|
match self.action:
|
||||||
@@ -178,8 +183,8 @@ class MeView(BaseViewSetMixin, GenericViewSet, UserService):
|
|||||||
def user_update(self, request):
|
def user_update(self, request):
|
||||||
ser = self.get_serializer(instance=request.user, data=request.data, partial=True)
|
ser = self.get_serializer(instance=request.user, data=request.data, partial=True)
|
||||||
ser.is_valid(raise_exception=True)
|
ser.is_valid(raise_exception=True)
|
||||||
ser.save()
|
data = ser.save()
|
||||||
return Response({"detail": _("Malumotlar yangilandi")})
|
return Response(UserSerializer(data).data)
|
||||||
|
|
||||||
|
|
||||||
@extend_schema(tags=["change-password"], description="Parolni o'zgartirish uchun")
|
@extend_schema(tags=["change-password"], description="Parolni o'zgartirish uchun")
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
from .auto import * # noqa
|
from .auto import * # noqa
|
||||||
from .customer import * # noqa
|
from .customer import * # noqa
|
||||||
from .document import * # noqa
|
from .document import * # noqa
|
||||||
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
from .real_estate import * # noqa
|
from .real_estate import * # noqa
|
||||||
from .reference import * # noqa
|
from .reference import * # noqa
|
||||||
from .report import * # noqa
|
from .report import * # noqa
|
||||||
|
from .request import * # noqa
|
||||||
from .valuation import * # noqa
|
from .valuation import * # noqa
|
||||||
from .vehicle import * # noqa
|
from .vehicle import * # noqa
|
||||||
|
|||||||
157
core/apps/evaluation/admin/history.py
Normal file
157
core/apps/evaluation/admin/history.py
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from unfold.admin import ModelAdmin
|
||||||
|
|
||||||
|
from core.apps.evaluation.choices.history import EvaluationEventType
|
||||||
|
from core.apps.evaluation.models import AutoevaluationhistoryModel, QuickevaluationhistoryModel
|
||||||
|
|
||||||
|
|
||||||
|
class BaseHistoryAdmin(ModelAdmin):
|
||||||
|
"""
|
||||||
|
History yozuvlari o'zgartirib bo'lmaydi — faqat o'qiladi.
|
||||||
|
Signallar tomonidan avtomatik yoziladi.
|
||||||
|
"""
|
||||||
|
|
||||||
|
list_filter = (
|
||||||
|
"event_type",
|
||||||
|
"actor_role",
|
||||||
|
"created_at",
|
||||||
|
)
|
||||||
|
search_fields = (
|
||||||
|
"actor_full_name",
|
||||||
|
"meta",
|
||||||
|
)
|
||||||
|
ordering = ("created_at",)
|
||||||
|
|
||||||
|
def has_add_permission(self, request):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def has_change_permission(self, request, obj=None):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def has_delete_permission(self, request, obj=None):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(AutoevaluationhistoryModel)
|
||||||
|
class AutoevaluationhistoryAdmin(BaseHistoryAdmin):
|
||||||
|
list_display = (
|
||||||
|
"id",
|
||||||
|
"auto_evaluation",
|
||||||
|
"event_type_colored",
|
||||||
|
"actor_full_name",
|
||||||
|
"actor_role",
|
||||||
|
"created_at",
|
||||||
|
)
|
||||||
|
autocomplete_fields = ("auto_evaluation",)
|
||||||
|
readonly_fields = (
|
||||||
|
"auto_evaluation",
|
||||||
|
"event_type",
|
||||||
|
"actor_id",
|
||||||
|
"actor_full_name",
|
||||||
|
"actor_role",
|
||||||
|
"meta",
|
||||||
|
"created_at",
|
||||||
|
)
|
||||||
|
fieldsets = (
|
||||||
|
(_("Baholash"), {
|
||||||
|
"fields": ("auto_evaluation",),
|
||||||
|
}),
|
||||||
|
(_("Hodisa"), {
|
||||||
|
"fields": (
|
||||||
|
"event_type",
|
||||||
|
"meta",
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
(_("Kim bajargan"), {
|
||||||
|
"fields": (
|
||||||
|
"actor_id",
|
||||||
|
"actor_full_name",
|
||||||
|
"actor_role",
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
(_("Tizim"), {
|
||||||
|
"classes": ("collapse",),
|
||||||
|
"fields": ("created_at",),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
@admin.display(description=_("Hodisa turi"))
|
||||||
|
def event_type_colored(self, obj):
|
||||||
|
colors = {
|
||||||
|
EvaluationEventType.ORDER_CREATED: "#16a34a",
|
||||||
|
EvaluationEventType.STATUS_CHANGED: "#2563eb",
|
||||||
|
EvaluationEventType.EVALUATOR_ASSIGNED: "#7c3aed",
|
||||||
|
EvaluationEventType.DOCUMENT_UPLOADED: "#d97706",
|
||||||
|
EvaluationEventType.PAYMENT_MADE: "#dc2626",
|
||||||
|
}
|
||||||
|
color = colors.get(obj.event_type, "#6b7280")
|
||||||
|
label = obj.get_event_type_display()
|
||||||
|
from django.utils.html import format_html
|
||||||
|
return format_html(
|
||||||
|
'<span style="color:{}; font-weight:600;">{}</span>',
|
||||||
|
color,
|
||||||
|
label,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(QuickevaluationhistoryModel)
|
||||||
|
class QuickevaluationhistoryAdmin(BaseHistoryAdmin):
|
||||||
|
list_display = (
|
||||||
|
"id",
|
||||||
|
"quick_evaluation",
|
||||||
|
"event_type_colored",
|
||||||
|
"actor_full_name",
|
||||||
|
"actor_role",
|
||||||
|
"created_at",
|
||||||
|
)
|
||||||
|
autocomplete_fields = ("quick_evaluation",)
|
||||||
|
readonly_fields = (
|
||||||
|
"quick_evaluation",
|
||||||
|
"event_type",
|
||||||
|
"actor_id",
|
||||||
|
"actor_full_name",
|
||||||
|
"actor_role",
|
||||||
|
"meta",
|
||||||
|
"created_at",
|
||||||
|
)
|
||||||
|
fieldsets = (
|
||||||
|
(_("Tezkor baholash"), {
|
||||||
|
"fields": ("quick_evaluation",),
|
||||||
|
}),
|
||||||
|
(_("Hodisa"), {
|
||||||
|
"fields": (
|
||||||
|
"event_type",
|
||||||
|
"meta",
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
(_("Kim bajargan"), {
|
||||||
|
"fields": (
|
||||||
|
"actor_id",
|
||||||
|
"actor_full_name",
|
||||||
|
"actor_role",
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
(_("Tizim"), {
|
||||||
|
"classes": ("collapse",),
|
||||||
|
"fields": ("created_at",),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
@admin.display(description=_("Hodisa turi"))
|
||||||
|
def event_type_colored(self, obj):
|
||||||
|
colors = {
|
||||||
|
EvaluationEventType.ORDER_CREATED: "#16a34a",
|
||||||
|
EvaluationEventType.STATUS_CHANGED: "#2563eb",
|
||||||
|
EvaluationEventType.EVALUATOR_ASSIGNED: "#7c3aed",
|
||||||
|
EvaluationEventType.DOCUMENT_UPLOADED: "#d97706",
|
||||||
|
EvaluationEventType.PAYMENT_MADE: "#dc2626",
|
||||||
|
}
|
||||||
|
color = colors.get(obj.event_type, "#6b7280")
|
||||||
|
label = obj.get_event_type_display()
|
||||||
|
from django.utils.html import format_html
|
||||||
|
return format_html(
|
||||||
|
'<span style="color:{}; font-weight:600;">{}</span>',
|
||||||
|
color,
|
||||||
|
label,
|
||||||
|
)
|
||||||
63
core/apps/evaluation/admin/request.py
Normal file
63
core/apps/evaluation/admin/request.py
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from unfold.admin import ModelAdmin
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import EvaluationrequestModel
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(EvaluationrequestModel)
|
||||||
|
class EvaluationrequestAdmin(ModelAdmin):
|
||||||
|
list_display = (
|
||||||
|
"id",
|
||||||
|
"user",
|
||||||
|
"rate_type",
|
||||||
|
"object_type",
|
||||||
|
"customer_inn_number",
|
||||||
|
"owner_inn_number",
|
||||||
|
"status",
|
||||||
|
"need_delivering",
|
||||||
|
"created_at",
|
||||||
|
)
|
||||||
|
list_filter = ("status", "rate_type", "object_type", "need_delivering")
|
||||||
|
search_fields = (
|
||||||
|
"customer_inn_number",
|
||||||
|
"owner_inn_number",
|
||||||
|
"tex_passport",
|
||||||
|
"user__phone",
|
||||||
|
)
|
||||||
|
readonly_fields = ("created_at", "updated_at")
|
||||||
|
fieldsets = (
|
||||||
|
("Asosiy", {
|
||||||
|
"fields": (
|
||||||
|
"user",
|
||||||
|
"rate_type",
|
||||||
|
"object_type",
|
||||||
|
"status",
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
("Buyurtmachi", {
|
||||||
|
"fields": (
|
||||||
|
("customer_inn_number", "owner_inn_number"),
|
||||||
|
"tex_passport",
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
("Baholash parametrlari", {
|
||||||
|
"fields": (
|
||||||
|
("value_determined", "rate_goal"),
|
||||||
|
("property_rights", "form_ownership"),
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
("Qo'shimcha (truck_car)", {
|
||||||
|
"classes": ("collapse",),
|
||||||
|
"fields": ("worked_hours", "chassi"),
|
||||||
|
}),
|
||||||
|
("Yetkazish", {
|
||||||
|
"fields": (
|
||||||
|
"need_delivering",
|
||||||
|
("location_lat", "location_lng"),
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
("Tizim", {
|
||||||
|
"classes": ("collapse",),
|
||||||
|
"fields": ("created_at", "updated_at"),
|
||||||
|
}),
|
||||||
|
)
|
||||||
@@ -4,3 +4,6 @@ from django.apps import AppConfig
|
|||||||
class ModuleConfig(AppConfig):
|
class ModuleConfig(AppConfig):
|
||||||
default_auto_field = "django.db.models.BigAutoField"
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
name = "core.apps.evaluation"
|
name = "core.apps.evaluation"
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
import core.apps.evaluation.signals # noqa
|
||||||
|
|||||||
10
core/apps/evaluation/choices/history.py
Normal file
10
core/apps/evaluation/choices/history.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
|
class EvaluationEventType(models.TextChoices):
|
||||||
|
ORDER_CREATED = "order_created", _("Buyurtma yaratildi")
|
||||||
|
STATUS_CHANGED = "status_changed", _("Status o'zgartirildi")
|
||||||
|
EVALUATOR_ASSIGNED = "evaluator_assigned", _("Baholovchi biriktirildi")
|
||||||
|
DOCUMENT_UPLOADED = "document_uploaded", _("Hujjat yuklandi")
|
||||||
|
PAYMENT_MADE = "payment_made", _("To'lov qilindi")
|
||||||
@@ -10,3 +10,7 @@ class ReferenceType(models.TextChoices):
|
|||||||
BODY_TYPE = "body_type", _("Body type")
|
BODY_TYPE = "body_type", _("Body type")
|
||||||
CAR_POSITION = "car_position", _("Car position")
|
CAR_POSITION = "car_position", _("Car position")
|
||||||
STATE_CAR = "state_car", _("Car state")
|
STATE_CAR = "state_car", _("Car state")
|
||||||
|
EVALUATION_PURPOSE = "evaluation_purpose", _("Evaluation purpose")
|
||||||
|
DETERMINED_VALUE = "determined_value", _("Determined value type")
|
||||||
|
PROPERTY_RIGHTS = "property_rights", _("Property rights")
|
||||||
|
OWNERSHIP_FORM = "ownership_form", _("Ownership form")
|
||||||
|
|||||||
21
core/apps/evaluation/choices/request.py
Normal file
21
core/apps/evaluation/choices/request.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
|
class EvaluationRateType(models.TextChoices):
|
||||||
|
AUTO = "auto", _("Automobil")
|
||||||
|
REAL_ESTATE = "real_estate", _("Ko'chmas mulk")
|
||||||
|
EQUIPMENT = "equipment", _("Uskuna")
|
||||||
|
|
||||||
|
|
||||||
|
class RequestObjectType(models.TextChoices):
|
||||||
|
LIGHTWEIGHT_AUTO = "lightweight_auto", _("Yengil automobil")
|
||||||
|
TRUCK_CAR = "truck_car", _("Yuk automobil")
|
||||||
|
SPECIAL_TECH = "special_tech", _("Maxsus texnika")
|
||||||
|
|
||||||
|
|
||||||
|
class RequestStatus(models.TextChoices):
|
||||||
|
PENDING = "pending", _("Kutilmoqda")
|
||||||
|
IN_PROGRESS = "in_progress", _("Jarayonda")
|
||||||
|
COMPLETED = "completed", _("Bajarildi")
|
||||||
|
REJECTED = "rejected", _("Rad etildi")
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
from .auto import * # noqa
|
from .auto import * # noqa
|
||||||
from .customer import * # noqa
|
from .customer import * # noqa
|
||||||
from .document import * # noqa
|
from .document import * # noqa
|
||||||
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
from .real_estate import * # noqa
|
from .real_estate import * # noqa
|
||||||
from .reference import * # noqa
|
from .reference import * # noqa
|
||||||
from .report import * # noqa
|
from .report import * # noqa
|
||||||
|
from .request import * # noqa
|
||||||
from .valuation import * # noqa
|
from .valuation import * # noqa
|
||||||
from .vehicle import * # noqa
|
from .vehicle import * # noqa
|
||||||
|
|||||||
54
core/apps/evaluation/filters/history.py
Normal file
54
core/apps/evaluation/filters/history.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
from django_filters import rest_framework as filters
|
||||||
|
|
||||||
|
from core.apps.evaluation.choices.history import EvaluationEventType
|
||||||
|
from core.apps.evaluation.models import AutoevaluationhistoryModel, QuickevaluationhistoryModel
|
||||||
|
|
||||||
|
|
||||||
|
class AutoevaluationhistoryFilter(filters.FilterSet):
|
||||||
|
auto_evaluation = filters.NumberFilter(
|
||||||
|
field_name="auto_evaluation", lookup_expr="exact"
|
||||||
|
)
|
||||||
|
event_type = filters.ChoiceFilter(
|
||||||
|
field_name="event_type",
|
||||||
|
choices=EvaluationEventType.choices,
|
||||||
|
)
|
||||||
|
created_from = filters.DateTimeFilter(
|
||||||
|
field_name="created_at", lookup_expr="gte"
|
||||||
|
)
|
||||||
|
created_to = filters.DateTimeFilter(
|
||||||
|
field_name="created_at", lookup_expr="lte"
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = AutoevaluationhistoryModel
|
||||||
|
fields = [
|
||||||
|
"auto_evaluation",
|
||||||
|
"event_type",
|
||||||
|
"created_from",
|
||||||
|
"created_to",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class QuickevaluationhistoryFilter(filters.FilterSet):
|
||||||
|
quick_evaluation = filters.NumberFilter(
|
||||||
|
field_name="quick_evaluation", lookup_expr="exact"
|
||||||
|
)
|
||||||
|
event_type = filters.ChoiceFilter(
|
||||||
|
field_name="event_type",
|
||||||
|
choices=EvaluationEventType.choices,
|
||||||
|
)
|
||||||
|
created_from = filters.DateTimeFilter(
|
||||||
|
field_name="created_at", lookup_expr="gte"
|
||||||
|
)
|
||||||
|
created_to = filters.DateTimeFilter(
|
||||||
|
field_name="created_at", lookup_expr="lte"
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = QuickevaluationhistoryModel
|
||||||
|
fields = [
|
||||||
|
"quick_evaluation",
|
||||||
|
"event_type",
|
||||||
|
"created_from",
|
||||||
|
"created_to",
|
||||||
|
]
|
||||||
35
core/apps/evaluation/filters/request.py
Normal file
35
core/apps/evaluation/filters/request.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
from django_filters import rest_framework as filters
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import EvaluationrequestModel
|
||||||
|
|
||||||
|
|
||||||
|
class EvaluationrequestFilter(filters.FilterSet):
|
||||||
|
rate_type = filters.CharFilter(field_name="rate_type", lookup_expr="exact")
|
||||||
|
object_type = filters.CharFilter(field_name="object_type", lookup_expr="exact")
|
||||||
|
status = filters.CharFilter(field_name="status", lookup_expr="exact")
|
||||||
|
need_delivering = filters.BooleanFilter(field_name="need_delivering")
|
||||||
|
customer_inn_number = filters.CharFilter(
|
||||||
|
field_name="customer_inn_number", lookup_expr="icontains"
|
||||||
|
)
|
||||||
|
owner_inn_number = filters.CharFilter(
|
||||||
|
field_name="owner_inn_number", lookup_expr="icontains"
|
||||||
|
)
|
||||||
|
tex_passport = filters.CharFilter(
|
||||||
|
field_name="tex_passport", lookup_expr="icontains"
|
||||||
|
)
|
||||||
|
date_from = filters.DateFilter(field_name="created_at", lookup_expr="gte")
|
||||||
|
date_to = filters.DateFilter(field_name="created_at", lookup_expr="lte")
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = EvaluationrequestModel
|
||||||
|
fields = [
|
||||||
|
"rate_type",
|
||||||
|
"object_type",
|
||||||
|
"status",
|
||||||
|
"need_delivering",
|
||||||
|
"customer_inn_number",
|
||||||
|
"owner_inn_number",
|
||||||
|
"tex_passport",
|
||||||
|
"date_from",
|
||||||
|
"date_to",
|
||||||
|
]
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
from .auto import * # noqa
|
from .auto import * # noqa
|
||||||
from .customer import * # noqa
|
from .customer import * # noqa
|
||||||
from .document import * # noqa
|
from .document import * # noqa
|
||||||
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
from .real_estate import * # noqa
|
from .real_estate import * # noqa
|
||||||
from .reference import * # noqa
|
from .reference import * # noqa
|
||||||
from .report import * # noqa
|
from .report import * # noqa
|
||||||
|
from .request import * # noqa
|
||||||
from .valuation import * # noqa
|
from .valuation import * # noqa
|
||||||
from .vehicle import * # noqa
|
from .vehicle import * # noqa
|
||||||
|
|||||||
17
core/apps/evaluation/forms/history.py
Normal file
17
core/apps/evaluation/forms/history.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
from django import forms
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import AutoevaluationhistoryModel, QuickevaluationhistoryModel
|
||||||
|
|
||||||
|
|
||||||
|
class AutoevaluationhistoryForm(forms.ModelForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = AutoevaluationhistoryModel
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
|
|
||||||
|
class QuickevaluationhistoryForm(forms.ModelForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = QuickevaluationhistoryModel
|
||||||
|
fields = "__all__"
|
||||||
10
core/apps/evaluation/forms/request.py
Normal file
10
core/apps/evaluation/forms/request.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from django import forms
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import EvaluationrequestModel
|
||||||
|
|
||||||
|
|
||||||
|
class EvaluationrequestForm(forms.ModelForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = EvaluationrequestModel
|
||||||
|
fields = "__all__"
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-03-10 08:34
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('evaluation', '0017_autoevaluationmodel_car_brand_and_more'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='EvaluationrequestModel',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateTimeField(auto_now=True)),
|
||||||
|
('rate_type', models.CharField(choices=[('auto', 'Automobil'), ('real_estate', "Ko'chmas mulk"), ('equipment', 'Uskuna')], max_length=50, verbose_name='rate type')),
|
||||||
|
('object_type', models.CharField(blank=True, choices=[('lightweight_auto', 'Yengil automobil'), ('truck_car', 'Yuk automobil'), ('special_tech', 'Maxsus texnika')], max_length=50, null=True, verbose_name='object type')),
|
||||||
|
('customer_inn_number', models.CharField(max_length=20, verbose_name='customer INN number')),
|
||||||
|
('owner_inn_number', models.CharField(max_length=20, verbose_name='owner INN number')),
|
||||||
|
('tex_passport', models.CharField(blank=True, max_length=20, null=True, verbose_name='tex passport')),
|
||||||
|
('value_determined', models.CharField(max_length=100, verbose_name='value determined')),
|
||||||
|
('rate_goal', models.CharField(max_length=100, verbose_name='rate goal')),
|
||||||
|
('property_rights', models.CharField(max_length=100, verbose_name='property rights')),
|
||||||
|
('form_ownership', models.CharField(max_length=100, verbose_name='form ownership')),
|
||||||
|
('worked_hours', models.IntegerField(blank=True, null=True, verbose_name='worked hours')),
|
||||||
|
('chassi', models.IntegerField(blank=True, null=True, verbose_name='chassi')),
|
||||||
|
('need_delivering', models.BooleanField(default=True, verbose_name='need delivering')),
|
||||||
|
('location_lat', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True, verbose_name='location latitude')),
|
||||||
|
('location_lng', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True, verbose_name='location longitude')),
|
||||||
|
('status', models.CharField(choices=[('pending', 'Kutilmoqda'), ('in_progress', 'Jarayonda'), ('completed', 'Bajarildi'), ('rejected', 'Rad etildi')], default='pending', max_length=50, verbose_name='status')),
|
||||||
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='evaluation_requests', to=settings.AUTH_USER_MODEL, verbose_name='user')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Evaluation Request',
|
||||||
|
'verbose_name_plural': 'Evaluation Requests',
|
||||||
|
'db_table': 'EvaluationRequest',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-03-17 13:34
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('evaluation', '0018_evaluationrequestmodel'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='evaluationrequestmodel',
|
||||||
|
name='location_name',
|
||||||
|
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='location name'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='evaluationrequestmodel',
|
||||||
|
name='chassi',
|
||||||
|
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='chassi'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-03-17 14:22
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('evaluation', '0019_evaluationrequestmodel_location_name_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='referenceitemmodel',
|
||||||
|
name='type',
|
||||||
|
field=models.CharField(choices=[('brand', 'Brand'), ('marka', 'Marka'), ('color', 'Color'), ('fuel_type', 'Fuel type'), ('body_type', 'Body type'), ('car_position', 'Car position'), ('state_car', 'Car state'), ('evaluation_purpose', 'Evaluation purpose')], max_length=50, verbose_name='type'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-03-17 15:14
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('evaluation', '0020_alter_referenceitemmodel_type'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='referenceitemmodel',
|
||||||
|
name='type',
|
||||||
|
field=models.CharField(choices=[('brand', 'Brand'), ('marka', 'Marka'), ('color', 'Color'), ('fuel_type', 'Fuel type'), ('body_type', 'Body type'), ('car_position', 'Car position'), ('state_car', 'Car state'), ('evaluation_purpose', 'Evaluation purpose'), ('determined_value', 'Determined value type')], max_length=50, verbose_name='type'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-03-18 08:20
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('evaluation', '0021_alter_referenceitemmodel_type'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='referenceitemmodel',
|
||||||
|
name='type',
|
||||||
|
field=models.CharField(choices=[('brand', 'Brand'), ('marka', 'Marka'), ('color', 'Color'), ('fuel_type', 'Fuel type'), ('body_type', 'Body type'), ('car_position', 'Car position'), ('state_car', 'Car state'), ('evaluation_purpose', 'Evaluation purpose'), ('determined_value', 'Determined value type'), ('property_rights', 'Property rights'), ('ownership_form', 'Ownership form')], max_length=50, verbose_name='type'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-04-02 10:03
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('evaluation', '0022_alter_referenceitemmodel_type'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='AutoevaluationhistoryModel',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('event_type', models.CharField(choices=[('order_created', 'Buyurtma yaratildi'), ('status_changed', "Status o'zgartirildi"), ('evaluator_assigned', 'Baholovchi biriktirildi'), ('document_uploaded', 'Hujjat yuklandi'), ('payment_made', "To'lov qilindi")], max_length=50, verbose_name='event type')),
|
||||||
|
('actor_id', models.BigIntegerField(blank=True, null=True, verbose_name='actor id')),
|
||||||
|
('actor_full_name', models.CharField(default='Tizim', max_length=255, verbose_name='actor full name')),
|
||||||
|
('actor_role', models.CharField(default='system', max_length=50, verbose_name='actor role')),
|
||||||
|
('meta', models.JSONField(blank=True, default=dict, verbose_name='meta')),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='created at')),
|
||||||
|
('auto_evaluation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='history', to='evaluation.autoevaluationmodel', verbose_name='auto evaluation')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Auto Evaluation History',
|
||||||
|
'verbose_name_plural': 'Auto Evaluation Histories',
|
||||||
|
'db_table': 'AutoEvaluationHistory',
|
||||||
|
'ordering': ['created_at'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='QuickevaluationhistoryModel',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('event_type', models.CharField(choices=[('order_created', 'Buyurtma yaratildi'), ('status_changed', "Status o'zgartirildi"), ('evaluator_assigned', 'Baholovchi biriktirildi'), ('document_uploaded', 'Hujjat yuklandi'), ('payment_made', "To'lov qilindi")], max_length=50, verbose_name='event type')),
|
||||||
|
('actor_id', models.BigIntegerField(blank=True, null=True, verbose_name='actor id')),
|
||||||
|
('actor_full_name', models.CharField(default='Tizim', max_length=255, verbose_name='actor full name')),
|
||||||
|
('actor_role', models.CharField(default='system', max_length=50, verbose_name='actor role')),
|
||||||
|
('meta', models.JSONField(blank=True, default=dict, verbose_name='meta')),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='created at')),
|
||||||
|
('quick_evaluation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='history', to='evaluation.quickevaluationmodel', verbose_name='quick evaluation')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Quick Evaluation History',
|
||||||
|
'verbose_name_plural': 'Quick Evaluation Histories',
|
||||||
|
'db_table': 'QuickEvaluationHistory',
|
||||||
|
'ordering': ['created_at'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
29
core/apps/evaluation/migrations/0024_add_history_indexes.py
Normal file
29
core/apps/evaluation/migrations/0024_add_history_indexes.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-04-02 11:08
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('evaluation', '0023_autoevaluationhistorymodel_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name='autoevaluationhistorymodel',
|
||||||
|
index=models.Index(fields=['auto_evaluation_id', 'created_at'], name='auto_hist_eval_date_idx'),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name='autoevaluationhistorymodel',
|
||||||
|
index=models.Index(fields=['event_type'], name='auto_hist_event_type_idx'),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name='quickevaluationhistorymodel',
|
||||||
|
index=models.Index(fields=['quick_evaluation_id', 'created_at'], name='quick_hist_eval_date_idx'),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name='quickevaluationhistorymodel',
|
||||||
|
index=models.Index(fields=['event_type'], name='quick_hist_event_type_idx'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-04-02 12:34
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('evaluation', '0024_add_history_indexes'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='evaluationrequestmodel',
|
||||||
|
name='form_ownership',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='evaluation_form_ownership_requests', to='evaluation.referenceitemmodel', verbose_name='form ownership'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='evaluationrequestmodel',
|
||||||
|
name='property_rights',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='evaluation_property_rights_requests', to='evaluation.referenceitemmodel', verbose_name='property rights'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='evaluationrequestmodel',
|
||||||
|
name='rate_goal',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='evaluation_rate_goal_requests', to='evaluation.referenceitemmodel', verbose_name='rate goal'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='evaluationrequestmodel',
|
||||||
|
name='value_determined',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='evaluation_value_determined_requests', to='evaluation.referenceitemmodel', verbose_name='value determined'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
from .auto import * # noqa
|
from .auto import * # noqa
|
||||||
from .customer import * # noqa
|
from .customer import * # noqa
|
||||||
from .document import * # noqa
|
from .document import * # noqa
|
||||||
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
from .real_estate import * # noqa
|
from .real_estate import * # noqa
|
||||||
from .reference import * # noqa
|
from .reference import * # noqa
|
||||||
from .report import * # noqa
|
from .report import * # noqa
|
||||||
|
from .request import * # noqa
|
||||||
from .valuation import * # noqa
|
from .valuation import * # noqa
|
||||||
from .vehicle import * # noqa
|
from .vehicle import * # noqa
|
||||||
|
|||||||
133
core/apps/evaluation/models/history.py
Normal file
133
core/apps/evaluation/models/history.py
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from model_bakery import baker
|
||||||
|
|
||||||
|
from core.apps.evaluation.choices.history import EvaluationEventType
|
||||||
|
|
||||||
|
|
||||||
|
class AutoevaluationhistoryModel(models.Model):
|
||||||
|
"""AutoEvaluation bo'yicha barcha harakatlar logi — faqat o'qiladi, signallar tomonidan yoziladi."""
|
||||||
|
|
||||||
|
auto_evaluation = models.ForeignKey(
|
||||||
|
"evaluation.AutoEvaluationModel",
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
related_name="history",
|
||||||
|
verbose_name=_("auto evaluation"),
|
||||||
|
)
|
||||||
|
event_type = models.CharField(
|
||||||
|
verbose_name=_("event type"),
|
||||||
|
max_length=50,
|
||||||
|
choices=EvaluationEventType.choices,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Actor — kim bajargan (system bo'lsa actor_id=None)
|
||||||
|
actor_id = models.BigIntegerField(
|
||||||
|
verbose_name=_("actor id"),
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
actor_full_name = models.CharField(
|
||||||
|
verbose_name=_("actor full name"),
|
||||||
|
max_length=255,
|
||||||
|
default="Tizim",
|
||||||
|
)
|
||||||
|
actor_role = models.CharField(
|
||||||
|
verbose_name=_("actor role"),
|
||||||
|
max_length=50,
|
||||||
|
default="system",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Har bir event_type uchun turli struktura
|
||||||
|
meta = models.JSONField(
|
||||||
|
verbose_name=_("meta"),
|
||||||
|
default=dict,
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
created_at = models.DateTimeField(
|
||||||
|
verbose_name=_("created at"),
|
||||||
|
auto_now_add=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.get_event_type_display()} — AutoEval #{self.auto_evaluation_id}"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _baker(cls):
|
||||||
|
return baker.make(cls)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = "AutoEvaluationHistory"
|
||||||
|
verbose_name = _("Auto Evaluation History")
|
||||||
|
verbose_name_plural = _("Auto Evaluation Histories")
|
||||||
|
ordering = ["created_at"]
|
||||||
|
indexes = [
|
||||||
|
# Asosiy query: bir baholash tarixi + sana bo'yicha tartib
|
||||||
|
models.Index(fields=["auto_evaluation_id", "created_at"], name="auto_hist_eval_date_idx"),
|
||||||
|
# event_type bo'yicha filter
|
||||||
|
models.Index(fields=["event_type"], name="auto_hist_event_type_idx"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class QuickevaluationhistoryModel(models.Model):
|
||||||
|
"""QuickEvaluation bo'yicha barcha harakatlar logi — faqat o'qiladi, signallar tomonidan yoziladi."""
|
||||||
|
|
||||||
|
quick_evaluation = models.ForeignKey(
|
||||||
|
"evaluation.QuickEvaluationModel",
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
related_name="history",
|
||||||
|
verbose_name=_("quick evaluation"),
|
||||||
|
)
|
||||||
|
event_type = models.CharField(
|
||||||
|
verbose_name=_("event type"),
|
||||||
|
max_length=50,
|
||||||
|
choices=EvaluationEventType.choices,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Actor — kim bajargan (system bo'lsa actor_id=None)
|
||||||
|
actor_id = models.BigIntegerField(
|
||||||
|
verbose_name=_("actor id"),
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
actor_full_name = models.CharField(
|
||||||
|
verbose_name=_("actor full name"),
|
||||||
|
max_length=255,
|
||||||
|
default="Tizim",
|
||||||
|
)
|
||||||
|
actor_role = models.CharField(
|
||||||
|
verbose_name=_("actor role"),
|
||||||
|
max_length=50,
|
||||||
|
default="system",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Har bir event_type uchun turli struktura
|
||||||
|
meta = models.JSONField(
|
||||||
|
verbose_name=_("meta"),
|
||||||
|
default=dict,
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
created_at = models.DateTimeField(
|
||||||
|
verbose_name=_("created at"),
|
||||||
|
auto_now_add=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.get_event_type_display()} — QuickEval #{self.quick_evaluation_id}"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _baker(cls):
|
||||||
|
return baker.make(cls)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = "QuickEvaluationHistory"
|
||||||
|
verbose_name = _("Quick Evaluation History")
|
||||||
|
verbose_name_plural = _("Quick Evaluation Histories")
|
||||||
|
ordering = ["created_at"]
|
||||||
|
indexes = [
|
||||||
|
# Asosiy query: bir baholash tarixi + sana bo'yicha tartib
|
||||||
|
models.Index(fields=["quick_evaluation_id", "created_at"], name="quick_hist_eval_date_idx"),
|
||||||
|
# event_type bo'yicha filter
|
||||||
|
models.Index(fields=["event_type"], name="quick_hist_event_type_idx"),
|
||||||
|
]
|
||||||
142
core/apps/evaluation/models/request.py
Normal file
142
core/apps/evaluation/models/request.py
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
from django.conf import settings
|
||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django_core.models import AbstractBaseModel
|
||||||
|
from model_bakery import baker
|
||||||
|
|
||||||
|
from core.apps.evaluation.choices.request import (
|
||||||
|
EvaluationRateType,
|
||||||
|
RequestObjectType,
|
||||||
|
RequestStatus,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class EvaluationrequestModel(AbstractBaseModel):
|
||||||
|
user = models.ForeignKey(
|
||||||
|
"accounts.User",
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
related_name="evaluation_requests",
|
||||||
|
verbose_name=_("user"),
|
||||||
|
)
|
||||||
|
rate_type = models.CharField(
|
||||||
|
verbose_name=_("rate type"),
|
||||||
|
max_length=50,
|
||||||
|
choices=EvaluationRateType.choices,
|
||||||
|
)
|
||||||
|
object_type = models.CharField(
|
||||||
|
verbose_name=_("object type"),
|
||||||
|
max_length=50,
|
||||||
|
choices=RequestObjectType.choices,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
customer_inn_number = models.CharField(
|
||||||
|
verbose_name=_("customer INN number"),
|
||||||
|
max_length=20,
|
||||||
|
)
|
||||||
|
owner_inn_number = models.CharField(
|
||||||
|
verbose_name=_("owner INN number"),
|
||||||
|
max_length=20,
|
||||||
|
)
|
||||||
|
tex_passport = models.CharField(
|
||||||
|
verbose_name=_("tex passport"),
|
||||||
|
max_length=20,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
value_determined = models.ForeignKey(
|
||||||
|
"evaluation.ReferenceitemModel",
|
||||||
|
verbose_name=_("value determined"),
|
||||||
|
related_name="evaluation_value_determined_requests",
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
rate_goal = models.ForeignKey(
|
||||||
|
"evaluation.ReferenceitemModel",
|
||||||
|
verbose_name=_("rate goal"),
|
||||||
|
related_name="evaluation_rate_goal_requests",
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
property_rights = models.ForeignKey(
|
||||||
|
"evaluation.ReferenceitemModel",
|
||||||
|
verbose_name=_("property rights"),
|
||||||
|
related_name="evaluation_property_rights_requests",
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
form_ownership = models.ForeignKey(
|
||||||
|
"evaluation.ReferenceitemModel",
|
||||||
|
verbose_name=_("form ownership"),
|
||||||
|
related_name="evaluation_form_ownership_requests",
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
worked_hours = models.IntegerField(
|
||||||
|
verbose_name=_("worked hours"),
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
chassi = models.CharField(
|
||||||
|
verbose_name=_("chassi"),
|
||||||
|
max_length=100,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
need_delivering = models.BooleanField(
|
||||||
|
verbose_name=_("need delivering"),
|
||||||
|
default=True,
|
||||||
|
)
|
||||||
|
location_name = models.CharField(
|
||||||
|
verbose_name=_("location name"),
|
||||||
|
max_length=255,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
location_lat = models.DecimalField(
|
||||||
|
verbose_name=_("location latitude"),
|
||||||
|
max_digits=9,
|
||||||
|
decimal_places=6,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
location_lng = models.DecimalField(
|
||||||
|
verbose_name=_("location longitude"),
|
||||||
|
max_digits=9,
|
||||||
|
decimal_places=6,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
status = models.CharField(
|
||||||
|
verbose_name=_("status"),
|
||||||
|
max_length=50,
|
||||||
|
choices=RequestStatus.choices,
|
||||||
|
default=RequestStatus.PENDING,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"Request #{self.pk} — {self.get_rate_type_display()}"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _baker(cls):
|
||||||
|
user = baker.make(settings.AUTH_USER_MODEL)
|
||||||
|
return baker.make(
|
||||||
|
cls,
|
||||||
|
user=user,
|
||||||
|
rate_type=EvaluationRateType.AUTO,
|
||||||
|
customer_inn_number="123456789",
|
||||||
|
owner_inn_number="987654321",
|
||||||
|
value_determined="Bozor qiymati",
|
||||||
|
rate_goal="Kredit uchun",
|
||||||
|
property_rights="Xususiy",
|
||||||
|
form_ownership="Xususiy",
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = "EvaluationRequest"
|
||||||
|
verbose_name = _("Evaluation Request")
|
||||||
|
verbose_name_plural = _("Evaluation Requests")
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
from .auto import * # noqa
|
from .auto import * # noqa
|
||||||
from .customer import * # noqa
|
from .customer import * # noqa
|
||||||
from .document import * # noqa
|
from .document import * # noqa
|
||||||
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
from .real_estate import * # noqa
|
from .real_estate import * # noqa
|
||||||
from .reference import * # noqa
|
from .reference import * # noqa
|
||||||
from .report import * # noqa
|
from .report import * # noqa
|
||||||
|
from .request import * # noqa
|
||||||
from .valuation import * # noqa
|
from .valuation import * # noqa
|
||||||
from .vehicle import * # noqa
|
from .vehicle import * # noqa
|
||||||
|
|||||||
23
core/apps/evaluation/permissions/history.py
Normal file
23
core/apps/evaluation/permissions/history.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from rest_framework import permissions
|
||||||
|
|
||||||
|
|
||||||
|
class AutoevaluationhistoryPermission(permissions.BasePermission):
|
||||||
|
|
||||||
|
def __init__(self) -> None: ...
|
||||||
|
|
||||||
|
def __call__(self, *args, **kwargs):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def has_permission(self, request, view):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class QuickevaluationhistoryPermission(permissions.BasePermission):
|
||||||
|
|
||||||
|
def __init__(self) -> None: ...
|
||||||
|
|
||||||
|
def __call__(self, *args, **kwargs):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def has_permission(self, request, view):
|
||||||
|
return True
|
||||||
12
core/apps/evaluation/permissions/request.py
Normal file
12
core/apps/evaluation/permissions/request.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from rest_framework import permissions
|
||||||
|
|
||||||
|
|
||||||
|
class EvaluationrequestPermission(permissions.BasePermission):
|
||||||
|
|
||||||
|
def __init__(self) -> None: ...
|
||||||
|
|
||||||
|
def __call__(self, *args, **kwargs):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def has_permission(self, request, view):
|
||||||
|
return True
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
from .auto import * # noqa
|
from .auto import * # noqa
|
||||||
from .customer import * # noqa
|
from .customer import * # noqa
|
||||||
from .document import * # noqa
|
from .document import * # noqa
|
||||||
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
from .real_estate import * # noqa
|
from .real_estate import * # noqa
|
||||||
from .reference import * # noqa
|
from .reference import * # noqa
|
||||||
from .report import * # noqa
|
from .report import * # noqa
|
||||||
|
from .request import * # noqa
|
||||||
from .valuation import * # noqa
|
from .valuation import * # noqa
|
||||||
from .vehicle import * # noqa
|
from .vehicle import * # noqa
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import AutoevaluationhistoryModel
|
||||||
|
|
||||||
|
|
||||||
|
class BaseAutoevaluationhistorySerializer(serializers.ModelSerializer):
|
||||||
|
event_type_display = serializers.CharField(source="get_event_type_display", read_only=True)
|
||||||
|
actor = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
def get_actor(self, obj):
|
||||||
|
return {
|
||||||
|
"id": obj.actor_id,
|
||||||
|
"full_name": obj.actor_full_name,
|
||||||
|
"role": obj.actor_role,
|
||||||
|
}
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = AutoevaluationhistoryModel
|
||||||
|
fields = [
|
||||||
|
"id",
|
||||||
|
"event_type",
|
||||||
|
"event_type_display",
|
||||||
|
"actor",
|
||||||
|
"meta",
|
||||||
|
"created_at",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class ListAutoevaluationhistorySerializer(BaseAutoevaluationhistorySerializer):
|
||||||
|
class Meta(BaseAutoevaluationhistorySerializer.Meta): ...
|
||||||
|
|
||||||
|
|
||||||
|
class RetrieveAutoevaluationhistorySerializer(BaseAutoevaluationhistorySerializer):
|
||||||
|
class Meta(BaseAutoevaluationhistorySerializer.Meta):
|
||||||
|
fields = BaseAutoevaluationhistorySerializer.Meta.fields + ["auto_evaluation"]
|
||||||
|
|
||||||
|
|
||||||
|
class CreateAutoevaluationhistorySerializer(BaseAutoevaluationhistorySerializer):
|
||||||
|
class Meta(BaseAutoevaluationhistorySerializer.Meta): ...
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import QuickevaluationhistoryModel
|
||||||
|
|
||||||
|
|
||||||
|
class BaseQuickevaluationhistorySerializer(serializers.ModelSerializer):
|
||||||
|
event_type_display = serializers.CharField(source="get_event_type_display", read_only=True)
|
||||||
|
actor = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
def get_actor(self, obj):
|
||||||
|
return {
|
||||||
|
"id": obj.actor_id,
|
||||||
|
"full_name": obj.actor_full_name,
|
||||||
|
"role": obj.actor_role,
|
||||||
|
}
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = QuickevaluationhistoryModel
|
||||||
|
fields = [
|
||||||
|
"id",
|
||||||
|
"event_type",
|
||||||
|
"event_type_display",
|
||||||
|
"actor",
|
||||||
|
"meta",
|
||||||
|
"created_at",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class ListQuickevaluationhistorySerializer(BaseQuickevaluationhistorySerializer):
|
||||||
|
class Meta(BaseQuickevaluationhistorySerializer.Meta): ...
|
||||||
|
|
||||||
|
|
||||||
|
class RetrieveQuickevaluationhistorySerializer(BaseQuickevaluationhistorySerializer):
|
||||||
|
class Meta(BaseQuickevaluationhistorySerializer.Meta):
|
||||||
|
fields = BaseQuickevaluationhistorySerializer.Meta.fields + ["quick_evaluation"]
|
||||||
|
|
||||||
|
|
||||||
|
class CreateQuickevaluationhistorySerializer(BaseQuickevaluationhistorySerializer):
|
||||||
|
class Meta(BaseQuickevaluationhistorySerializer.Meta): ...
|
||||||
2
core/apps/evaluation/serializers/history/__init__.py
Normal file
2
core/apps/evaluation/serializers/history/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from .AutoEvaluationHistory import * # noqa
|
||||||
|
from .QuickEvaluationHistory import * # noqa
|
||||||
@@ -46,3 +46,30 @@ class CreateReferenceitemSerializer(BaseReferenceitemSerializer):
|
|||||||
"order",
|
"order",
|
||||||
"is_active",
|
"is_active",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class EvaluationPurposeSerializer(serializers.ModelSerializer):
|
||||||
|
label = serializers.CharField(source="name")
|
||||||
|
value = serializers.IntegerField(source="id")
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = ReferenceitemModel
|
||||||
|
fields = ["label", "value"]
|
||||||
|
|
||||||
|
|
||||||
|
class DeterminedValueSerializer(serializers.ModelSerializer):
|
||||||
|
label = serializers.CharField(source="name")
|
||||||
|
value = serializers.IntegerField(source="id")
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = ReferenceitemModel
|
||||||
|
fields = ["label", "value"]
|
||||||
|
|
||||||
|
|
||||||
|
class LabelValueSerializer(serializers.ModelSerializer):
|
||||||
|
label = serializers.CharField(source="name")
|
||||||
|
value = serializers.IntegerField(source="id")
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = ReferenceitemModel
|
||||||
|
fields = ["label", "value"]
|
||||||
|
|||||||
192
core/apps/evaluation/serializers/request/EvaluationRequest.py
Normal file
192
core/apps/evaluation/serializers/request/EvaluationRequest.py
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import EvaluationrequestModel, ReferenceitemModel
|
||||||
|
from core.apps.evaluation.serializers.reference import ListReferenceitemSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class BaseEvaluationrequestSerializer(serializers.ModelSerializer):
|
||||||
|
rate_type_display = serializers.CharField(
|
||||||
|
source="get_rate_type_display", read_only=True
|
||||||
|
)
|
||||||
|
object_type_display = serializers.CharField(
|
||||||
|
source="get_object_type_display", read_only=True, default=None
|
||||||
|
)
|
||||||
|
status_display = serializers.CharField(
|
||||||
|
source="get_status_display", read_only=True
|
||||||
|
)
|
||||||
|
location = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
location_name = serializers.CharField(required=False)
|
||||||
|
value_determined = ListReferenceitemSerializer(read_only=True)
|
||||||
|
rate_goal = ListReferenceitemSerializer(read_only=True)
|
||||||
|
property_rights = ListReferenceitemSerializer(read_only=True)
|
||||||
|
form_ownership = ListReferenceitemSerializer(read_only=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = EvaluationrequestModel
|
||||||
|
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",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
]
|
||||||
|
|
||||||
|
def get_location(self, obj):
|
||||||
|
if obj.location_lat is not None and obj.location_lng is not None:
|
||||||
|
return {
|
||||||
|
"lat": float(obj.location_lat),
|
||||||
|
"lng": float(obj.location_lng),
|
||||||
|
"name": obj.location_name
|
||||||
|
}
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class ListEvaluationrequestSerializer(BaseEvaluationrequestSerializer):
|
||||||
|
class Meta(BaseEvaluationrequestSerializer.Meta):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RetrieveEvaluationrequestSerializer(BaseEvaluationrequestSerializer):
|
||||||
|
class Meta(BaseEvaluationrequestSerializer.Meta):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class CreateEvaluationrequestSerializer(serializers.ModelSerializer):
|
||||||
|
location = serializers.DictField(required=False, allow_empty=True)
|
||||||
|
|
||||||
|
# locationName — string qabul qiladi, location ichida yoki tashqarida yuborsa bo'ladi
|
||||||
|
locationName = serializers.CharField(
|
||||||
|
write_only=True,
|
||||||
|
required=False,
|
||||||
|
allow_null=True,
|
||||||
|
allow_blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Faqat truck_car uchun majburiy — field darajasida optional qilib belgilaymiz,
|
||||||
|
# validate() da object_type ga qarab tekshiramiz
|
||||||
|
worked_hours = serializers.IntegerField(
|
||||||
|
required=False,
|
||||||
|
allow_null=True,
|
||||||
|
)
|
||||||
|
chassi = serializers.CharField(
|
||||||
|
required=False,
|
||||||
|
allow_null=True,
|
||||||
|
allow_blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
value_determined = serializers.IntegerField(required=False, allow_null=True)
|
||||||
|
rate_goal = serializers.IntegerField(required=False, allow_null=True)
|
||||||
|
property_rights = serializers.IntegerField(required=False, allow_null=True)
|
||||||
|
form_ownership = serializers.IntegerField(required=False, allow_null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = EvaluationrequestModel
|
||||||
|
fields = [
|
||||||
|
"value_determined",
|
||||||
|
"rate_goal",
|
||||||
|
"property_rights",
|
||||||
|
"form_ownership",
|
||||||
|
"rate_type",
|
||||||
|
"object_type",
|
||||||
|
"customer_inn_number",
|
||||||
|
"owner_inn_number",
|
||||||
|
"tex_passport",
|
||||||
|
"worked_hours",
|
||||||
|
"chassi",
|
||||||
|
"need_delivering",
|
||||||
|
"location",
|
||||||
|
"locationName",
|
||||||
|
]
|
||||||
|
|
||||||
|
def validate_tex_passport(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):
|
||||||
|
rate_type = attrs.get("rate_type")
|
||||||
|
object_type = attrs.get("object_type")
|
||||||
|
|
||||||
|
if rate_type == "auto" and not object_type:
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
{"object_type": "rate_type 'auto' bo'lganda object_type majburiy."}
|
||||||
|
)
|
||||||
|
|
||||||
|
if rate_type == "auto" and not attrs.get("tex_passport"):
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
{"tex_passport": "rate_type 'auto' bo'lganda tex_passport majburiy."}
|
||||||
|
)
|
||||||
|
|
||||||
|
# worked_hours va chassi FAQAT yuk avtomobil (truck_car) uchun majburiy
|
||||||
|
if object_type == "truck_car":
|
||||||
|
if attrs.get("worked_hours") is None:
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
{"worked_hours": "Yuk avtomobil uchun ishlagan soati majburiy."}
|
||||||
|
)
|
||||||
|
if not attrs.get("chassi"):
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
{"chassi": "Yuk avtomobil uchun shassi raqami majburiy."}
|
||||||
|
)
|
||||||
|
|
||||||
|
if attrs.get("value_determined"):
|
||||||
|
if attrs.get("value_determined") not in ReferenceitemModel.objects.values_list("id", flat=True):
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
{"value_determined": "Noto'g'ri qiymat aniqlandi."}
|
||||||
|
)
|
||||||
|
|
||||||
|
if attrs.get("rate_goal"):
|
||||||
|
if attrs.get("rate_goal") not in ReferenceitemModel.objects.values_list("id", flat=True):
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
{"rate_goal": "Noto'g'ri qiymat aniqlandi."}
|
||||||
|
)
|
||||||
|
|
||||||
|
if attrs.get("property_rights"):
|
||||||
|
if attrs.get("property_rights") not in ReferenceitemModel.objects.values_list("id", flat=True):
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
{"property_rights": "Noto'g'ri qiymat aniqlandi."}
|
||||||
|
)
|
||||||
|
|
||||||
|
if attrs.get("form_ownership"):
|
||||||
|
if attrs.get("form_ownership") not in ReferenceitemModel.objects.values_list("id", flat=True):
|
||||||
|
raise serializers.ValidationError(
|
||||||
|
{"form_ownership": "Noto'g'ri qiymat aniqlandi."}
|
||||||
|
)
|
||||||
|
|
||||||
|
return attrs
|
||||||
|
|
||||||
|
def create(self, validated_data):
|
||||||
|
location = validated_data.pop("location", None)
|
||||||
|
location_name = validated_data.pop("locationName", None)
|
||||||
|
|
||||||
|
if location:
|
||||||
|
validated_data["location_lat"] = location.get("lat")
|
||||||
|
validated_data["location_lng"] = location.get("lng")
|
||||||
|
if not location_name:
|
||||||
|
location_name = location.get("name") or location.get("locationName")
|
||||||
|
|
||||||
|
if location_name:
|
||||||
|
validated_data["location_name"] = str(location_name)
|
||||||
|
|
||||||
|
validated_data["user"] = self.context["request"].user
|
||||||
|
return super().create(validated_data)
|
||||||
1
core/apps/evaluation/serializers/request/__init__.py
Normal file
1
core/apps/evaluation/serializers/request/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .EvaluationRequest import * # noqa
|
||||||
1
core/apps/evaluation/services/__init__.py
Normal file
1
core/apps/evaluation/services/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .history import EvaluationHistoryService # noqa
|
||||||
51
core/apps/evaluation/services/history.py
Normal file
51
core/apps/evaluation/services/history.py
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
from core.apps.evaluation.choices.history import EvaluationEventType
|
||||||
|
|
||||||
|
|
||||||
|
class EvaluationHistoryService:
|
||||||
|
"""
|
||||||
|
AutoEvaluation va QuickEvaluation uchun history yozuvlarini yaratuvchi servis.
|
||||||
|
Faqat shu servis orqali yoziladi — frontend va boshqa kodlar bu sinfdan foydalanadi.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _build_actor(user) -> dict:
|
||||||
|
if user is None:
|
||||||
|
return {"id": None, "full_name": "Tizim", "role": "system"}
|
||||||
|
full_name = ""
|
||||||
|
if hasattr(user, "get_full_name"):
|
||||||
|
full_name = user.get_full_name().strip()
|
||||||
|
if not full_name and hasattr(user, "phone"):
|
||||||
|
full_name = str(user.phone)
|
||||||
|
return {
|
||||||
|
"id": user.id,
|
||||||
|
"full_name": full_name or str(user),
|
||||||
|
"role": getattr(user, "role", "user"),
|
||||||
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def log_auto(cls, auto_evaluation, event_type: EvaluationEventType, actor=None, meta: dict = None):
|
||||||
|
from core.apps.evaluation.models import AutoevaluationhistoryModel
|
||||||
|
|
||||||
|
actor_data = cls._build_actor(actor)
|
||||||
|
AutoevaluationhistoryModel.objects.create(
|
||||||
|
auto_evaluation=auto_evaluation,
|
||||||
|
event_type=event_type,
|
||||||
|
actor_id=actor_data["id"],
|
||||||
|
actor_full_name=actor_data["full_name"],
|
||||||
|
actor_role=actor_data["role"],
|
||||||
|
meta=meta or {},
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def log_quick(cls, quick_evaluation, event_type: EvaluationEventType, actor=None, meta: dict = None):
|
||||||
|
from core.apps.evaluation.models import QuickevaluationhistoryModel
|
||||||
|
|
||||||
|
actor_data = cls._build_actor(actor)
|
||||||
|
QuickevaluationhistoryModel.objects.create(
|
||||||
|
quick_evaluation=quick_evaluation,
|
||||||
|
event_type=event_type,
|
||||||
|
actor_id=actor_data["id"],
|
||||||
|
actor_full_name=actor_data["full_name"],
|
||||||
|
actor_role=actor_data["role"],
|
||||||
|
meta=meta or {},
|
||||||
|
)
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
from .auto import * # noqa
|
from .auto import * # noqa
|
||||||
from .customer import * # noqa
|
from .customer import * # noqa
|
||||||
from .document import * # noqa
|
from .document import * # noqa
|
||||||
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
from .real_estate import * # noqa
|
from .real_estate import * # noqa
|
||||||
from .reference import * # noqa
|
from .reference import * # noqa
|
||||||
from .report import * # noqa
|
from .report import * # noqa
|
||||||
|
from .request import * # noqa
|
||||||
from .valuation import * # noqa
|
from .valuation import * # noqa
|
||||||
from .vehicle import * # noqa
|
from .vehicle import * # noqa
|
||||||
|
|||||||
210
core/apps/evaluation/signals/history.py
Normal file
210
core/apps/evaluation/signals/history.py
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
from django.db.models.signals import post_save, pre_save
|
||||||
|
from django.dispatch import receiver
|
||||||
|
|
||||||
|
from core.apps.evaluation.choices.auto import AutoEvaluationStatus
|
||||||
|
from core.apps.evaluation.choices.history import EvaluationEventType
|
||||||
|
from core.apps.evaluation.choices.quick import QuickEvaluationStatus
|
||||||
|
from core.apps.evaluation.models import (
|
||||||
|
AutoEvaluationModel,
|
||||||
|
QuickEvaluationModel,
|
||||||
|
ValuationDocumentModel,
|
||||||
|
ValuationModel,
|
||||||
|
)
|
||||||
|
from core.apps.evaluation.services.history import EvaluationHistoryService
|
||||||
|
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
# AutoEvaluation — order_created va status_changed
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
@receiver(pre_save, sender=AutoEvaluationModel)
|
||||||
|
def auto_eval_pre_save(sender, instance, **kwargs):
|
||||||
|
"""Status o'zgarishini kuzatish uchun eski qiymatni saqlaydi."""
|
||||||
|
if instance.pk:
|
||||||
|
try:
|
||||||
|
old = AutoEvaluationModel.objects.get(pk=instance.pk)
|
||||||
|
instance._old_status = old.status
|
||||||
|
except AutoEvaluationModel.DoesNotExist:
|
||||||
|
instance._old_status = None
|
||||||
|
else:
|
||||||
|
instance._old_status = None
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_save, sender=AutoEvaluationModel)
|
||||||
|
def auto_eval_post_save(sender, instance, created, **kwargs):
|
||||||
|
if created:
|
||||||
|
actor = None
|
||||||
|
if instance.valuation_id:
|
||||||
|
try:
|
||||||
|
actor = instance.valuation.created_by
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
EvaluationHistoryService.log_auto(
|
||||||
|
auto_evaluation=instance,
|
||||||
|
event_type=EvaluationEventType.ORDER_CREATED,
|
||||||
|
actor=actor,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
old_status = getattr(instance, "_old_status", None)
|
||||||
|
if old_status is not None and old_status != instance.status:
|
||||||
|
status_labels = dict(AutoEvaluationStatus.choices)
|
||||||
|
EvaluationHistoryService.log_auto(
|
||||||
|
auto_evaluation=instance,
|
||||||
|
event_type=EvaluationEventType.STATUS_CHANGED,
|
||||||
|
meta={
|
||||||
|
"from_status": old_status,
|
||||||
|
"from_status_display": status_labels.get(old_status, old_status),
|
||||||
|
"to_status": instance.status,
|
||||||
|
"to_status_display": status_labels.get(instance.status, instance.status),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
# Valuation — evaluator_assigned (assigned_to o'zgarganda)
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
@receiver(pre_save, sender=ValuationModel)
|
||||||
|
def valuation_pre_save(sender, instance, **kwargs):
|
||||||
|
"""assigned_to o'zgarishini kuzatish uchun eski qiymatni saqlaydi."""
|
||||||
|
if instance.pk:
|
||||||
|
try:
|
||||||
|
old = ValuationModel.objects.get(pk=instance.pk)
|
||||||
|
instance._old_assigned_to_id = old.assigned_to_id
|
||||||
|
except ValuationModel.DoesNotExist:
|
||||||
|
instance._old_assigned_to_id = None
|
||||||
|
else:
|
||||||
|
instance._old_assigned_to_id = None
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_save, sender=ValuationModel)
|
||||||
|
def valuation_post_save(sender, instance, created, **kwargs):
|
||||||
|
if created:
|
||||||
|
return
|
||||||
|
old_assigned_id = getattr(instance, "_old_assigned_to_id", None)
|
||||||
|
if instance.assigned_to_id and old_assigned_id != instance.assigned_to_id:
|
||||||
|
try:
|
||||||
|
auto_eval = instance.auto_detail
|
||||||
|
except AutoEvaluationModel.DoesNotExist:
|
||||||
|
return
|
||||||
|
evaluator = instance.assigned_to
|
||||||
|
evaluator_name = ""
|
||||||
|
if evaluator:
|
||||||
|
evaluator_name = evaluator.get_full_name().strip() or str(evaluator.phone)
|
||||||
|
EvaluationHistoryService.log_auto(
|
||||||
|
auto_evaluation=auto_eval,
|
||||||
|
event_type=EvaluationEventType.EVALUATOR_ASSIGNED,
|
||||||
|
meta={
|
||||||
|
"evaluator_id": instance.assigned_to_id,
|
||||||
|
"evaluator_name": evaluator_name,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
# ValuationDocument — document_uploaded
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
@receiver(post_save, sender=ValuationDocumentModel)
|
||||||
|
def document_post_save(sender, instance, created, **kwargs):
|
||||||
|
if not created:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
auto_eval = instance.valuation.auto_detail
|
||||||
|
except (AttributeError, AutoEvaluationModel.DoesNotExist):
|
||||||
|
return
|
||||||
|
file_name = ""
|
||||||
|
if instance.file:
|
||||||
|
file_name = instance.file.name.split("/")[-1]
|
||||||
|
EvaluationHistoryService.log_auto(
|
||||||
|
auto_evaluation=auto_eval,
|
||||||
|
event_type=EvaluationEventType.DOCUMENT_UPLOADED,
|
||||||
|
actor=instance.uploaded_by,
|
||||||
|
meta={
|
||||||
|
"document_type": instance.document_type,
|
||||||
|
"document_type_display": instance.get_document_type_display(),
|
||||||
|
"file_name": file_name,
|
||||||
|
"title": instance.title or "",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
# Payment — payment_made (status COMPLETED bo'lganda)
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
@receiver(pre_save, sender="payment.PaymentModel")
|
||||||
|
def payment_pre_save(sender, instance, **kwargs):
|
||||||
|
if instance.pk:
|
||||||
|
try:
|
||||||
|
old = sender.objects.get(pk=instance.pk)
|
||||||
|
instance._old_payment_status = old.status
|
||||||
|
except sender.DoesNotExist:
|
||||||
|
instance._old_payment_status = None
|
||||||
|
else:
|
||||||
|
instance._old_payment_status = None
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_save, sender="payment.PaymentModel")
|
||||||
|
def payment_post_save(sender, instance, created, **kwargs):
|
||||||
|
old_status = getattr(instance, "_old_payment_status", None)
|
||||||
|
is_newly_completed = (
|
||||||
|
instance.status == "completed"
|
||||||
|
and (created or old_status != "completed")
|
||||||
|
)
|
||||||
|
if not is_newly_completed:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
auto_eval = instance.valuation.auto_detail
|
||||||
|
except (AttributeError, AutoEvaluationModel.DoesNotExist):
|
||||||
|
return
|
||||||
|
EvaluationHistoryService.log_auto(
|
||||||
|
auto_evaluation=auto_eval,
|
||||||
|
event_type=EvaluationEventType.PAYMENT_MADE,
|
||||||
|
actor=instance.payer,
|
||||||
|
meta={
|
||||||
|
"amount": str(instance.amount),
|
||||||
|
"payment_method": instance.payment_method,
|
||||||
|
"transaction_id": instance.transaction_id or "",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
# QuickEvaluation — order_created va status_changed
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
@receiver(pre_save, sender=QuickEvaluationModel)
|
||||||
|
def quick_eval_pre_save(sender, instance, **kwargs):
|
||||||
|
if instance.pk:
|
||||||
|
try:
|
||||||
|
old = QuickEvaluationModel.objects.get(pk=instance.pk)
|
||||||
|
instance._old_status = old.status
|
||||||
|
except QuickEvaluationModel.DoesNotExist:
|
||||||
|
instance._old_status = None
|
||||||
|
else:
|
||||||
|
instance._old_status = None
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_save, sender=QuickEvaluationModel)
|
||||||
|
def quick_eval_post_save(sender, instance, created, **kwargs):
|
||||||
|
if created:
|
||||||
|
EvaluationHistoryService.log_quick(
|
||||||
|
quick_evaluation=instance,
|
||||||
|
event_type=EvaluationEventType.ORDER_CREATED,
|
||||||
|
actor=instance.created_by,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
old_status = getattr(instance, "_old_status", None)
|
||||||
|
if old_status is not None and old_status != instance.status:
|
||||||
|
status_labels = dict(QuickEvaluationStatus.choices)
|
||||||
|
EvaluationHistoryService.log_quick(
|
||||||
|
quick_evaluation=instance,
|
||||||
|
event_type=EvaluationEventType.STATUS_CHANGED,
|
||||||
|
meta={
|
||||||
|
"from_status": old_status,
|
||||||
|
"from_status_display": status_labels.get(old_status, old_status),
|
||||||
|
"to_status": instance.status,
|
||||||
|
"to_status_display": status_labels.get(instance.status, instance.status),
|
||||||
|
},
|
||||||
|
)
|
||||||
27
core/apps/evaluation/signals/request.py
Normal file
27
core/apps/evaluation/signals/request.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
from django.db.models.signals import pre_save
|
||||||
|
from django.dispatch import receiver
|
||||||
|
|
||||||
|
from core.apps.evaluation.choices.request import RequestStatus
|
||||||
|
from core.apps.evaluation.models import EvaluationrequestModel
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(pre_save, sender=EvaluationrequestModel)
|
||||||
|
def create_evaluation_on_approve(sender, instance, **kwargs):
|
||||||
|
if not instance.pk:
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
old = EvaluationrequestModel.objects.get(pk=instance.pk)
|
||||||
|
except EvaluationrequestModel.DoesNotExist:
|
||||||
|
return
|
||||||
|
|
||||||
|
if old.status != RequestStatus.COMPLETED and instance.status == RequestStatus.COMPLETED:
|
||||||
|
from core.apps.evaluation.models import AutoEvaluationModel
|
||||||
|
|
||||||
|
if instance.rate_type == "auto" and not hasattr(instance, "_evaluation_created"):
|
||||||
|
AutoEvaluationModel.objects.create(
|
||||||
|
object_type=instance.object_type or "",
|
||||||
|
tex_passport_serie_num=instance.tex_passport or "",
|
||||||
|
rating_goal=instance.rate_goal or "",
|
||||||
|
)
|
||||||
|
instance._evaluation_created = True
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
from .auto import * # noqa
|
from .auto import * # noqa
|
||||||
from .customer import * # noqa
|
from .customer import * # noqa
|
||||||
from .document import * # noqa
|
from .document import * # noqa
|
||||||
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
from .real_estate import * # noqa
|
from .real_estate import * # noqa
|
||||||
from .reference import * # noqa
|
from .reference import * # noqa
|
||||||
from .report import * # noqa
|
from .report import * # noqa
|
||||||
|
from .request import * # noqa
|
||||||
from .valuation import * # noqa
|
from .valuation import * # noqa
|
||||||
from .vehicle import * # noqa
|
from .vehicle import * # noqa
|
||||||
|
|||||||
2
core/apps/evaluation/tests/history/__init__.py
Normal file
2
core/apps/evaluation/tests/history/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from .test_AutoEvaluationHistory import * # noqa
|
||||||
|
from .test_QuickEvaluationHistory import * # noqa
|
||||||
101
core/apps/evaluation/tests/history/test_AutoEvaluationHistory.py
Normal file
101
core/apps/evaluation/tests/history/test_AutoEvaluationHistory.py
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import pytest
|
||||||
|
from django.urls import reverse
|
||||||
|
from rest_framework.test import APIClient
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import AutoevaluationhistoryModel
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def instance(db):
|
||||||
|
return AutoevaluationhistoryModel._baker()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def api_client(instance):
|
||||||
|
client = APIClient()
|
||||||
|
##client.force_authenticate(user=instance.user)
|
||||||
|
return client, instance
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def data(api_client):
|
||||||
|
client, instance = api_client
|
||||||
|
return (
|
||||||
|
{
|
||||||
|
"list": reverse("auto-evaluation-history-list"),
|
||||||
|
"retrieve": reverse("auto-evaluation-history-detail", kwargs={"pk": instance.pk}),
|
||||||
|
"retrieve-not-found": reverse("auto-evaluation-history-detail", kwargs={"pk": 1000}),
|
||||||
|
},
|
||||||
|
client,
|
||||||
|
instance,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_list(data):
|
||||||
|
urls, client, _ = data
|
||||||
|
response = client.get(urls["list"])
|
||||||
|
data_resp = response.json()
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert data_resp["status"] is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_retrieve(data):
|
||||||
|
urls, client, _ = data
|
||||||
|
response = client.get(urls["retrieve"])
|
||||||
|
data_resp = response.json()
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert data_resp["status"] is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_retrieve_not_found(data):
|
||||||
|
urls, client, _ = data
|
||||||
|
response = client.get(urls["retrieve-not-found"])
|
||||||
|
data_resp = response.json()
|
||||||
|
assert response.status_code == 404
|
||||||
|
assert data_resp["status"] is False
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_create(data):
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.post(urls["list"], data={"name": "test"})
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 201
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_update(data):
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.patch(urls["retrieve"], data={"name": "updated"})
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
#
|
||||||
|
# # verify updated value
|
||||||
|
# response = client.get(urls["retrieve"])
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
# assert response.json()["data"]["name"] == "updated"
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_partial_update():
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.patch(urls["retrieve"], data={"name": "updated"})
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
#
|
||||||
|
# # verify updated value
|
||||||
|
# response = client.get(urls["retrieve"])
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
# assert response.json()["data"]["name"] == "updated"
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_destroy(data):
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.delete(urls["retrieve"])
|
||||||
|
# assert response.status_code == 204
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
import pytest
|
||||||
|
from django.urls import reverse
|
||||||
|
from rest_framework.test import APIClient
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import QuickevaluationhistoryModel
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def instance(db):
|
||||||
|
return QuickevaluationhistoryModel._baker()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def api_client(instance):
|
||||||
|
client = APIClient()
|
||||||
|
##client.force_authenticate(user=instance.user)
|
||||||
|
return client, instance
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def data(api_client):
|
||||||
|
client, instance = api_client
|
||||||
|
return (
|
||||||
|
{
|
||||||
|
"list": reverse("quick-evaluation-history-list"),
|
||||||
|
"retrieve": reverse("quick-evaluation-history-detail", kwargs={"pk": instance.pk}),
|
||||||
|
"retrieve-not-found": reverse("quick-evaluation-history-detail", kwargs={"pk": 1000}),
|
||||||
|
},
|
||||||
|
client,
|
||||||
|
instance,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_list(data):
|
||||||
|
urls, client, _ = data
|
||||||
|
response = client.get(urls["list"])
|
||||||
|
data_resp = response.json()
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert data_resp["status"] is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_retrieve(data):
|
||||||
|
urls, client, _ = data
|
||||||
|
response = client.get(urls["retrieve"])
|
||||||
|
data_resp = response.json()
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert data_resp["status"] is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_retrieve_not_found(data):
|
||||||
|
urls, client, _ = data
|
||||||
|
response = client.get(urls["retrieve-not-found"])
|
||||||
|
data_resp = response.json()
|
||||||
|
assert response.status_code == 404
|
||||||
|
assert data_resp["status"] is False
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_create(data):
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.post(urls["list"], data={"name": "test"})
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 201
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_update(data):
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.patch(urls["retrieve"], data={"name": "updated"})
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
#
|
||||||
|
# # verify updated value
|
||||||
|
# response = client.get(urls["retrieve"])
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
# assert response.json()["data"]["name"] == "updated"
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_partial_update():
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.patch(urls["retrieve"], data={"name": "updated"})
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
#
|
||||||
|
# # verify updated value
|
||||||
|
# response = client.get(urls["retrieve"])
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
# assert response.json()["data"]["name"] == "updated"
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_destroy(data):
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.delete(urls["retrieve"])
|
||||||
|
# assert response.status_code == 204
|
||||||
1
core/apps/evaluation/tests/request/__init__.py
Normal file
1
core/apps/evaluation/tests/request/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .test_EvaluationRequest import * # noqa
|
||||||
101
core/apps/evaluation/tests/request/test_EvaluationRequest.py
Normal file
101
core/apps/evaluation/tests/request/test_EvaluationRequest.py
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import pytest
|
||||||
|
from django.urls import reverse
|
||||||
|
from rest_framework.test import APIClient
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import EvaluationrequestModel
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def instance(db):
|
||||||
|
return EvaluationrequestModel._baker()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def api_client(instance):
|
||||||
|
client = APIClient()
|
||||||
|
client.force_authenticate(user=instance.user)
|
||||||
|
return client, instance
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def data(api_client):
|
||||||
|
client, instance = api_client
|
||||||
|
return (
|
||||||
|
{
|
||||||
|
"list": reverse("evaluation-request-list"),
|
||||||
|
"retrieve": reverse("evaluation-request-detail", kwargs={"pk": instance.pk}),
|
||||||
|
"retrieve-not-found": reverse("evaluation-request-detail", kwargs={"pk": 1000}),
|
||||||
|
},
|
||||||
|
client,
|
||||||
|
instance,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_list(data):
|
||||||
|
urls, client, _ = data
|
||||||
|
response = client.get(urls["list"])
|
||||||
|
data_resp = response.json()
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert data_resp["status"] is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_retrieve(data):
|
||||||
|
urls, client, _ = data
|
||||||
|
response = client.get(urls["retrieve"])
|
||||||
|
data_resp = response.json()
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert data_resp["status"] is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_retrieve_not_found(data):
|
||||||
|
urls, client, _ = data
|
||||||
|
response = client.get(urls["retrieve-not-found"])
|
||||||
|
data_resp = response.json()
|
||||||
|
assert response.status_code == 404
|
||||||
|
assert data_resp["status"] is False
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_create(data):
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.post(urls["list"], data={"name": "test"})
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 201
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_update(data):
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.patch(urls["retrieve"], data={"name": "updated"})
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
#
|
||||||
|
# # verify updated value
|
||||||
|
# response = client.get(urls["retrieve"])
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
# assert response.json()["data"]["name"] == "updated"
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_partial_update():
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.patch(urls["retrieve"], data={"name": "updated"})
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
#
|
||||||
|
# # verify updated value
|
||||||
|
# response = client.get(urls["retrieve"])
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
# assert response.json()["data"]["name"] == "updated"
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_destroy(data):
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.delete(urls["retrieve"])
|
||||||
|
# assert response.status_code == 204
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
from .auto import * # noqa
|
from .auto import * # noqa
|
||||||
from .customer import * # noqa
|
from .customer import * # noqa
|
||||||
from .document import * # noqa
|
from .document import * # noqa
|
||||||
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
from .real_estate import * # noqa
|
from .real_estate import * # noqa
|
||||||
from .reference import * # noqa
|
from .reference import * # noqa
|
||||||
from .report import * # noqa
|
from .report import * # noqa
|
||||||
|
from .request import * # noqa
|
||||||
from .valuation import * # noqa
|
from .valuation import * # noqa
|
||||||
from .vehicle import * # noqa
|
from .vehicle import * # noqa
|
||||||
|
|||||||
13
core/apps/evaluation/translation/history.py
Normal file
13
core/apps/evaluation/translation/history.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from modeltranslation.translator import TranslationOptions, register
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import AutoevaluationhistoryModel, QuickevaluationhistoryModel
|
||||||
|
|
||||||
|
|
||||||
|
@register(AutoevaluationhistoryModel)
|
||||||
|
class AutoevaluationhistoryTranslation(TranslationOptions):
|
||||||
|
fields = []
|
||||||
|
|
||||||
|
|
||||||
|
@register(QuickevaluationhistoryModel)
|
||||||
|
class QuickevaluationhistoryTranslation(TranslationOptions):
|
||||||
|
fields = []
|
||||||
8
core/apps/evaluation/translation/request.py
Normal file
8
core/apps/evaluation/translation/request.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from modeltranslation.translator import TranslationOptions, register
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import EvaluationrequestModel
|
||||||
|
|
||||||
|
|
||||||
|
@register(EvaluationrequestModel)
|
||||||
|
class EvaluationrequestTranslation(TranslationOptions):
|
||||||
|
fields = []
|
||||||
@@ -2,11 +2,18 @@ from django.urls import include, path
|
|||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
from .views import (
|
from .views import (
|
||||||
|
AutoEvaluationHistoryView,
|
||||||
AutoEvaluationView,
|
AutoEvaluationView,
|
||||||
CustomerView,
|
CustomerView,
|
||||||
|
DeterminedValueView,
|
||||||
|
EvaluationPurposeView,
|
||||||
EvaluationReportView,
|
EvaluationReportView,
|
||||||
|
EvaluationrequestView,
|
||||||
MovablePropertyEvaluationView,
|
MovablePropertyEvaluationView,
|
||||||
|
OwnershipFormView,
|
||||||
PropertyOwnerView,
|
PropertyOwnerView,
|
||||||
|
PropertyRightsView,
|
||||||
|
QuickEvaluationHistoryView,
|
||||||
QuickEvaluationView,
|
QuickEvaluationView,
|
||||||
RealEstateEvaluationView,
|
RealEstateEvaluationView,
|
||||||
ReferenceitemView,
|
ReferenceitemView,
|
||||||
@@ -16,6 +23,13 @@ from .views import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
router = DefaultRouter()
|
router = DefaultRouter()
|
||||||
|
router.register("auto-evaluation-history", AutoEvaluationHistoryView, basename="auto-evaluation-history")
|
||||||
|
router.register("quick-evaluation-history", QuickEvaluationHistoryView, basename="quick-evaluation-history")
|
||||||
|
router.register("determined-value", DeterminedValueView, basename="determined-value")
|
||||||
|
router.register("evaluation-purpose", EvaluationPurposeView, basename="evaluation-purpose")
|
||||||
|
router.register("property-rights", PropertyRightsView, basename="property-rights")
|
||||||
|
router.register("ownership-form", OwnershipFormView, basename="ownership-form")
|
||||||
|
router.register("evaluation-request", EvaluationrequestView, basename="evaluation-request")
|
||||||
router.register("reference-item", ReferenceitemView, basename="reference-item")
|
router.register("reference-item", ReferenceitemView, basename="reference-item")
|
||||||
router.register("valuation-document", ValuationDocumentView, basename="valuation-document")
|
router.register("valuation-document", ValuationDocumentView, basename="valuation-document")
|
||||||
router.register("evaluation-report", EvaluationReportView, basename="evaluation-report")
|
router.register("evaluation-report", EvaluationReportView, basename="evaluation-report")
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
from .auto import * # noqa
|
from .auto import * # noqa
|
||||||
from .customer import * # noqa
|
from .customer import * # noqa
|
||||||
from .document import * # noqa
|
from .document import * # noqa
|
||||||
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
from .real_estate import * # noqa
|
from .real_estate import * # noqa
|
||||||
from .reference import * # noqa
|
from .reference import * # noqa
|
||||||
from .report import * # noqa
|
from .report import * # noqa
|
||||||
|
from .request import * # noqa
|
||||||
from .valuation import * # noqa
|
from .valuation import * # noqa
|
||||||
from .vehicle import * # noqa
|
from .vehicle import * # noqa
|
||||||
|
|||||||
15
core/apps/evaluation/validators/history.py
Normal file
15
core/apps/evaluation/validators/history.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class AutoevaluationhistoryValidator:
|
||||||
|
def __init__(self): ...
|
||||||
|
|
||||||
|
def __call__(self):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class QuickevaluationhistoryValidator:
|
||||||
|
def __init__(self): ...
|
||||||
|
|
||||||
|
def __call__(self):
|
||||||
|
return True
|
||||||
8
core/apps/evaluation/validators/request.py
Normal file
8
core/apps/evaluation/validators/request.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class EvaluationrequestValidator:
|
||||||
|
def __init__(self): ...
|
||||||
|
|
||||||
|
def __call__(self):
|
||||||
|
return True
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
from .auto import * # noqa
|
from .auto import * # noqa
|
||||||
from .customer import * # noqa
|
from .customer import * # noqa
|
||||||
from .document import * # noqa
|
from .document import * # noqa
|
||||||
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
from .real_estate import * # noqa
|
from .real_estate import * # noqa
|
||||||
from .reference import * # noqa
|
from .reference import * # noqa
|
||||||
from .report import * # noqa
|
from .report import * # noqa
|
||||||
|
from .request import * # noqa
|
||||||
from .valuation import * # noqa
|
from .valuation import * # noqa
|
||||||
from .vehicle import * # noqa
|
from .vehicle import * # noqa
|
||||||
|
|||||||
109
core/apps/evaluation/views/history.py
Normal file
109
core/apps/evaluation/views/history.py
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
from django_core.mixins import BaseViewSetMixin
|
||||||
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
|
from drf_spectacular.utils import OpenApiParameter, extend_schema
|
||||||
|
from rest_framework.filters import OrderingFilter
|
||||||
|
from rest_framework.permissions import AllowAny
|
||||||
|
from rest_framework.response import Response
|
||||||
|
from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||||
|
|
||||||
|
from core.apps.evaluation.filters.history import (
|
||||||
|
AutoevaluationhistoryFilter,
|
||||||
|
QuickevaluationhistoryFilter,
|
||||||
|
)
|
||||||
|
from core.apps.evaluation.models import AutoevaluationhistoryModel, QuickevaluationhistoryModel
|
||||||
|
from core.apps.evaluation.serializers.history import (
|
||||||
|
CreateAutoevaluationhistorySerializer,
|
||||||
|
CreateQuickevaluationhistorySerializer,
|
||||||
|
ListAutoevaluationhistorySerializer,
|
||||||
|
ListQuickevaluationhistorySerializer,
|
||||||
|
RetrieveAutoevaluationhistorySerializer,
|
||||||
|
RetrieveQuickevaluationhistorySerializer,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema(
|
||||||
|
tags=["AutoEvaluationHistory"],
|
||||||
|
parameters=[
|
||||||
|
OpenApiParameter("auto_evaluation", int, description="AutoEvaluation ID bo'yicha filter"),
|
||||||
|
OpenApiParameter("event_type", str, description="Event turi bo'yicha filter"),
|
||||||
|
OpenApiParameter("created_from", str, description="Boshlanish sanasi (ISO 8601)"),
|
||||||
|
OpenApiParameter("created_to", str, description="Tugash sanasi (ISO 8601)"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
class AutoEvaluationHistoryView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||||
|
# select_related("auto_evaluation") faqat retrieve uchun — list uchun kerak emas
|
||||||
|
queryset = AutoevaluationhistoryModel.objects.only(
|
||||||
|
"id", "auto_evaluation_id", "event_type",
|
||||||
|
"actor_id", "actor_full_name", "actor_role",
|
||||||
|
"meta", "created_at",
|
||||||
|
)
|
||||||
|
serializer_class = ListAutoevaluationhistorySerializer
|
||||||
|
permission_classes = [AllowAny]
|
||||||
|
pagination_class = None
|
||||||
|
|
||||||
|
filter_backends = [DjangoFilterBackend, OrderingFilter]
|
||||||
|
filterset_class = AutoevaluationhistoryFilter
|
||||||
|
ordering_fields = ["created_at"]
|
||||||
|
ordering = ["created_at"]
|
||||||
|
|
||||||
|
action_permission_classes = {}
|
||||||
|
action_serializer_class = {
|
||||||
|
"list": ListAutoevaluationhistorySerializer,
|
||||||
|
"retrieve": RetrieveAutoevaluationhistorySerializer,
|
||||||
|
"create": CreateAutoevaluationhistorySerializer,
|
||||||
|
}
|
||||||
|
|
||||||
|
def list(self, request, *args, **kwargs):
|
||||||
|
queryset = self.filter_queryset(self.get_queryset())
|
||||||
|
# Queryset bir marta evaluate qilinadi — COUNT uchun alohida query yo'q
|
||||||
|
results = list(queryset)
|
||||||
|
serializer = self.get_serializer(results, many=True)
|
||||||
|
return Response({
|
||||||
|
"count": len(results),
|
||||||
|
"next": None,
|
||||||
|
"previous": None,
|
||||||
|
"results": serializer.data,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema(
|
||||||
|
tags=["QuickEvaluationHistory"],
|
||||||
|
parameters=[
|
||||||
|
OpenApiParameter("quick_evaluation", int, description="QuickEvaluation ID bo'yicha filter"),
|
||||||
|
OpenApiParameter("event_type", str, description="Event turi bo'yicha filter"),
|
||||||
|
OpenApiParameter("created_from", str, description="Boshlanish sanasi (ISO 8601)"),
|
||||||
|
OpenApiParameter("created_to", str, description="Tugash sanasi (ISO 8601)"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
class QuickEvaluationHistoryView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||||
|
queryset = QuickevaluationhistoryModel.objects.only(
|
||||||
|
"id", "quick_evaluation_id", "event_type",
|
||||||
|
"actor_id", "actor_full_name", "actor_role",
|
||||||
|
"meta", "created_at",
|
||||||
|
)
|
||||||
|
serializer_class = ListQuickevaluationhistorySerializer
|
||||||
|
permission_classes = [AllowAny]
|
||||||
|
pagination_class = None
|
||||||
|
|
||||||
|
filter_backends = [DjangoFilterBackend, OrderingFilter]
|
||||||
|
filterset_class = QuickevaluationhistoryFilter
|
||||||
|
ordering_fields = ["created_at"]
|
||||||
|
ordering = ["created_at"]
|
||||||
|
|
||||||
|
action_permission_classes = {}
|
||||||
|
action_serializer_class = {
|
||||||
|
"list": ListQuickevaluationhistorySerializer,
|
||||||
|
"retrieve": RetrieveQuickevaluationhistorySerializer,
|
||||||
|
"create": CreateQuickevaluationhistorySerializer,
|
||||||
|
}
|
||||||
|
|
||||||
|
def list(self, request, *args, **kwargs):
|
||||||
|
queryset = self.filter_queryset(self.get_queryset())
|
||||||
|
results = list(queryset)
|
||||||
|
serializer = self.get_serializer(results, many=True)
|
||||||
|
return Response({
|
||||||
|
"count": len(results),
|
||||||
|
"next": None,
|
||||||
|
"previous": None,
|
||||||
|
"results": serializer.data,
|
||||||
|
})
|
||||||
@@ -11,9 +11,72 @@ from core.apps.evaluation.serializers.reference import (
|
|||||||
CreateReferenceitemSerializer,
|
CreateReferenceitemSerializer,
|
||||||
ListReferenceitemSerializer,
|
ListReferenceitemSerializer,
|
||||||
RetrieveReferenceitemSerializer,
|
RetrieveReferenceitemSerializer,
|
||||||
|
EvaluationPurposeSerializer,
|
||||||
|
DeterminedValueSerializer,
|
||||||
|
LabelValueSerializer,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema(tags=["EvaluationPurpose"])
|
||||||
|
class EvaluationPurposeView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||||
|
queryset = ReferenceitemModel.objects.filter(
|
||||||
|
type="evaluation_purpose", is_active=True
|
||||||
|
).order_by("order", "name")
|
||||||
|
serializer_class = EvaluationPurposeSerializer
|
||||||
|
permission_classes = [AllowAny]
|
||||||
|
pagination_class = None
|
||||||
|
|
||||||
|
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||||
|
search_fields = ["name"]
|
||||||
|
ordering_fields = ["name", "order"]
|
||||||
|
ordering = ["order", "name"]
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema(tags=["DeterminedValue"])
|
||||||
|
class DeterminedValueView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||||
|
queryset = ReferenceitemModel.objects.filter(
|
||||||
|
type="determined_value", is_active=True
|
||||||
|
).order_by("order", "name")
|
||||||
|
serializer_class = DeterminedValueSerializer
|
||||||
|
permission_classes = [AllowAny]
|
||||||
|
pagination_class = None
|
||||||
|
|
||||||
|
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||||
|
search_fields = ["name"]
|
||||||
|
ordering_fields = ["name", "order"]
|
||||||
|
ordering = ["order", "name"]
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema(tags=["PropertyRights"])
|
||||||
|
class PropertyRightsView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||||
|
queryset = ReferenceitemModel.objects.filter(
|
||||||
|
type="property_rights", is_active=True
|
||||||
|
).order_by("order", "name")
|
||||||
|
serializer_class = LabelValueSerializer
|
||||||
|
permission_classes = [AllowAny]
|
||||||
|
pagination_class = None
|
||||||
|
|
||||||
|
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||||
|
search_fields = ["name"]
|
||||||
|
ordering_fields = ["name", "order"]
|
||||||
|
ordering = ["order", "name"]
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema(tags=["OwnershipForm"])
|
||||||
|
class OwnershipFormView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||||
|
queryset = ReferenceitemModel.objects.filter(
|
||||||
|
type="ownership_form", is_active=True
|
||||||
|
).order_by("order", "name")
|
||||||
|
serializer_class = LabelValueSerializer
|
||||||
|
permission_classes = [AllowAny]
|
||||||
|
pagination_class = None
|
||||||
|
|
||||||
|
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||||
|
search_fields = ["name"]
|
||||||
|
ordering_fields = ["name", "order"]
|
||||||
|
ordering = ["order", "name"]
|
||||||
|
|
||||||
|
|
||||||
@extend_schema(tags=["ReferenceItem"])
|
@extend_schema(tags=["ReferenceItem"])
|
||||||
class ReferenceitemView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
class ReferenceitemView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||||
queryset = ReferenceitemModel.objects.select_related("parent").filter(is_active=True)
|
queryset = ReferenceitemModel.objects.select_related("parent").filter(is_active=True)
|
||||||
|
|||||||
56
core/apps/evaluation/views/request.py
Normal file
56
core/apps/evaluation/views/request.py
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
from django_core.mixins import BaseViewSetMixin
|
||||||
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
|
from drf_spectacular.utils import extend_schema
|
||||||
|
from rest_framework.filters import OrderingFilter, SearchFilter
|
||||||
|
from rest_framework.pagination import PageNumberPagination
|
||||||
|
from rest_framework.permissions import AllowAny, IsAuthenticated
|
||||||
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
|
from core.apps.evaluation.filters.request import EvaluationrequestFilter
|
||||||
|
from core.apps.evaluation.models import EvaluationrequestModel
|
||||||
|
from core.apps.evaluation.serializers.request import (
|
||||||
|
CreateEvaluationrequestSerializer,
|
||||||
|
ListEvaluationrequestSerializer,
|
||||||
|
RetrieveEvaluationrequestSerializer,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# class RequestPagination(PageNumberPagination):
|
||||||
|
# page_size = 20
|
||||||
|
# page_size_query_param = "limit"
|
||||||
|
# max_page_size = 100
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema(tags=["EvaluationRequest"])
|
||||||
|
class EvaluationrequestView(BaseViewSetMixin, ModelViewSet):
|
||||||
|
serializer_class = ListEvaluationrequestSerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
# pagination_class = RequestPagination
|
||||||
|
|
||||||
|
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||||
|
filterset_class = EvaluationrequestFilter
|
||||||
|
search_fields = [
|
||||||
|
"customer_inn_number",
|
||||||
|
"owner_inn_number",
|
||||||
|
"tex_passport",
|
||||||
|
]
|
||||||
|
ordering_fields = [
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"rate_type",
|
||||||
|
"object_type",
|
||||||
|
"status",
|
||||||
|
]
|
||||||
|
ordering = ["-created_at"]
|
||||||
|
|
||||||
|
action_permission_classes = {}
|
||||||
|
action_serializer_class = {
|
||||||
|
"list": ListEvaluationrequestSerializer,
|
||||||
|
"retrieve": RetrieveEvaluationrequestSerializer,
|
||||||
|
"create": CreateEvaluationrequestSerializer,
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return EvaluationrequestModel.objects.filter(
|
||||||
|
user=self.request.user
|
||||||
|
).order_by("-created_at")
|
||||||
@@ -84,7 +84,7 @@ services:
|
|||||||
max-file: "5"
|
max-file: "5"
|
||||||
|
|
||||||
web:
|
web:
|
||||||
image: husanjon/sifatbaho:45
|
image: husanjon/sifatbaho:54
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
Reference in New Issue
Block a user