Fixes: 1) Validate gateway presence in `process_transaction_changes` signal; 2) Add missing imports for `Type`, `create_object`, and `AbstractGateway`; Extra: 1) Cleanup unused diff lines in migrations files; 2) Improve JSONField, FloatField, and PositiveIntegerField declarations by consolidating into single lines; 3) Remove redundant match-case logic in `signals.py`.
147 lines
5.6 KiB
Python
147 lines
5.6 KiB
Python
# 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",
|
|
),
|
|
),
|
|
]
|