feat: add new document and documentcategory model for auto evaluation detail
This commit is contained in:
@@ -150,4 +150,20 @@ PAGES = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"title": _("Auto baholash"),
|
||||||
|
"separator": True,
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"title": _("Hujjatlar"),
|
||||||
|
"icon": "attach_file",
|
||||||
|
"link": reverse_lazy("admin:evaluation_documentmodel_changelist"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": _("Kategoriyalar"),
|
||||||
|
"icon": "category",
|
||||||
|
"link": reverse_lazy("admin:evaluation_documentcategorymodel_changelist"),
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-04-03 10:58
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('chat', '0002_chatroom_and_message_media'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='chatmessagemodel',
|
||||||
|
options={'ordering': ['created_at'], 'verbose_name': 'Chat Xabar', 'verbose_name_plural': 'Chat Xabarlar'},
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='chatroommodel',
|
||||||
|
name='type',
|
||||||
|
field=models.CharField(choices=[('auto_evaluation', 'AutoEvaluation xonasi'), ('direct', "To'g'ridan-to'g'ri")], db_index=True, default='auto_evaluation', max_length=20, verbose_name='type'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
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 .documentcategory import * # noqa
|
||||||
from .history import * # noqa
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from unfold.admin import ModelAdmin
|
from unfold.admin import ModelAdmin
|
||||||
|
|
||||||
from core.apps.evaluation.models import ValuationDocumentModel
|
from core.apps.evaluation.models import DocumentModel, ValuationDocumentModel
|
||||||
|
|
||||||
|
|
||||||
@admin.register(ValuationDocumentModel)
|
@admin.register(ValuationDocumentModel)
|
||||||
@@ -23,7 +23,9 @@ class ValuationDocumentAdmin(ModelAdmin):
|
|||||||
readonly_fields = ("created_at", "updated_at")
|
readonly_fields = ("created_at", "updated_at")
|
||||||
autocomplete_fields = ("valuation", "uploaded_by")
|
autocomplete_fields = ("valuation", "uploaded_by")
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
("Hujjat", {
|
(
|
||||||
|
"Hujjat",
|
||||||
|
{
|
||||||
"fields": (
|
"fields": (
|
||||||
"valuation",
|
"valuation",
|
||||||
"document_type",
|
"document_type",
|
||||||
@@ -31,12 +33,27 @@ class ValuationDocumentAdmin(ModelAdmin):
|
|||||||
"file",
|
"file",
|
||||||
"uploaded_by",
|
"uploaded_by",
|
||||||
),
|
),
|
||||||
}),
|
},
|
||||||
("Qo'shimcha", {
|
),
|
||||||
|
(
|
||||||
|
"Qo'shimcha",
|
||||||
|
{
|
||||||
"fields": ("description",),
|
"fields": ("description",),
|
||||||
}),
|
},
|
||||||
("Tizim", {
|
),
|
||||||
|
(
|
||||||
|
"Tizim",
|
||||||
|
{
|
||||||
"classes": ("collapse",),
|
"classes": ("collapse",),
|
||||||
"fields": ("created_at", "updated_at"),
|
"fields": ("created_at", "updated_at"),
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(DocumentModel)
|
||||||
|
class DocumentAdmin(ModelAdmin):
|
||||||
|
list_display = (
|
||||||
|
"id",
|
||||||
|
"__str__",
|
||||||
)
|
)
|
||||||
|
|||||||
57
core/apps/evaluation/admin/documentcategory.py
Normal file
57
core/apps/evaluation/admin/documentcategory.py
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from unfold.admin import ModelAdmin
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import DocumentcategoryModel
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(DocumentcategoryModel)
|
||||||
|
class DocumentcategoryAdmin(ModelAdmin):
|
||||||
|
list_display = (
|
||||||
|
"id",
|
||||||
|
"label",
|
||||||
|
"value",
|
||||||
|
"created_at",
|
||||||
|
"updated_at"
|
||||||
|
)
|
||||||
|
search_fields = (
|
||||||
|
"label",
|
||||||
|
"value",
|
||||||
|
)
|
||||||
|
list_filter = (
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
)
|
||||||
|
readonly_fields = (
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
)
|
||||||
|
fieldsets = (
|
||||||
|
(
|
||||||
|
("Uzbekcha"),
|
||||||
|
{
|
||||||
|
"fields": (
|
||||||
|
"label_uz",
|
||||||
|
"value_uz",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
),
|
||||||
|
(
|
||||||
|
("Ruscha"),
|
||||||
|
{
|
||||||
|
"fields": (
|
||||||
|
"label_ru",
|
||||||
|
"value_ru",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
),
|
||||||
|
(
|
||||||
|
("Inglizcha"),
|
||||||
|
{
|
||||||
|
"fields": (
|
||||||
|
"label_en",
|
||||||
|
"value_en",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
list_display_links =list_display
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
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 .documentcategory import * # noqa
|
||||||
from .history import * # noqa
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
from django_filters import rest_framework as filters
|
from django_filters import rest_framework as filters
|
||||||
|
|
||||||
from core.apps.evaluation.models import ValuationDocumentModel
|
from core.apps.evaluation.models import DocumentModel, ValuationDocumentModel
|
||||||
|
|
||||||
|
|
||||||
class ValuationdocumentFilter(filters.FilterSet):
|
class ValuationdocumentFilter(filters.FilterSet):
|
||||||
# name = filters.CharFilter(field_name="name", lookup_expr="icontains")
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ValuationDocumentModel
|
model = ValuationDocumentModel
|
||||||
fields = []
|
fields = []
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentFilter(filters.FilterSet):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = DocumentModel
|
||||||
|
fields = [
|
||||||
|
]
|
||||||
|
|||||||
10
core/apps/evaluation/filters/documentcategory.py
Normal file
10
core/apps/evaluation/filters/documentcategory.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from django_filters import rest_framework as filters
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import DocumentcategoryModel
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentcategoryFilter(filters.FilterSet):
|
||||||
|
class Meta:
|
||||||
|
model = DocumentcategoryModel
|
||||||
|
fields = [
|
||||||
|
]
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
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 .documentcategory import * # noqa
|
||||||
from .history import * # noqa
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
from core.apps.evaluation.models import ValuationDocumentModel
|
from core.apps.evaluation.models import DocumentModel, ValuationDocumentModel
|
||||||
|
|
||||||
|
|
||||||
class ValuationdocumentForm(forms.ModelForm):
|
class ValuationdocumentForm(forms.ModelForm):
|
||||||
@@ -8,3 +8,10 @@ class ValuationdocumentForm(forms.ModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = ValuationDocumentModel
|
model = ValuationDocumentModel
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentForm(forms.ModelForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = DocumentModel
|
||||||
|
fields = "__all__"
|
||||||
|
|||||||
10
core/apps/evaluation/forms/documentcategory.py
Normal file
10
core/apps/evaluation/forms/documentcategory.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from django import forms
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import DocumentcategoryModel
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentcategoryForm(forms.ModelForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = DocumentcategoryModel
|
||||||
|
fields = "__all__"
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-04-03 10:58
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('evaluation', '0026_alter_autoevaluationmodel_form_ownership_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DocumentcategoryModel',
|
||||||
|
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)),
|
||||||
|
('label', models.CharField(max_length=255, verbose_name='label')),
|
||||||
|
('label_uz', models.CharField(max_length=255, null=True, verbose_name='label')),
|
||||||
|
('label_ru', models.CharField(max_length=255, null=True, verbose_name='label')),
|
||||||
|
('label_en', models.CharField(max_length=255, null=True, verbose_name='label')),
|
||||||
|
('value', models.CharField(max_length=255, verbose_name='value')),
|
||||||
|
('value_uz', models.CharField(max_length=255, null=True, verbose_name='value')),
|
||||||
|
('value_ru', models.CharField(max_length=255, null=True, verbose_name='value')),
|
||||||
|
('value_en', models.CharField(max_length=255, null=True, verbose_name='value')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'DocumentcategoryModel',
|
||||||
|
'verbose_name_plural': 'DocumentcategoryModels',
|
||||||
|
'db_table': 'DocumentCategory',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DocumentModel',
|
||||||
|
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)),
|
||||||
|
('title', models.CharField(max_length=255, verbose_name='title')),
|
||||||
|
('document', models.FileField(upload_to='evaluation/documents/%Y/%m/', verbose_name='document')),
|
||||||
|
('auto_evaluation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='evaluation.autoevaluationmodel', verbose_name='auto evaluation')),
|
||||||
|
('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='evaluation.documentcategorymodel', verbose_name='category')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'DocumentModel',
|
||||||
|
'verbose_name_plural': 'DocumentModels',
|
||||||
|
'db_table': 'Document',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
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 .documentcategory import * # noqa
|
||||||
from .history import * # noqa
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from django_core.models import AbstractBaseModel
|
from django_core.models import AbstractBaseModel
|
||||||
from model_bakery import baker
|
from model_bakery import baker
|
||||||
|
|
||||||
from .valuation import ValuationModel
|
|
||||||
from core.apps.evaluation.choices.document import DocumentType
|
from core.apps.evaluation.choices.document import DocumentType
|
||||||
|
|
||||||
|
from .valuation import ValuationModel
|
||||||
|
|
||||||
|
|
||||||
class ValuationDocumentModel(AbstractBaseModel):
|
class ValuationDocumentModel(AbstractBaseModel):
|
||||||
valuation = models.ForeignKey(
|
valuation = models.ForeignKey(
|
||||||
@@ -54,3 +55,35 @@ class ValuationDocumentModel(AbstractBaseModel):
|
|||||||
verbose_name = _("Valuation Document")
|
verbose_name = _("Valuation Document")
|
||||||
verbose_name_plural = _("Valuation Documents")
|
verbose_name_plural = _("Valuation Documents")
|
||||||
ordering = ["-created_at"]
|
ordering = ["-created_at"]
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentModel(AbstractBaseModel):
|
||||||
|
auto_evaluation = models.ForeignKey(
|
||||||
|
"evaluation.AutoEvaluationModel",
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
related_name="documents",
|
||||||
|
verbose_name=_("auto evaluation"),
|
||||||
|
)
|
||||||
|
title = models.CharField(verbose_name=_("title"), max_length=255)
|
||||||
|
document = models.FileField(
|
||||||
|
verbose_name=_("document"),
|
||||||
|
upload_to="evaluation/documents/%Y/%m/",
|
||||||
|
)
|
||||||
|
category = models.ForeignKey(
|
||||||
|
"evaluation.DocumentCategoryModel",
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
related_name="documents",
|
||||||
|
verbose_name=_("category"),
|
||||||
|
)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return str(self.pk)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _baker(cls):
|
||||||
|
return baker.make(cls)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = "Document"
|
||||||
|
verbose_name = _("DocumentModel")
|
||||||
|
verbose_name_plural = _("DocumentModels")
|
||||||
|
|||||||
21
core/apps/evaluation/models/documentcategory.py
Normal file
21
core/apps/evaluation/models/documentcategory.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django_core.models import AbstractBaseModel
|
||||||
|
from model_bakery import baker
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentcategoryModel(AbstractBaseModel):
|
||||||
|
label = models.CharField(verbose_name=_("label"), max_length=255)
|
||||||
|
value = models.CharField(verbose_name=_("value"), max_length=255)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return str(self.pk)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _baker(cls):
|
||||||
|
return baker.make(cls)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = "DocumentCategory"
|
||||||
|
verbose_name = _("DocumentcategoryModel")
|
||||||
|
verbose_name_plural = _("DocumentcategoryModels")
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
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 .documentcategory import * # noqa
|
||||||
from .history import * # noqa
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
|
|||||||
@@ -10,3 +10,14 @@ class ValuationdocumentPermission(permissions.BasePermission):
|
|||||||
|
|
||||||
def has_permission(self, request, view):
|
def has_permission(self, request, view):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentPermission(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/documentcategory.py
Normal file
12
core/apps/evaluation/permissions/documentcategory.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from rest_framework import permissions
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentcategoryPermission(permissions.BasePermission):
|
||||||
|
|
||||||
|
def __init__(self) -> None: ...
|
||||||
|
|
||||||
|
def __call__(self, *args, **kwargs):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def has_permission(self, request, view):
|
||||||
|
return True
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
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 .documentcategory import * # noqa
|
||||||
from .history import * # noqa
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
|
|||||||
42
core/apps/evaluation/serializers/document/Document.py
Normal file
42
core/apps/evaluation/serializers/document/Document.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import DocumentModel, AutoEvaluationModel, DocumentcategoryModel
|
||||||
|
from core.apps.evaluation.serializers.documentcategory import ListDocumentcategorySerializer
|
||||||
|
|
||||||
|
class BaseDocumentSerializer(serializers.ModelSerializer):
|
||||||
|
category = ListDocumentcategorySerializer(read_only=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = DocumentModel
|
||||||
|
fields = [
|
||||||
|
"id",
|
||||||
|
"title",
|
||||||
|
"document",
|
||||||
|
"category",
|
||||||
|
"created_at",
|
||||||
|
"updated_at"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class ListDocumentSerializer(BaseDocumentSerializer):
|
||||||
|
class Meta(BaseDocumentSerializer.Meta): ...
|
||||||
|
|
||||||
|
|
||||||
|
class RetrieveDocumentSerializer(BaseDocumentSerializer):
|
||||||
|
class Meta(BaseDocumentSerializer.Meta): ...
|
||||||
|
|
||||||
|
|
||||||
|
class CreateDocumentSerializer(BaseDocumentSerializer):
|
||||||
|
auto_evaluation = serializers.PrimaryKeyRelatedField(queryset=AutoEvaluationModel.objects.all())
|
||||||
|
category = serializers.PrimaryKeyRelatedField(queryset=DocumentcategoryModel.objects.all())
|
||||||
|
|
||||||
|
class Meta(BaseDocumentSerializer.Meta):
|
||||||
|
fields = [
|
||||||
|
"id",
|
||||||
|
"title",
|
||||||
|
"auto_evaluation",
|
||||||
|
"document",
|
||||||
|
"category",
|
||||||
|
"created_at",
|
||||||
|
"updated_at"
|
||||||
|
]
|
||||||
@@ -1 +1,2 @@
|
|||||||
|
from .Document import * # noqa
|
||||||
from .ValuationDocument import * # noqa
|
from .ValuationDocument import * # noqa
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import DocumentcategoryModel
|
||||||
|
|
||||||
|
|
||||||
|
class BaseDocumentcategorySerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = DocumentcategoryModel
|
||||||
|
fields = [
|
||||||
|
"id",
|
||||||
|
"label",
|
||||||
|
"value",
|
||||||
|
"created_at",
|
||||||
|
"updated_at"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class ListDocumentcategorySerializer(BaseDocumentcategorySerializer):
|
||||||
|
class Meta(BaseDocumentcategorySerializer.Meta): ...
|
||||||
|
|
||||||
|
|
||||||
|
class RetrieveDocumentcategorySerializer(BaseDocumentcategorySerializer):
|
||||||
|
class Meta(BaseDocumentcategorySerializer.Meta): ...
|
||||||
|
|
||||||
|
|
||||||
|
# class CreateDocumentcategorySerializer(BaseDocumentcategorySerializer):
|
||||||
|
# class Meta(BaseDocumentcategorySerializer.Meta):
|
||||||
|
# fields = [
|
||||||
|
# "id",
|
||||||
|
# "label",
|
||||||
|
# "value",
|
||||||
|
# "created_at",
|
||||||
|
# "updated_at"
|
||||||
|
# ]
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
from .DocumentCategory import * # noqa
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
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 .documentcategory import * # noqa
|
||||||
from .history import * # noqa
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
|
||||||
from core.apps.evaluation.models import ValuationDocumentModel
|
from core.apps.evaluation.models import DocumentModel, ValuationDocumentModel
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=ValuationDocumentModel)
|
@receiver(post_save, sender=ValuationDocumentModel)
|
||||||
def ValuationdocumentSignal(sender, instance, created, **kwargs): ...
|
def ValuationdocumentSignal(sender, instance, created, **kwargs): ...
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_save, sender=DocumentModel)
|
||||||
|
def DocumentSignal(sender, instance, created, **kwargs): ...
|
||||||
|
|||||||
8
core/apps/evaluation/signals/documentcategory.py
Normal file
8
core/apps/evaluation/signals/documentcategory.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from django.db.models.signals import post_save
|
||||||
|
from django.dispatch import receiver
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import DocumentcategoryModel
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_save, sender=DocumentcategoryModel)
|
||||||
|
def DocumentcategorySignal(sender, instance, created, **kwargs): ...
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
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 .documentcategory import * # noqa
|
||||||
from .history import * # noqa
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
|
from .test_Document import * # noqa
|
||||||
from .test_ValuationDocument import * # noqa
|
from .test_ValuationDocument import * # noqa
|
||||||
|
|||||||
101
core/apps/evaluation/tests/document/test_Document.py
Normal file
101
core/apps/evaluation/tests/document/test_Document.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 DocumentModel
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def instance(db):
|
||||||
|
return DocumentModel._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("Document-list"),
|
||||||
|
"retrieve": reverse("Document-detail", kwargs={"pk": instance.pk}),
|
||||||
|
"retrieve-not-found": reverse("Document-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/documentcategory/__init__.py
Normal file
1
core/apps/evaluation/tests/documentcategory/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .test_DocumentCategory import * # noqa
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
import pytest
|
||||||
|
from django.urls import reverse
|
||||||
|
from rest_framework.test import APIClient
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import DocumentcategoryModel
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def instance(db):
|
||||||
|
return DocumentcategoryModel._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("DocumentCategory-list"),
|
||||||
|
"retrieve": reverse("DocumentCategory-detail", kwargs={"pk": instance.pk}),
|
||||||
|
"retrieve-not-found": reverse("DocumentCategory-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,6 +1,7 @@
|
|||||||
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 .documentcategory import * # noqa
|
||||||
from .history import * # noqa
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
from modeltranslation.translator import TranslationOptions, register
|
from modeltranslation.translator import TranslationOptions, register
|
||||||
|
|
||||||
from core.apps.evaluation.models import ValuationDocumentModel
|
from core.apps.evaluation.models import DocumentModel, ValuationDocumentModel
|
||||||
|
|
||||||
|
|
||||||
@register(ValuationDocumentModel)
|
@register(ValuationDocumentModel)
|
||||||
class ValuationdocumentTranslation(TranslationOptions):
|
class ValuationdocumentTranslation(TranslationOptions):
|
||||||
fields = []
|
fields = []
|
||||||
|
|
||||||
|
|
||||||
|
@register(DocumentModel)
|
||||||
|
class DocumentTranslation(TranslationOptions):
|
||||||
|
fields = []
|
||||||
|
|||||||
8
core/apps/evaluation/translation/documentcategory.py
Normal file
8
core/apps/evaluation/translation/documentcategory.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from modeltranslation.translator import TranslationOptions, register
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import DocumentcategoryModel
|
||||||
|
|
||||||
|
|
||||||
|
@register(DocumentcategoryModel)
|
||||||
|
class DocumentcategoryTranslation(TranslationOptions):
|
||||||
|
fields = ["label", "value"]
|
||||||
@@ -2,10 +2,13 @@ from django.urls import include, path
|
|||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
from .views import (
|
from .views import (
|
||||||
|
AdminEvaluationrequestView,
|
||||||
AutoEvaluationHistoryView,
|
AutoEvaluationHistoryView,
|
||||||
AutoEvaluationView,
|
AutoEvaluationView,
|
||||||
CustomerView,
|
CustomerView,
|
||||||
DeterminedValueView,
|
DeterminedValueView,
|
||||||
|
DocumentCategoryView,
|
||||||
|
DocumentView,
|
||||||
EvaluationPurposeView,
|
EvaluationPurposeView,
|
||||||
EvaluationReportView,
|
EvaluationReportView,
|
||||||
EvaluationrequestView,
|
EvaluationrequestView,
|
||||||
@@ -20,10 +23,11 @@ from .views import (
|
|||||||
ValuationDocumentView,
|
ValuationDocumentView,
|
||||||
ValuationView,
|
ValuationView,
|
||||||
VehicleView,
|
VehicleView,
|
||||||
AdminEvaluationrequestView,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
router = DefaultRouter()
|
router = DefaultRouter()
|
||||||
|
router.register("document-category", DocumentCategoryView, basename="DocumentCategory")
|
||||||
|
router.register("document", DocumentView, basename="Document")
|
||||||
router.register("auto-evaluation-history", AutoEvaluationHistoryView, basename="auto-evaluation-history")
|
router.register("auto-evaluation-history", AutoEvaluationHistoryView, basename="auto-evaluation-history")
|
||||||
router.register("quick-evaluation-history", QuickEvaluationHistoryView, basename="quick-evaluation-history")
|
router.register("quick-evaluation-history", QuickEvaluationHistoryView, basename="quick-evaluation-history")
|
||||||
router.register("determined-value", DeterminedValueView, basename="determined-value")
|
router.register("determined-value", DeterminedValueView, basename="determined-value")
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
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 .documentcategory import * # noqa
|
||||||
from .history import * # noqa
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
|
|||||||
@@ -6,3 +6,10 @@ class ValuationdocumentValidator:
|
|||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentValidator:
|
||||||
|
def __init__(self): ...
|
||||||
|
|
||||||
|
def __call__(self):
|
||||||
|
return True
|
||||||
|
|||||||
8
core/apps/evaluation/validators/documentcategory.py
Normal file
8
core/apps/evaluation/validators/documentcategory.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentcategoryValidator:
|
||||||
|
def __init__(self): ...
|
||||||
|
|
||||||
|
def __call__(self):
|
||||||
|
return True
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
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 .documentcategory import * # noqa
|
||||||
from .history import * # noqa
|
from .history import * # noqa
|
||||||
from .movable import * # noqa
|
from .movable import * # noqa
|
||||||
from .quick import * # noqa
|
from .quick import * # noqa
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
from django_core.mixins import BaseViewSetMixin
|
from django_core.mixins import BaseViewSetMixin
|
||||||
from drf_spectacular.utils import extend_schema
|
from drf_spectacular.utils import extend_schema
|
||||||
from rest_framework.permissions import AllowAny
|
from rest_framework.permissions import AllowAny
|
||||||
from rest_framework.viewsets import ReadOnlyModelViewSet
|
from rest_framework.viewsets import ReadOnlyModelViewSet, ModelViewSet
|
||||||
|
from rest_framework.parsers import FormParser, MultiPartParser
|
||||||
|
|
||||||
from core.apps.evaluation.models import ValuationDocumentModel
|
from core.apps.evaluation.models import DocumentModel, ValuationDocumentModel
|
||||||
from core.apps.evaluation.serializers.document import (
|
from core.apps.evaluation.serializers.document import (
|
||||||
|
CreateDocumentSerializer,
|
||||||
CreateValuationdocumentSerializer,
|
CreateValuationdocumentSerializer,
|
||||||
|
ListDocumentSerializer,
|
||||||
ListValuationdocumentSerializer,
|
ListValuationdocumentSerializer,
|
||||||
|
RetrieveDocumentSerializer,
|
||||||
RetrieveValuationdocumentSerializer,
|
RetrieveValuationdocumentSerializer,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,3 +27,18 @@ class ValuationDocumentView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
|||||||
"retrieve": RetrieveValuationdocumentSerializer,
|
"retrieve": RetrieveValuationdocumentSerializer,
|
||||||
"create": CreateValuationdocumentSerializer,
|
"create": CreateValuationdocumentSerializer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema(tags=["Document"])
|
||||||
|
class DocumentView(BaseViewSetMixin, ModelViewSet):
|
||||||
|
queryset = DocumentModel.objects.all()
|
||||||
|
serializer_class = ListDocumentSerializer
|
||||||
|
permission_classes = [AllowAny]
|
||||||
|
parser_classes = [FormParser, MultiPartParser]
|
||||||
|
|
||||||
|
action_permission_classes = {}
|
||||||
|
action_serializer_class = {
|
||||||
|
"list": ListDocumentSerializer,
|
||||||
|
"retrieve": RetrieveDocumentSerializer,
|
||||||
|
"create": CreateDocumentSerializer,
|
||||||
|
}
|
||||||
|
|||||||
24
core/apps/evaluation/views/documentcategory.py
Normal file
24
core/apps/evaluation/views/documentcategory.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from django_core.mixins import BaseViewSetMixin
|
||||||
|
from drf_spectacular.utils import extend_schema
|
||||||
|
from rest_framework.permissions import AllowAny
|
||||||
|
from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||||
|
|
||||||
|
from core.apps.evaluation.models import DocumentcategoryModel
|
||||||
|
from core.apps.evaluation.serializers.documentcategory import (
|
||||||
|
ListDocumentcategorySerializer,
|
||||||
|
RetrieveDocumentcategorySerializer,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema(tags=["DocumentCategory"])
|
||||||
|
class DocumentCategoryView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||||
|
queryset = DocumentcategoryModel.objects.all()
|
||||||
|
serializer_class = ListDocumentcategorySerializer
|
||||||
|
permission_classes = [AllowAny]
|
||||||
|
|
||||||
|
action_permission_classes = {}
|
||||||
|
action_serializer_class = {
|
||||||
|
"list": ListDocumentcategorySerializer,
|
||||||
|
"retrieve": RetrieveDocumentcategorySerializer,
|
||||||
|
# "create": CreateDocumentcategorySerializer,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user