Compare commits
2 Commits
129827b495
...
32d3bea234
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32d3bea234 | ||
|
|
76563b3ef0 |
28
core/apps/evaluation/migrations/0032_certificatemodel.py
Normal file
28
core/apps/evaluation/migrations/0032_certificatemodel.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# Generated by Django 6.0.4 on 2026-04-23 11:07
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('evaluation', '0031_remove_autoevaluationmodel_object_location_city_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='CertificateModel',
|
||||
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')),
|
||||
('file_url', models.URLField(max_length=255, verbose_name='file url')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Certificate',
|
||||
'verbose_name_plural': 'Certificates',
|
||||
'db_table': 'certificate',
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -11,3 +11,4 @@ from .report import * # noqa
|
||||
from .request import * # noqa
|
||||
from .valuation import * # noqa
|
||||
from .vehicle import * # noqa
|
||||
from .certificate import * # noqa
|
||||
|
||||
20
core/apps/evaluation/models/certificate.py
Normal file
20
core/apps/evaluation/models/certificate.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from django.db import models
|
||||
from django_core.models import AbstractBaseModel
|
||||
from model_bakery import baker
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
class CertificateModel(AbstractBaseModel):
|
||||
title = models.CharField(verbose_name=_("title"), max_length=255, blank=False, null=False)
|
||||
file_url = models.URLField(verbose_name=_("file url"), max_length=255, blank=False, null=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
@classmethod
|
||||
def _baker(cls):
|
||||
return baker.make(cls)
|
||||
|
||||
class Meta:
|
||||
db_table = "certificate"
|
||||
verbose_name = _("Certificate")
|
||||
verbose_name_plural = _("Certificates")
|
||||
@@ -12,3 +12,4 @@ from .request import * # noqa
|
||||
from .valuation import * # noqa
|
||||
from .vehicle import * # noqa
|
||||
from .tech_passport import * # noqa
|
||||
from .certificate import * # noqa
|
||||
|
||||
1
core/apps/evaluation/serializers/certificate/__init__.py
Normal file
1
core/apps/evaluation/serializers/certificate/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .certificate import * # noqa
|
||||
12
core/apps/evaluation/serializers/certificate/certificate.py
Normal file
12
core/apps/evaluation/serializers/certificate/certificate.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from rest_framework import serializers
|
||||
from core.apps.evaluation.models import CertificateModel
|
||||
|
||||
class BaseCertificateSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = CertificateModel
|
||||
fields = [
|
||||
"id",
|
||||
"title",
|
||||
"file_url"
|
||||
]
|
||||
@@ -29,6 +29,7 @@ from .views import (
|
||||
DidoxCompanyInfoAPIView,
|
||||
TechPassportAPIView,
|
||||
EvaluationStatusChange,
|
||||
CertificateView,
|
||||
ArchiveQuickEvaluationView,
|
||||
ArchiveEvaluationrequestView,
|
||||
)
|
||||
@@ -55,6 +56,7 @@ router.register("vehicle", VehicleView, basename="vehicle")
|
||||
router.register("valuation", ValuationView, basename="valuation")
|
||||
router.register("property-owner", PropertyOwnerView, basename="property-owner")
|
||||
router.register("customer", CustomerView, basename="customer")
|
||||
router.register("certificate", CertificateView, basename="certificate")
|
||||
urlpatterns = [
|
||||
path("", include(router.urls)),
|
||||
path("auto-evaluation/appraisers/", include(
|
||||
|
||||
@@ -13,3 +13,4 @@ from .valuation import * # noqa
|
||||
from .vehicle import * # noqa
|
||||
from .didox import * # noqa
|
||||
from .tech_passport import * # noqa
|
||||
from .certificate import * # noqa
|
||||
|
||||
20
core/apps/evaluation/views/certificate.py
Normal file
20
core/apps/evaluation/views/certificate.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from django_core.mixins import BaseViewSetMixin
|
||||
from drf_spectacular.utils import extend_schema
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
from core.apps.evaluation.models import CertificateModel
|
||||
from core.apps.evaluation.serializers.certificate import BaseCertificateSerializer
|
||||
from rest_framework.filters import SearchFilter
|
||||
|
||||
@extend_schema(tags=["Certificate"])
|
||||
class CertificateView(BaseViewSetMixin, ModelViewSet):
|
||||
queryset = CertificateModel.objects.all()
|
||||
serializer_class = BaseCertificateSerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
filter_backends = [SearchFilter]
|
||||
search_fields = ["title"]
|
||||
|
||||
pagination_class = None
|
||||
|
||||
action_permission_classes = {}
|
||||
Reference in New Issue
Block a user