From a6d7fa8c9adc36d4e00ba636aac505db24cf44a9 Mon Sep 17 00:00:00 2001 From: Husanjonazamov Date: Wed, 18 Feb 2026 18:06:42 +0500 Subject: [PATCH] payment modeli yaratildi --- MODELS.md | 32 ++++++ config/conf/modules.py | 2 +- config/urls.py | 3 +- core/apps/payment/__init__.py | 0 core/apps/payment/admin/__init__.py | 1 + core/apps/payment/admin/payment.py | 12 +++ core/apps/payment/apps.py | 6 ++ core/apps/payment/enums/__init__.py | 1 + core/apps/payment/enums/payment.py | 20 ++++ core/apps/payment/filters/__init__.py | 1 + core/apps/payment/filters/payment.py | 13 +++ core/apps/payment/forms/__init__.py | 1 + core/apps/payment/forms/payment.py | 10 ++ core/apps/payment/migrations/0001_initial.py | 40 +++++++ core/apps/payment/migrations/__init__.py | 0 core/apps/payment/models/__init__.py | 1 + core/apps/payment/models/payment.py | 69 ++++++++++++ core/apps/payment/permissions/__init__.py | 1 + core/apps/payment/permissions/payment.py | 12 +++ core/apps/payment/serializers/__init__.py | 1 + .../payment/serializers/payment/__init__.py | 1 + .../payment/serializers/payment/payment.py | 28 +++++ core/apps/payment/signals/__init__.py | 1 + core/apps/payment/signals/payment.py | 8 ++ core/apps/payment/tests/__init__.py | 1 + core/apps/payment/tests/payment/__init__.py | 1 + .../payment/tests/payment/test_payment.py | 101 ++++++++++++++++++ core/apps/payment/translation/__init__.py | 1 + core/apps/payment/translation/payment.py | 8 ++ core/apps/payment/urls.py | 8 ++ core/apps/payment/validators/__init__.py | 1 + core/apps/payment/validators/payment.py | 8 ++ core/apps/payment/views/__init__.py | 1 + core/apps/payment/views/payment.py | 25 +++++ 34 files changed, 417 insertions(+), 2 deletions(-) create mode 100644 MODELS.md create mode 100644 core/apps/payment/__init__.py create mode 100644 core/apps/payment/admin/__init__.py create mode 100644 core/apps/payment/admin/payment.py create mode 100644 core/apps/payment/apps.py create mode 100644 core/apps/payment/enums/__init__.py create mode 100644 core/apps/payment/enums/payment.py create mode 100644 core/apps/payment/filters/__init__.py create mode 100644 core/apps/payment/filters/payment.py create mode 100644 core/apps/payment/forms/__init__.py create mode 100644 core/apps/payment/forms/payment.py create mode 100644 core/apps/payment/migrations/0001_initial.py create mode 100644 core/apps/payment/migrations/__init__.py create mode 100644 core/apps/payment/models/__init__.py create mode 100644 core/apps/payment/models/payment.py create mode 100644 core/apps/payment/permissions/__init__.py create mode 100644 core/apps/payment/permissions/payment.py create mode 100644 core/apps/payment/serializers/__init__.py create mode 100644 core/apps/payment/serializers/payment/__init__.py create mode 100644 core/apps/payment/serializers/payment/payment.py create mode 100644 core/apps/payment/signals/__init__.py create mode 100644 core/apps/payment/signals/payment.py create mode 100644 core/apps/payment/tests/__init__.py create mode 100644 core/apps/payment/tests/payment/__init__.py create mode 100644 core/apps/payment/tests/payment/test_payment.py create mode 100644 core/apps/payment/translation/__init__.py create mode 100644 core/apps/payment/translation/payment.py create mode 100644 core/apps/payment/urls.py create mode 100644 core/apps/payment/validators/__init__.py create mode 100644 core/apps/payment/validators/payment.py create mode 100644 core/apps/payment/views/__init__.py create mode 100644 core/apps/payment/views/payment.py diff --git a/MODELS.md b/MODELS.md new file mode 100644 index 0000000..58d0f0d --- /dev/null +++ b/MODELS.md @@ -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. ✅ diff --git a/config/conf/modules.py b/config/conf/modules.py index 9ef1c3d..19b0ce9 100644 --- a/config/conf/modules.py +++ b/config/conf/modules.py @@ -1 +1 @@ -MODULES = ["core.apps.shared", "core.apps.evaluation"] +MODULES = ["core.apps.shared", "core.apps.evaluation", "core.apps.payment"] diff --git a/config/urls.py b/config/urls.py index d9a4abd..8e6fbfe 100644 --- a/config/urls.py +++ b/config/urls.py @@ -20,7 +20,8 @@ urlpatterns = [ path("health/", home), path("api/v1/", include("core.apps.accounts.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 += [ path("admin/", admin.site.urls), diff --git a/core/apps/payment/__init__.py b/core/apps/payment/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/apps/payment/admin/__init__.py b/core/apps/payment/admin/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/admin/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/admin/payment.py b/core/apps/payment/admin/payment.py new file mode 100644 index 0000000..634b67b --- /dev/null +++ b/core/apps/payment/admin/payment.py @@ -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__", + ) diff --git a/core/apps/payment/apps.py b/core/apps/payment/apps.py new file mode 100644 index 0000000..6d9aa09 --- /dev/null +++ b/core/apps/payment/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ModuleConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "core.apps.payment" diff --git a/core/apps/payment/enums/__init__.py b/core/apps/payment/enums/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/enums/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/enums/payment.py b/core/apps/payment/enums/payment.py new file mode 100644 index 0000000..8aa9522 --- /dev/null +++ b/core/apps/payment/enums/payment.py @@ -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") diff --git a/core/apps/payment/filters/__init__.py b/core/apps/payment/filters/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/filters/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/filters/payment.py b/core/apps/payment/filters/payment.py new file mode 100644 index 0000000..75a7064 --- /dev/null +++ b/core/apps/payment/filters/payment.py @@ -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", + ] diff --git a/core/apps/payment/forms/__init__.py b/core/apps/payment/forms/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/forms/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/forms/payment.py b/core/apps/payment/forms/payment.py new file mode 100644 index 0000000..03c382d --- /dev/null +++ b/core/apps/payment/forms/payment.py @@ -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__" diff --git a/core/apps/payment/migrations/0001_initial.py b/core/apps/payment/migrations/0001_initial.py new file mode 100644 index 0000000..bf6af80 --- /dev/null +++ b/core/apps/payment/migrations/0001_initial.py @@ -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'], + }, + ), + ] diff --git a/core/apps/payment/migrations/__init__.py b/core/apps/payment/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/apps/payment/models/__init__.py b/core/apps/payment/models/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/models/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/models/payment.py b/core/apps/payment/models/payment.py new file mode 100644 index 0000000..f5639ac --- /dev/null +++ b/core/apps/payment/models/payment.py @@ -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"] diff --git a/core/apps/payment/permissions/__init__.py b/core/apps/payment/permissions/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/permissions/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/permissions/payment.py b/core/apps/payment/permissions/payment.py new file mode 100644 index 0000000..4c61e32 --- /dev/null +++ b/core/apps/payment/permissions/payment.py @@ -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 diff --git a/core/apps/payment/serializers/__init__.py b/core/apps/payment/serializers/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/serializers/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/serializers/payment/__init__.py b/core/apps/payment/serializers/payment/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/serializers/payment/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/serializers/payment/payment.py b/core/apps/payment/serializers/payment/payment.py new file mode 100644 index 0000000..390509b --- /dev/null +++ b/core/apps/payment/serializers/payment/payment.py @@ -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", + ] diff --git a/core/apps/payment/signals/__init__.py b/core/apps/payment/signals/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/signals/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/signals/payment.py b/core/apps/payment/signals/payment.py new file mode 100644 index 0000000..ebd6f6c --- /dev/null +++ b/core/apps/payment/signals/payment.py @@ -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): ... diff --git a/core/apps/payment/tests/__init__.py b/core/apps/payment/tests/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/tests/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/tests/payment/__init__.py b/core/apps/payment/tests/payment/__init__.py new file mode 100644 index 0000000..517d443 --- /dev/null +++ b/core/apps/payment/tests/payment/__init__.py @@ -0,0 +1 @@ +from .test_payment import * # noqa diff --git a/core/apps/payment/tests/payment/test_payment.py b/core/apps/payment/tests/payment/test_payment.py new file mode 100644 index 0000000..53a7023 --- /dev/null +++ b/core/apps/payment/tests/payment/test_payment.py @@ -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 diff --git a/core/apps/payment/translation/__init__.py b/core/apps/payment/translation/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/translation/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/translation/payment.py b/core/apps/payment/translation/payment.py new file mode 100644 index 0000000..e78b33e --- /dev/null +++ b/core/apps/payment/translation/payment.py @@ -0,0 +1,8 @@ +from modeltranslation.translator import TranslationOptions, register + +from core.apps.payment.models import PaymentModel + + +@register(PaymentModel) +class PaymentTranslation(TranslationOptions): + fields = [] diff --git a/core/apps/payment/urls.py b/core/apps/payment/urls.py new file mode 100644 index 0000000..9c62028 --- /dev/null +++ b/core/apps/payment/urls.py @@ -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))] diff --git a/core/apps/payment/validators/__init__.py b/core/apps/payment/validators/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/validators/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/validators/payment.py b/core/apps/payment/validators/payment.py new file mode 100644 index 0000000..78661df --- /dev/null +++ b/core/apps/payment/validators/payment.py @@ -0,0 +1,8 @@ +# from django.core.exceptions import ValidationError + + +class PaymentValidator: + def __init__(self): ... + + def __call__(self): + return True diff --git a/core/apps/payment/views/__init__.py b/core/apps/payment/views/__init__.py new file mode 100644 index 0000000..79db684 --- /dev/null +++ b/core/apps/payment/views/__init__.py @@ -0,0 +1 @@ +from .payment import * # noqa diff --git a/core/apps/payment/views/payment.py b/core/apps/payment/views/payment.py new file mode 100644 index 0000000..99a2590 --- /dev/null +++ b/core/apps/payment/views/payment.py @@ -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, + }