payment modeli yaratildi
This commit is contained in:
32
MODELS.md
Normal file
32
MODELS.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# SifatBaho — Modellar Ro'yxati
|
||||||
|
|
||||||
|
## Evaluation App — 11 ta model
|
||||||
|
|
||||||
|
| # | Model nomi | Fayl | Vazifasi |
|
||||||
|
|---|-----------|------|----------|
|
||||||
|
| 1 | `CustomerModel` | `models/customer.py` | Buyurtmachi (jismoniy yoki yuridik shaxs). Ariza beruvchi mijozning shaxsiy ma'lumotlari saqlanadi. |
|
||||||
|
| 2 | `PropertyOwnerModel` | `models/customer.py` | Mulk egasi. Agar buyurtmachi va mulk egasi boshqa odam bo'lsa, shu model to'ldiriladi. |
|
||||||
|
| 3 | `ValuationModel` | `models/valuation.py` | Asosiy ariza. Barcha baholash turlari uchun umumiy model: status, narx, buyurtmachi, baholovchi. |
|
||||||
|
| 4 | `VehicleModel` | `models/vehicle.py` | Transport vositasi. Moshinaning texnik ma'lumotlari: VIN, davlat raqami, marka, model, rang, yurgan masofasi. |
|
||||||
|
| 5 | `AutoEvaluationModel` | `models/auto.py` | Avto baholash bog'lamasi. Arizani moshinaga bog'laydi (Ariza + Vehicle = AutoEvaluation). |
|
||||||
|
| 6 | `RealEstateEvaluationModel` | `models/real_estate.py` | Ko'chmas mulk baholash. Uy, xonadon, ofis uchun: maydoni, qavati, kadastr raqami, manzili. |
|
||||||
|
| 7 | `MovablePropertyEvaluationModel` | `models/movable.py` | Ko'char mulk baholash. Uskunalar, mebellar, stanoklar uchun: nomi, kategoriyasi, seriya raqami, miqdori. |
|
||||||
|
| 8 | `QuickEvaluationModel` | `models/quick.py` | Tezkor baholash. To'liq ariza yaratmasdan, moshina narxini taxminiy hisoblab beradi (kalkulyator). |
|
||||||
|
| 9 | `EvaluationReportModel` | `models/report.py` | Yakuniy hisobot. Baholovchi tomonidan tayyorlanadigan rasmiy natija: yakuniy narx, PDF fayl, xulosa matni. |
|
||||||
|
| 10 | `ValuationDocumentModel` | `models/document.py` | Ariza hujjatlari. Arizaga biriktiriladigan fayllar: passport, tex passport, rasmlar, guvohnomalar. |
|
||||||
|
|
||||||
|
## Payment App — 1 ta model
|
||||||
|
|
||||||
|
| # | Model nomi | Fayl | Vazifasi |
|
||||||
|
|---|-----------|------|----------|
|
||||||
|
| 11 | `PaymentModel` | `models/payment.py` | To'lov. Ariza uchun to'lov ma'lumotlari: summa, to'lov usuli (Click/Payme/naqd), tranzaksiya ID, status. |
|
||||||
|
|
||||||
|
## Accounts App — 1 ta model (mavjud edi)
|
||||||
|
|
||||||
|
| # | Model nomi | Fayl | Vazifasi |
|
||||||
|
|---|-----------|------|----------|
|
||||||
|
| 12 | `User` | `models/user.py` | Foydalanuvchi. Tizimga kirish, rollar (admin, baholovchi, diler, mijoz). |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Jami: 12 ta model** — barchasi TZ asosida yaratildi va ishlamoqda. ✅
|
||||||
@@ -1 +1 @@
|
|||||||
MODULES = ["core.apps.shared", "core.apps.evaluation"]
|
MODULES = ["core.apps.shared", "core.apps.evaluation", "core.apps.payment"]
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ urlpatterns = [
|
|||||||
path("health/", home),
|
path("health/", home),
|
||||||
path("api/v1/", include("core.apps.accounts.urls")),
|
path("api/v1/", include("core.apps.accounts.urls")),
|
||||||
path("api/", include("core.apps.shared.urls")),
|
path("api/", include("core.apps.shared.urls")),
|
||||||
path("api/", include("core.apps.evaluation.urls")),
|
path("api/v1/", include("core.apps.evaluation.urls")),
|
||||||
|
path("api/v1/", include("core.apps.payment.urls")),
|
||||||
]
|
]
|
||||||
urlpatterns += [
|
urlpatterns += [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
|
|||||||
0
core/apps/payment/__init__.py
Normal file
0
core/apps/payment/__init__.py
Normal file
1
core/apps/payment/admin/__init__.py
Normal file
1
core/apps/payment/admin/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
12
core/apps/payment/admin/payment.py
Normal file
12
core/apps/payment/admin/payment.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from unfold.admin import ModelAdmin
|
||||||
|
|
||||||
|
from core.apps.payment.models import PaymentModel
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(PaymentModel)
|
||||||
|
class PaymentAdmin(ModelAdmin):
|
||||||
|
list_display = (
|
||||||
|
"id",
|
||||||
|
"__str__",
|
||||||
|
)
|
||||||
6
core/apps/payment/apps.py
Normal file
6
core/apps/payment/apps.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ModuleConfig(AppConfig):
|
||||||
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
|
name = "core.apps.payment"
|
||||||
1
core/apps/payment/enums/__init__.py
Normal file
1
core/apps/payment/enums/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
20
core/apps/payment/enums/payment.py
Normal file
20
core/apps/payment/enums/payment.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentMethod(models.TextChoices):
|
||||||
|
CASH = "cash", _("Cash")
|
||||||
|
CARD = "card", _("Card")
|
||||||
|
BANK_TRANSFER = "bank_transfer", _("Bank Transfer")
|
||||||
|
CLICK = "click", _("Click")
|
||||||
|
PAYME = "payme", _("Payme")
|
||||||
|
UZUM = "uzum", _("Uzum")
|
||||||
|
OTHER = "other", _("Other")
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentStatus(models.TextChoices):
|
||||||
|
PENDING = "pending", _("Pending")
|
||||||
|
COMPLETED = "completed", _("Completed")
|
||||||
|
FAILED = "failed", _("Failed")
|
||||||
|
REFUNDED = "refunded", _("Refunded")
|
||||||
|
CANCELLED = "cancelled", _("Cancelled")
|
||||||
1
core/apps/payment/filters/__init__.py
Normal file
1
core/apps/payment/filters/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
13
core/apps/payment/filters/payment.py
Normal file
13
core/apps/payment/filters/payment.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from django_filters import rest_framework as filters
|
||||||
|
|
||||||
|
from core.apps.payment.models import PaymentModel
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentFilter(filters.FilterSet):
|
||||||
|
# name = filters.CharFilter(field_name="name", lookup_expr="icontains")
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = PaymentModel
|
||||||
|
fields = [
|
||||||
|
"name",
|
||||||
|
]
|
||||||
1
core/apps/payment/forms/__init__.py
Normal file
1
core/apps/payment/forms/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
10
core/apps/payment/forms/payment.py
Normal file
10
core/apps/payment/forms/payment.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from django import forms
|
||||||
|
|
||||||
|
from core.apps.payment.models import PaymentModel
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentForm(forms.ModelForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = PaymentModel
|
||||||
|
fields = "__all__"
|
||||||
40
core/apps/payment/migrations/0001_initial.py
Normal file
40
core/apps/payment/migrations/0001_initial.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-02-18 13:02
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('evaluation', '0009_valuationdocumentmodel'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='PaymentModel',
|
||||||
|
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)),
|
||||||
|
('amount', models.DecimalField(decimal_places=2, max_digits=15, verbose_name='amount')),
|
||||||
|
('payment_method', models.CharField(choices=[('cash', 'Cash'), ('card', 'Card'), ('bank_transfer', 'Bank Transfer'), ('click', 'Click'), ('payme', 'Payme'), ('uzum', 'Uzum'), ('other', 'Other')], default='cash', max_length=50, verbose_name='payment method')),
|
||||||
|
('status', models.CharField(choices=[('pending', 'Pending'), ('completed', 'Completed'), ('failed', 'Failed'), ('refunded', 'Refunded'), ('cancelled', 'Cancelled')], default='pending', max_length=50, verbose_name='status')),
|
||||||
|
('transaction_id', models.CharField(blank=True, max_length=255, null=True, unique=True, verbose_name='transaction ID')),
|
||||||
|
('paid_at', models.DateTimeField(blank=True, null=True, verbose_name='paid at')),
|
||||||
|
('note', models.TextField(blank=True, verbose_name='note')),
|
||||||
|
('payer', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='payments', to=settings.AUTH_USER_MODEL, verbose_name='payer')),
|
||||||
|
('valuation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='payments', to='evaluation.valuationmodel', verbose_name='valuation')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Payment',
|
||||||
|
'verbose_name_plural': 'Payments',
|
||||||
|
'db_table': 'Payment',
|
||||||
|
'ordering': ['-created_at'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
0
core/apps/payment/migrations/__init__.py
Normal file
0
core/apps/payment/migrations/__init__.py
Normal file
1
core/apps/payment/models/__init__.py
Normal file
1
core/apps/payment/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
69
core/apps/payment/models/payment.py
Normal file
69
core/apps/payment/models/payment.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django_core.models import AbstractBaseModel
|
||||||
|
from model_bakery import baker
|
||||||
|
|
||||||
|
from core.apps.payment.enums.payment import PaymentMethod, PaymentStatus
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentModel(AbstractBaseModel):
|
||||||
|
valuation = models.ForeignKey(
|
||||||
|
"evaluation.ValuationModel",
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
related_name="payments",
|
||||||
|
verbose_name=_("valuation"),
|
||||||
|
)
|
||||||
|
payer = models.ForeignKey(
|
||||||
|
"accounts.User",
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
related_name="payments",
|
||||||
|
verbose_name=_("payer"),
|
||||||
|
)
|
||||||
|
amount = models.DecimalField(
|
||||||
|
verbose_name=_("amount"),
|
||||||
|
max_digits=15,
|
||||||
|
decimal_places=2,
|
||||||
|
)
|
||||||
|
payment_method = models.CharField(
|
||||||
|
verbose_name=_("payment method"),
|
||||||
|
max_length=50,
|
||||||
|
choices=PaymentMethod.choices,
|
||||||
|
default=PaymentMethod.CASH,
|
||||||
|
)
|
||||||
|
status = models.CharField(
|
||||||
|
verbose_name=_("status"),
|
||||||
|
max_length=50,
|
||||||
|
choices=PaymentStatus.choices,
|
||||||
|
default=PaymentStatus.PENDING,
|
||||||
|
)
|
||||||
|
transaction_id = models.CharField(
|
||||||
|
verbose_name=_("transaction ID"),
|
||||||
|
max_length=255,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
unique=True,
|
||||||
|
)
|
||||||
|
paid_at = models.DateTimeField(
|
||||||
|
verbose_name=_("paid at"),
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
note = models.TextField(
|
||||||
|
verbose_name=_("note"),
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"Payment #{self.pk} — {self.amount} ({self.get_status_display()})"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _baker(cls):
|
||||||
|
return baker.make(cls)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = "Payment"
|
||||||
|
verbose_name = _("Payment")
|
||||||
|
verbose_name_plural = _("Payments")
|
||||||
|
ordering = ["-created_at"]
|
||||||
1
core/apps/payment/permissions/__init__.py
Normal file
1
core/apps/payment/permissions/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
12
core/apps/payment/permissions/payment.py
Normal file
12
core/apps/payment/permissions/payment.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from rest_framework import permissions
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentPermission(permissions.BasePermission):
|
||||||
|
|
||||||
|
def __init__(self) -> None: ...
|
||||||
|
|
||||||
|
def __call__(self, *args, **kwargs):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def has_permission(self, request, view):
|
||||||
|
return True
|
||||||
1
core/apps/payment/serializers/__init__.py
Normal file
1
core/apps/payment/serializers/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
1
core/apps/payment/serializers/payment/__init__.py
Normal file
1
core/apps/payment/serializers/payment/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
28
core/apps/payment/serializers/payment/payment.py
Normal file
28
core/apps/payment/serializers/payment/payment.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from core.apps.payment.models import PaymentModel
|
||||||
|
|
||||||
|
|
||||||
|
class BasePaymentSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = PaymentModel
|
||||||
|
fields = [
|
||||||
|
"id",
|
||||||
|
"valuation",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class ListPaymentSerializer(BasePaymentSerializer):
|
||||||
|
class Meta(BasePaymentSerializer.Meta): ...
|
||||||
|
|
||||||
|
|
||||||
|
class RetrievePaymentSerializer(BasePaymentSerializer):
|
||||||
|
class Meta(BasePaymentSerializer.Meta): ...
|
||||||
|
|
||||||
|
|
||||||
|
class CreatePaymentSerializer(BasePaymentSerializer):
|
||||||
|
class Meta(BasePaymentSerializer.Meta):
|
||||||
|
fields = [
|
||||||
|
"id",
|
||||||
|
"valuation",
|
||||||
|
]
|
||||||
1
core/apps/payment/signals/__init__.py
Normal file
1
core/apps/payment/signals/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
8
core/apps/payment/signals/payment.py
Normal file
8
core/apps/payment/signals/payment.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from django.db.models.signals import post_save
|
||||||
|
from django.dispatch import receiver
|
||||||
|
|
||||||
|
from core.apps.payment.models import PaymentModel
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_save, sender=PaymentModel)
|
||||||
|
def PaymentSignal(sender, instance, created, **kwargs): ...
|
||||||
1
core/apps/payment/tests/__init__.py
Normal file
1
core/apps/payment/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
1
core/apps/payment/tests/payment/__init__.py
Normal file
1
core/apps/payment/tests/payment/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .test_payment import * # noqa
|
||||||
101
core/apps/payment/tests/payment/test_payment.py
Normal file
101
core/apps/payment/tests/payment/test_payment.py
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import pytest
|
||||||
|
from django.urls import reverse
|
||||||
|
from rest_framework.test import APIClient
|
||||||
|
|
||||||
|
from core.apps.payment.models import PaymentModel
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def instance(db):
|
||||||
|
return PaymentModel._baker()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def api_client(instance):
|
||||||
|
client = APIClient()
|
||||||
|
##client.force_authenticate(user=instance.user)
|
||||||
|
return client, instance
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def data(api_client):
|
||||||
|
client, instance = api_client
|
||||||
|
return (
|
||||||
|
{
|
||||||
|
"list": reverse("payment-list"),
|
||||||
|
"retrieve": reverse("payment-detail", kwargs={"pk": instance.pk}),
|
||||||
|
"retrieve-not-found": reverse("payment-detail", kwargs={"pk": 1000}),
|
||||||
|
},
|
||||||
|
client,
|
||||||
|
instance,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_list(data):
|
||||||
|
urls, client, _ = data
|
||||||
|
response = client.get(urls["list"])
|
||||||
|
data_resp = response.json()
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert data_resp["status"] is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_retrieve(data):
|
||||||
|
urls, client, _ = data
|
||||||
|
response = client.get(urls["retrieve"])
|
||||||
|
data_resp = response.json()
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert data_resp["status"] is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_retrieve_not_found(data):
|
||||||
|
urls, client, _ = data
|
||||||
|
response = client.get(urls["retrieve-not-found"])
|
||||||
|
data_resp = response.json()
|
||||||
|
assert response.status_code == 404
|
||||||
|
assert data_resp["status"] is False
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_create(data):
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.post(urls["list"], data={"name": "test"})
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 201
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_update(data):
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.patch(urls["retrieve"], data={"name": "updated"})
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
#
|
||||||
|
# # verify updated value
|
||||||
|
# response = client.get(urls["retrieve"])
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
# assert response.json()["data"]["name"] == "updated"
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_partial_update():
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.patch(urls["retrieve"], data={"name": "updated"})
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
#
|
||||||
|
# # verify updated value
|
||||||
|
# response = client.get(urls["retrieve"])
|
||||||
|
# assert response.json()["status"] is True
|
||||||
|
# assert response.status_code == 200
|
||||||
|
# assert response.json()["data"]["name"] == "updated"
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.django_db
|
||||||
|
# def test_destroy(data):
|
||||||
|
# urls, client, _ = data
|
||||||
|
# response = client.delete(urls["retrieve"])
|
||||||
|
# assert response.status_code == 204
|
||||||
1
core/apps/payment/translation/__init__.py
Normal file
1
core/apps/payment/translation/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
8
core/apps/payment/translation/payment.py
Normal file
8
core/apps/payment/translation/payment.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from modeltranslation.translator import TranslationOptions, register
|
||||||
|
|
||||||
|
from core.apps.payment.models import PaymentModel
|
||||||
|
|
||||||
|
|
||||||
|
@register(PaymentModel)
|
||||||
|
class PaymentTranslation(TranslationOptions):
|
||||||
|
fields = []
|
||||||
8
core/apps/payment/urls.py
Normal file
8
core/apps/payment/urls.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from django.urls import include, path
|
||||||
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
|
from .views import PaymentView
|
||||||
|
|
||||||
|
router = DefaultRouter()
|
||||||
|
router.register("payment", PaymentView, basename="payment")
|
||||||
|
urlpatterns = [path("", include(router.urls))]
|
||||||
1
core/apps/payment/validators/__init__.py
Normal file
1
core/apps/payment/validators/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
8
core/apps/payment/validators/payment.py
Normal file
8
core/apps/payment/validators/payment.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentValidator:
|
||||||
|
def __init__(self): ...
|
||||||
|
|
||||||
|
def __call__(self):
|
||||||
|
return True
|
||||||
1
core/apps/payment/views/__init__.py
Normal file
1
core/apps/payment/views/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .payment import * # noqa
|
||||||
25
core/apps/payment/views/payment.py
Normal file
25
core/apps/payment/views/payment.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
from django_core.mixins import BaseViewSetMixin
|
||||||
|
from drf_spectacular.utils import extend_schema
|
||||||
|
from rest_framework.permissions import AllowAny
|
||||||
|
from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||||
|
|
||||||
|
from core.apps.payment.models import PaymentModel
|
||||||
|
from core.apps.payment.serializers.payment import (
|
||||||
|
CreatePaymentSerializer,
|
||||||
|
ListPaymentSerializer,
|
||||||
|
RetrievePaymentSerializer,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema(tags=["payment"])
|
||||||
|
class PaymentView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||||
|
queryset = PaymentModel.objects.all()
|
||||||
|
serializer_class = ListPaymentSerializer
|
||||||
|
permission_classes = [AllowAny]
|
||||||
|
|
||||||
|
action_permission_classes = {}
|
||||||
|
action_serializer_class = {
|
||||||
|
"list": ListPaymentSerializer,
|
||||||
|
"retrieve": RetrievePaymentSerializer,
|
||||||
|
"create": CreatePaymentSerializer,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user