add: add two new model
This commit is contained in:
@@ -78,3 +78,14 @@ class NewsAdmin(TranslationAdmin):
|
|||||||
@admin.register(models.Country)
|
@admin.register(models.Country)
|
||||||
class CountryAdmin(admin.ModelAdmin):
|
class CountryAdmin(admin.ModelAdmin):
|
||||||
list_display = ['name']
|
list_display = ['name']
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(models.Requisite)
|
||||||
|
class Requisite(TranslationAdmin):
|
||||||
|
list_display = ['company_name', 'legal_address', 'tin', 'okpo']
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(models.PrivacyPolicy)
|
||||||
|
class Requisite(TranslationAdmin):
|
||||||
|
list_display = ['title', 'text']
|
||||||
|
|
||||||
35
core/apps/common/migrations/0003_requisite.py
Normal file
35
core/apps/common/migrations/0003_requisite.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Generated by Django 5.2 on 2025-09-03 18:12
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('common', '0002_banner_text_banner_text_en_banner_text_ru_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Requisite',
|
||||||
|
fields=[
|
||||||
|
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||||
|
('created_at', models.DateField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateField(auto_now=True)),
|
||||||
|
('company_name', models.CharField(max_length=200)),
|
||||||
|
('legal_address', models.CharField(max_length=200)),
|
||||||
|
('tin', models.CharField(max_length=15)),
|
||||||
|
('okpo', models.CharField(max_length=10)),
|
||||||
|
('oked', models.CharField(max_length=10)),
|
||||||
|
('bank_name', models.CharField(max_length=200)),
|
||||||
|
('bank_code', models.CharField(max_length=15)),
|
||||||
|
('uzs', models.PositiveBigIntegerField()),
|
||||||
|
('usd', models.PositiveBigIntegerField()),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'korxona rekvizit',
|
||||||
|
'verbose_name_plural': 'korxona rekvizitlar',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# Generated by Django 5.2 on 2025-09-03 18:13
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('common', '0003_requisite'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='requisite',
|
||||||
|
name='company_name_en',
|
||||||
|
field=models.CharField(max_length=200, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='requisite',
|
||||||
|
name='company_name_ru',
|
||||||
|
field=models.CharField(max_length=200, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='requisite',
|
||||||
|
name='company_name_uz',
|
||||||
|
field=models.CharField(max_length=200, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='requisite',
|
||||||
|
name='legal_address_en',
|
||||||
|
field=models.CharField(max_length=200, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='requisite',
|
||||||
|
name='legal_address_ru',
|
||||||
|
field=models.CharField(max_length=200, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='requisite',
|
||||||
|
name='legal_address_uz',
|
||||||
|
field=models.CharField(max_length=200, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
34
core/apps/common/migrations/0005_privacypolicy.py
Normal file
34
core/apps/common/migrations/0005_privacypolicy.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Generated by Django 5.2 on 2025-09-03 18:19
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('common', '0004_requisite_company_name_en_requisite_company_name_ru_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='PrivacyPolicy',
|
||||||
|
fields=[
|
||||||
|
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||||
|
('created_at', models.DateField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateField(auto_now=True)),
|
||||||
|
('title', models.CharField(max_length=200)),
|
||||||
|
('title_uz', models.CharField(max_length=200, null=True)),
|
||||||
|
('title_en', models.CharField(max_length=200, null=True)),
|
||||||
|
('title_ru', models.CharField(max_length=200, null=True)),
|
||||||
|
('text', models.TextField()),
|
||||||
|
('text_uz', models.TextField(null=True)),
|
||||||
|
('text_en', models.TextField(null=True)),
|
||||||
|
('text_ru', models.TextField(null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Maxfiylik siyosati',
|
||||||
|
'verbose_name_plural': 'Maxfiylik siyosati',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -136,3 +136,34 @@ class Country(BaseModel):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = 'Davlat'
|
verbose_name = 'Davlat'
|
||||||
verbose_name_plural = 'Davlatlar'
|
verbose_name_plural = 'Davlatlar'
|
||||||
|
|
||||||
|
|
||||||
|
class Requisite(BaseModel):
|
||||||
|
company_name = models.CharField(max_length=200)
|
||||||
|
legal_address = models.CharField(max_length=200)
|
||||||
|
tin = models.CharField(max_length=15)
|
||||||
|
okpo = models.CharField(max_length=10)
|
||||||
|
oked = models.CharField(max_length=10)
|
||||||
|
bank_name = models.CharField(max_length=200)
|
||||||
|
bank_code = models.CharField(max_length=15)
|
||||||
|
uzs = models.PositiveBigIntegerField()
|
||||||
|
usd = models.PositiveBigIntegerField()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.company_name
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = 'korxona rekvizit'
|
||||||
|
verbose_name_plural = 'korxona rekvizitlar'
|
||||||
|
|
||||||
|
|
||||||
|
class PrivacyPolicy(BaseModel):
|
||||||
|
title = models.CharField(max_length=200)
|
||||||
|
text = models.TextField()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = 'Maxfiylik siyosati'
|
||||||
|
verbose_name_plural = 'Maxfiylik siyosati'
|
||||||
|
|||||||
@@ -67,3 +67,19 @@ class ContactUsSerializer(serializers.ModelSerializer):
|
|||||||
'first_name', 'last_name', 'phone', 'email', 'service', 'message',
|
'first_name', 'last_name', 'phone', 'email', 'service', 'message',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class RequisiteSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Requisite
|
||||||
|
fields = [
|
||||||
|
'id', 'company_name', 'legal_address', 'tin', 'okpo', 'oked', 'bank_name', 'bank_code',
|
||||||
|
'uzs', 'usd',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class PrivacyPolicySerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.PrivacyPolicy
|
||||||
|
fields = [
|
||||||
|
'id', 'title', 'text'
|
||||||
|
]
|
||||||
@@ -36,3 +36,17 @@ class NewsTranslation(translator.TranslationOptions):
|
|||||||
fields = [
|
fields = [
|
||||||
'title', 'text'
|
'title', 'text'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@translator.register(models.Requisite)
|
||||||
|
class RequisiteTranslation(translator.TranslationOptions):
|
||||||
|
fields = [
|
||||||
|
'company_name', 'legal_address'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@translator.register(models.PrivacyPolicy)
|
||||||
|
class RequisiteTranslation(translator.TranslationOptions):
|
||||||
|
fields = [
|
||||||
|
'title', 'text'
|
||||||
|
]
|
||||||
|
|||||||
@@ -9,4 +9,6 @@ urlpatterns = [
|
|||||||
path('services/', views.ServiceListApiView.as_view()),
|
path('services/', views.ServiceListApiView.as_view()),
|
||||||
path('news/', views.NewsListApiView.as_view()),
|
path('news/', views.NewsListApiView.as_view()),
|
||||||
path('contact_us/', views.ContactUsApiView.as_view()),
|
path('contact_us/', views.ContactUsApiView.as_view()),
|
||||||
|
path('requisite/', views.RequisiteApiView.as_view()),
|
||||||
|
path('privacy_policy/', views.PrivacyPolicyListApiView.as_view()),
|
||||||
]
|
]
|
||||||
@@ -44,3 +44,18 @@ class ContactUsApiView(generics.CreateAPIView):
|
|||||||
serializer_class = serializers.ContactUsSerializer
|
serializer_class = serializers.ContactUsSerializer
|
||||||
queryset = models.ContactUs.objects.all()
|
queryset = models.ContactUs.objects.all()
|
||||||
|
|
||||||
|
|
||||||
|
class RequisiteApiView(generics.GenericAPIView):
|
||||||
|
serializer_class = serializers.RequisiteSerializer
|
||||||
|
queryset = models.Requisite.objects.all()
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
queryset = models.Requisite.objects.first()
|
||||||
|
serializer = self.serializer_class(queryset)
|
||||||
|
return Response(serializer.data)
|
||||||
|
|
||||||
|
|
||||||
|
class PrivacyPolicyListApiView(generics.ListAPIView):
|
||||||
|
queryset = models.PrivacyPolicy.objects.all()
|
||||||
|
serializer_class = serializers.PrivacyPolicySerializer
|
||||||
|
|
||||||
Reference in New Issue
Block a user