change order list serialzier class
This commit is contained in:
@@ -1 +1,2 @@
|
||||
from .region import *
|
||||
from .region import *
|
||||
from .usd_course import *
|
||||
23
core/apps/shared/admin/usd_course.py
Normal file
23
core/apps/shared/admin/usd_course.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.contrib import admin
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
|
||||
from core.apps.shared.models import UsdCourse
|
||||
|
||||
|
||||
@admin.register(UsdCourse)
|
||||
class UsdCourseAdmin(admin.ModelAdmin):
|
||||
def has_add_permission(self, request):
|
||||
return not UsdCourse.objects.exists()
|
||||
|
||||
def has_delete_permission(self, request, obj = ...):
|
||||
return False
|
||||
|
||||
def changelist_view(self, request, extra_context=None):
|
||||
config, created = UsdCourse.objects.get_or_create(
|
||||
defaults=dict(
|
||||
value=0
|
||||
)
|
||||
)
|
||||
url = reverse("admin:shared_usdcourse_change", args=[config.id])
|
||||
return HttpResponseRedirect(url)
|
||||
27
core/apps/shared/migrations/0002_usdcourse.py
Normal file
27
core/apps/shared/migrations/0002_usdcourse.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Generated by Django 5.2.4 on 2025-08-23 11:35
|
||||
|
||||
import uuid
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('shared', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='UsdCourse',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('value', models.PositiveBigIntegerField()),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'dollar kursi',
|
||||
'verbose_name_plural': 'dollar kursi',
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -1,2 +1,3 @@
|
||||
from .base import BaseModel
|
||||
from .region import *
|
||||
from .region import *
|
||||
from .usd_course import *
|
||||
12
core/apps/shared/models/usd_course.py
Normal file
12
core/apps/shared/models/usd_course.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from django.db import models
|
||||
|
||||
from core.apps.shared.models import BaseModel
|
||||
|
||||
|
||||
class UsdCourse(BaseModel):
|
||||
value = models.PositiveBigIntegerField()
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'dollar kursi'
|
||||
verbose_name_plural = 'dollar kursi'
|
||||
|
||||
Reference in New Issue
Block a user