fix
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
from .contact_us import *
|
||||
from .folder import *
|
||||
6
core/apps/shared/admins/contact_us.py
Normal file
6
core/apps/shared/admins/contact_us.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from core.apps.shared.models import ContactUs
|
||||
|
||||
|
||||
admin.site.register(ContactUs)
|
||||
@@ -6,4 +6,4 @@ class SharedConfig(AppConfig):
|
||||
name = 'core.apps.shared'
|
||||
|
||||
def ready(self):
|
||||
import core.apps.shared.admins.folder
|
||||
import core.apps.shared.admins
|
||||
27
core/apps/shared/migrations/0002_contactus.py
Normal file
27
core/apps/shared/migrations/0002_contactus.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Generated by Django 5.2 on 2025-11-11 19:26
|
||||
|
||||
import uuid
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('shared', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ContactUs',
|
||||
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)),
|
||||
('phone_number', models.CharField(max_length=20)),
|
||||
('telegram_url', models.URLField()),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -1,2 +1,3 @@
|
||||
from .base import *
|
||||
from .folder import *
|
||||
from .folder import *
|
||||
from .contact_us import *
|
||||
12
core/apps/shared/models/contact_us.py
Normal file
12
core/apps/shared/models/contact_us.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from django.db import models
|
||||
|
||||
from core.apps.shared.models.base import BaseModel
|
||||
|
||||
|
||||
class ContactUs(BaseModel):
|
||||
phone_number = models.CharField(max_length=20)
|
||||
telegram_url = models.URLField()
|
||||
|
||||
def __str__(self):
|
||||
return self.phone_number
|
||||
|
||||
9
core/apps/shared/serializers/contact_us.py
Normal file
9
core/apps/shared/serializers/contact_us.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from core.apps.shared.models.contact_us import ContactUs
|
||||
|
||||
|
||||
class ContactUsSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = ContactUs
|
||||
fields = '__all__'
|
||||
8
core/apps/shared/urls.py
Normal file
8
core/apps/shared/urls.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from django.urls import path
|
||||
|
||||
from core.apps.shared.views.contact_us import ContactUsApiView
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('contact_us/', ContactUsApiView.as_view()),
|
||||
]
|
||||
18
core/apps/shared/views/contact_us.py
Normal file
18
core/apps/shared/views/contact_us.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from rest_framework import generics
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
|
||||
from core.apps.shared.utils.response import success_message, error_message
|
||||
from core.apps.shared.serializers.contact_us import ContactUsSerializer
|
||||
from core.apps.shared.models import ContactUs
|
||||
|
||||
|
||||
class ContactUsApiView(generics.GenericAPIView):
|
||||
permission_classes = [IsAuthenticated]
|
||||
queryset = ContactUs.objects.first()
|
||||
serializer_class = ContactUsSerializer
|
||||
|
||||
def get(self, request):
|
||||
obj = ContactUs.objects.first()
|
||||
serializer = self.serializer_class(obj)
|
||||
return Response(serializer.data, status=200)
|
||||
Reference in New Issue
Block a user