Compare commits
15 Commits
129827b495
...
user-crud
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb275a091a | ||
|
|
190480b6f7 | ||
| 1a985ffa4b | |||
|
|
3b62c5a7bf | ||
|
|
07f8d55966 | ||
| b0b4ccfeee | |||
|
|
ccefe9c119 | ||
|
|
6456283f72 | ||
|
|
6eed2d998e | ||
| 2c82691166 | |||
|
|
7a88e39b96 | ||
|
|
dc622ce305 | ||
|
|
6e0718c5db | ||
|
|
32d3bea234 | ||
|
|
76563b3ef0 |
@@ -13,7 +13,7 @@ from config.env import env
|
||||
|
||||
|
||||
def home(request):
|
||||
return HttpResponse("OK: #2a08ad9662f957a3a0b75b8c8440d49b0b4e9ae4")
|
||||
return HttpResponse("OK: #1a985ffa4b785b63a71b9e0cdd78042c3fcda239")
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
@@ -30,3 +30,16 @@ class UserUpdateSerializer(serializers.ModelSerializer):
|
||||
"last_name",
|
||||
"avatar"
|
||||
]
|
||||
|
||||
class AdminUserSerializer(serializers.ModelSerializer):
|
||||
avatar = serializers.SerializerMethodField(method_name='get_avatar')
|
||||
|
||||
class Meta:
|
||||
model = get_user_model()
|
||||
fields = "__all__"
|
||||
|
||||
def get_avatar(self, obj):
|
||||
request = self.context.get('request')
|
||||
if obj.avatar:
|
||||
return request.build_absolute_uri(obj.avatar.url)
|
||||
return None
|
||||
@@ -4,7 +4,7 @@ Accounts app urls
|
||||
|
||||
from django.urls import path, include
|
||||
from rest_framework_simplejwt import views as jwt_views
|
||||
from .views import RegisterView, ResetPasswordView, MeView, ChangePasswordView, UserListApiView, AdminUserListApiView
|
||||
from .views import RegisterView, ResetPasswordView, MeView, ChangePasswordView, UserListApiView, AdminUserListApiView,AdminUserView
|
||||
from rest_framework.routers import DefaultRouter
|
||||
|
||||
router = DefaultRouter()
|
||||
@@ -12,6 +12,7 @@ router.register("auth", RegisterView, basename="auth")
|
||||
router.register("auth", ResetPasswordView, basename="reset-password")
|
||||
router.register("auth", MeView, basename="me")
|
||||
router.register("auth", ChangePasswordView, basename="change-password")
|
||||
router.register("user", AdminUserView, basename="user-crud")
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
@@ -5,8 +5,11 @@ from rest_framework.permissions import IsAuthenticated
|
||||
|
||||
from drf_spectacular.utils import extend_schema
|
||||
|
||||
from core.apps.accounts.serializers.user import UserSerializer
|
||||
from core.apps.accounts.serializers.user import UserSerializer, AdminUserSerializer
|
||||
from core.apps.accounts.choices.user import RoleChoice
|
||||
from django_core.mixins import BaseViewSetMixin
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
@@ -29,3 +32,16 @@ class AdminUserListApiView(generics.ListAPIView):
|
||||
permission_classes = [IsAuthenticated]
|
||||
filter_backends = [filters.SearchFilter]
|
||||
search_fields = ['phone', 'first_name', 'last_name']
|
||||
|
||||
|
||||
@extend_schema(tags=["User"],request=AdminUserSerializer)
|
||||
class AdminUserView(BaseViewSetMixin, ModelViewSet):
|
||||
queryset = User.objects.filter(role=RoleChoice.USER)
|
||||
serializer_class = AdminUserSerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
filter_backends = [filters.SearchFilter]
|
||||
search_fields = ['phone', 'first_name', 'last_name']
|
||||
|
||||
def serializer_context(self):
|
||||
return self.serializer_class(context={"request": self.request})
|
||||
|
||||
|
||||
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',
|
||||
},
|
||||
),
|
||||
]
|
||||
15
core/apps/evaluation/migrations/0033_merge_20260423_1622.py
Normal file
15
core/apps/evaluation/migrations/0033_merge_20260423_1622.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# Generated by Django 6.0.4 on 2026-04-23 11:22
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('evaluation', '0032_certificatemodel'),
|
||||
('evaluation', '0032_evaluationrequestmodel_is_archive'),
|
||||
('evaluation', '0032_quickevaluationmodel_is_archive'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
]
|
||||
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 6.0.4 on 2026-04-23 13:42
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('evaluation', '0033_merge_20260423_1622'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='certificatemodel',
|
||||
name='file_url',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='certificatemodel',
|
||||
name='file',
|
||||
field=models.FileField(blank=True, null=True, upload_to='certificates/', verbose_name='file'),
|
||||
),
|
||||
]
|
||||
@@ -11,3 +11,4 @@ from .report import * # noqa
|
||||
from .request import * # noqa
|
||||
from .valuation import * # noqa
|
||||
from .vehicle import * # noqa
|
||||
from .certificate import * # noqa
|
||||
|
||||
30
core/apps/evaluation/models/certificate.py
Normal file
30
core/apps/evaluation/models/certificate.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from django.db import models
|
||||
from django_core.models import AbstractBaseModel
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from model_bakery import baker
|
||||
|
||||
|
||||
class CertificateModel(AbstractBaseModel):
|
||||
title = models.CharField(
|
||||
verbose_name=_("title"),
|
||||
max_length=255
|
||||
)
|
||||
|
||||
file = models.FileField(
|
||||
verbose_name=_("file"),
|
||||
upload_to="certificates/",
|
||||
blank=True,
|
||||
null=True
|
||||
)
|
||||
|
||||
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
|
||||
13
core/apps/evaluation/serializers/certificate/certificate.py
Normal file
13
core/apps/evaluation/serializers/certificate/certificate.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from rest_framework import serializers
|
||||
from core.apps.evaluation.models import CertificateModel
|
||||
|
||||
|
||||
class BaseCertificateSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = CertificateModel
|
||||
fields = [
|
||||
"id",
|
||||
"title",
|
||||
"file",
|
||||
]
|
||||
@@ -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(
|
||||
@@ -76,6 +78,6 @@ urlpatterns = [
|
||||
),
|
||||
path("evaluation-request/<int:pk>/change-status/", EvaluationStatusChange.as_view(),
|
||||
name="evaluation-change-status"),
|
||||
path("quick-evaluation/archive/", ArchiveQuickEvaluationView.as_view(), name="quick-evaluation-archive"),
|
||||
path("evaluation-request/archive/", ArchiveEvaluationrequestView.as_view(), name="evaluation-request-archive"),
|
||||
path("archive/quick-evaluation/", ArchiveQuickEvaluationView.as_view(), name="quick-evaluation-archive"),
|
||||
path("archive/evaluation-request/", ArchiveEvaluationrequestView.as_view(), name="evaluation-request-archive"),
|
||||
]
|
||||
|
||||
@@ -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
|
||||
|
||||
23
core/apps/evaluation/views/certificate.py
Normal file
23
core/apps/evaluation/views/certificate.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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
|
||||
from rest_framework.parsers import MultiPartParser, FormParser
|
||||
|
||||
@extend_schema(tags=["Certificate"],request=BaseCertificateSerializer)
|
||||
class CertificateView(BaseViewSetMixin, ModelViewSet):
|
||||
queryset = CertificateModel.objects.all()
|
||||
serializer_class = BaseCertificateSerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
parser_classes = [MultiPartParser, FormParser]
|
||||
|
||||
filter_backends = [SearchFilter]
|
||||
search_fields = ["title"]
|
||||
|
||||
pagination_class = None
|
||||
|
||||
action_permission_classes = {}
|
||||
@@ -84,7 +84,7 @@ services:
|
||||
max-file: "5"
|
||||
|
||||
web:
|
||||
image: husanjon/sifatbaho:108
|
||||
image: husanjon/sifatbaho:114
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
@@ -129,7 +129,7 @@ services:
|
||||
max-file: "5"
|
||||
|
||||
celery:
|
||||
image: husanjon/sifatbaho:108
|
||||
image: husanjon/sifatbaho:114
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
|
||||
Reference in New Issue
Block a user