Features: 1) Add Gateway model with fields for UUID, activation status, currency details, limits, and integration variables; 2) Add gateway foreign key to Transaction model; 3) Introduce is_static_page field to Post model to differentiate static pages; 4) Add integration_path field to Vendor model.
Fixes: 1) Correct import order in `payments.admin`. Extra: 1) Update `productimage.priority` field in `core` app with default value and help text; 2) Include `integration_path` in `Vendor` admin additional fields.
This commit is contained in:
parent
3b7c405e84
commit
a87cb31d7e
5 changed files with 213 additions and 1 deletions
22
blog/migrations/0007_post_is_static_page.py
Normal file
22
blog/migrations/0007_post_is_static_page.py
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Generated by Django 5.2 on 2025-10-21 09:24
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("blog", "0006_post_meta_description_post_meta_description_ar_ar_and_more"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="post",
|
||||||
|
name="is_static_page",
|
||||||
|
field=models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
help_text="is this a post for a page with static URL (e.g. `/help/delivery`)?",
|
||||||
|
verbose_name="is static page",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -518,6 +518,7 @@ class VendorAdmin(FieldsetsMixin, ActivationActionsMixin, ModelAdmin): # type:
|
||||||
"users",
|
"users",
|
||||||
]
|
]
|
||||||
additional_fields = [
|
additional_fields = [
|
||||||
|
"integration_path",
|
||||||
"last_processing_response",
|
"last_processing_response",
|
||||||
"b2b_auth_token",
|
"b2b_auth_token",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
# Generated by Django 5.2 on 2025-10-21 09:24
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("core", "0047_alter_attribute_unique_together"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="vendor",
|
||||||
|
name="integration_path",
|
||||||
|
field=models.CharField(
|
||||||
|
blank=True,
|
||||||
|
help_text="vendor's integration file path",
|
||||||
|
max_length=255,
|
||||||
|
null=True,
|
||||||
|
verbose_name="integration path",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="productimage",
|
||||||
|
name="priority",
|
||||||
|
field=models.PositiveIntegerField(
|
||||||
|
default=1,
|
||||||
|
help_text="determines the order in which images are displayed",
|
||||||
|
verbose_name="display priority",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -5,7 +5,7 @@ from django.http import HttpRequest
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from core.admin import ActivationActionsMixin
|
from core.admin import ActivationActionsMixin
|
||||||
from payments.forms import TransactionForm, GatewayForm
|
from payments.forms import GatewayForm, TransactionForm
|
||||||
from payments.models import Balance, Transaction
|
from payments.models import Balance, Transaction
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
156
payments/migrations/0005_gateway_transaction_gateway.py
Normal file
156
payments/migrations/0005_gateway_transaction_gateway.py
Normal file
|
|
@ -0,0 +1,156 @@
|
||||||
|
# Generated by Django 5.2 on 2025-10-21 09:24
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django_extensions.db.fields
|
||||||
|
import uuid
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("payments", "0004_alter_transaction_payment_method"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="Gateway",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"uuid",
|
||||||
|
models.UUIDField(
|
||||||
|
default=uuid.uuid4,
|
||||||
|
editable=False,
|
||||||
|
help_text="unique id is used to surely identify any database object",
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="unique id",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"is_active",
|
||||||
|
models.BooleanField(
|
||||||
|
default=True,
|
||||||
|
help_text="if set to false, this object can't be seen by users without needed permission",
|
||||||
|
verbose_name="is active",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"created",
|
||||||
|
django_extensions.db.fields.CreationDateTimeField(
|
||||||
|
auto_now_add=True,
|
||||||
|
help_text="when the object first appeared on the database",
|
||||||
|
verbose_name="created",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"modified",
|
||||||
|
django_extensions.db.fields.ModificationDateTimeField(
|
||||||
|
auto_now=True,
|
||||||
|
help_text="when the object was last modified",
|
||||||
|
verbose_name="modified",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("name", models.CharField(max_length=20, verbose_name="name")),
|
||||||
|
(
|
||||||
|
"default_currency",
|
||||||
|
models.CharField(
|
||||||
|
choices=[
|
||||||
|
("AED", "د.إ"),
|
||||||
|
("BRL", "R$"),
|
||||||
|
("CNY", "¥"),
|
||||||
|
("CZK", "Kč"),
|
||||||
|
("DKK", "kr"),
|
||||||
|
("EUR", "€"),
|
||||||
|
("GBP", "£"),
|
||||||
|
("IDR", "Rp"),
|
||||||
|
("ILS", "₪"),
|
||||||
|
("INR", "₹"),
|
||||||
|
("IRR", "﷼"),
|
||||||
|
("JPY", "¥"),
|
||||||
|
("KRW", "₩"),
|
||||||
|
("KZT", "₸"),
|
||||||
|
("NOK", "kr"),
|
||||||
|
("PLN", "zł"),
|
||||||
|
("RON", "lei"),
|
||||||
|
("RUB", "₽"),
|
||||||
|
("SEK", "kr"),
|
||||||
|
("THB", "฿"),
|
||||||
|
("TRY", "₺"),
|
||||||
|
("USD", "$"),
|
||||||
|
("VND", "₫"),
|
||||||
|
],
|
||||||
|
max_length=4,
|
||||||
|
verbose_name="default currency",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"currencies",
|
||||||
|
models.CharField(
|
||||||
|
help_text="comma separated list of currencies supported by this gateway, choose from AED, BRL, CNY, CZK, DKK, EUR, GBP, IDR, ILS, INR, IRR, JPY, KRW, KZT, NOK, PLN, RON, RUB, SEK, THB, TRY, USD, VND",
|
||||||
|
max_length=255,
|
||||||
|
verbose_name="currencies",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"integration_path",
|
||||||
|
models.CharField(blank=True, max_length=255, null=True),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"minimum_transaction_amount",
|
||||||
|
models.FloatField(
|
||||||
|
default=0, verbose_name="minimum transaction amount"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"maximum_transaction_amount",
|
||||||
|
models.FloatField(
|
||||||
|
default=0, verbose_name="maximum transaction amount"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"daily_limit",
|
||||||
|
models.PositiveIntegerField(
|
||||||
|
default=0,
|
||||||
|
help_text="daily sum limit of transactions' amounts. 0 means no limit",
|
||||||
|
verbose_name="daily limit",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"monthly_limit",
|
||||||
|
models.PositiveIntegerField(
|
||||||
|
default=0,
|
||||||
|
help_text="monthly sum limit of transactions' amounts. 0 means no limit",
|
||||||
|
verbose_name="monthly limit",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"priority",
|
||||||
|
models.PositiveIntegerField(
|
||||||
|
default=10, unique=True, verbose_name="priority"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"integration_variables",
|
||||||
|
models.JSONField(
|
||||||
|
default=dict, verbose_name="integration variables"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"verbose_name": "payment gateway",
|
||||||
|
"verbose_name_plural": "payment gateways",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="transaction",
|
||||||
|
name="gateway",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="transactions",
|
||||||
|
to="payments.gateway",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
Loading…
Reference in a new issue