Skip to content

Commit

Permalink
Merge pull request #104 from ali-zahedi/fix/deprecate-enum
Browse files Browse the repository at this point in the history
Fix/deprecate enum
  • Loading branch information
ali-zahedi authored Mar 28, 2024
2 parents e22da64 + b614fde commit 912a8c0
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 283 deletions.
51 changes: 0 additions & 51 deletions .gitlab-ci.yml

This file was deleted.

1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ repos:
rev: 23.7.0
hooks:
- id: black
exclude: ^(.*/)?(migrations|load_geojson_data)/
args: ['--config=pyproject.toml']
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.13.0
Expand Down
278 changes: 150 additions & 128 deletions README.md

Large diffs are not rendered by default.

18 changes: 6 additions & 12 deletions azbankgateways/default_settings.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
"""Default settings for messaging."""

import django
from django.conf import settings

from azbankgateways.apps import AZIranianBankGatewaysConfig

if django.__version__ >= "3.0":
from django.db import models

TEXT_CHOICES = models.TextChoices
else:
from .models.enum_django import TextChoices

TEXT_CHOICES = TextChoices
BANK_CLASS = getattr(
settings,
"CLASS",
Expand All @@ -24,7 +16,7 @@
"ZIBAL": "azbankgateways.banks.Zibal",
"BAHAMTA": "azbankgateways.banks.Bahamta",
"MELLAT": "azbankgateways.banks.Mellat",
"PAYV1": "azbankgateways.banks.PayV1",
"PAYV1": "azbankgateways.banks.PayV1",
},
)
_AZ_IRANIAN_BANK_GATEWAYS = getattr(settings, "AZ_IRANIAN_BANK_GATEWAYS", {})
Expand All @@ -39,16 +31,18 @@
TRACKING_CODE_LENGTH = _AZ_IRANIAN_BANK_GATEWAYS.get("TRACKING_CODE_LENGTH", 16)
IS_SAMPLE_FORM_ENABLE = _AZ_IRANIAN_BANK_GATEWAYS.get("IS_SAMPLE_FORM_ENABLE", False)
IS_SAFE_GET_GATEWAY_PAYMENT = _AZ_IRANIAN_BANK_GATEWAYS.get("IS_SAFE_GET_GATEWAY_PAYMENT", False)
CUSTOM_APP = _AZ_IRANIAN_BANK_GATEWAYS.get("CUSTOM_APP", None)
CUSTOM_APP = _AZ_IRANIAN_BANK_GATEWAYS.get("CUSTOM_APP")
if CUSTOM_APP:
CALLBACK_NAMESPACE = f"{CUSTOM_APP}:{AZIranianBankGatewaysConfig.name}:callback"
GO_TO_BANK_GATEWAY_NAMESPACE = f"{CUSTOM_APP}:{AZIranianBankGatewaysConfig.name}:go-to-bank-gateway"
SAMPLE_RESULT_NAMESPACE = f"{CUSTOM_APP}:{AZIranianBankGatewaysConfig.name}:sample-result"
else:
CALLBACK_NAMESPACE = _AZ_IRANIAN_BANK_GATEWAYS.get("CALLBACK_NAMESPACE", f"{AZIranianBankGatewaysConfig.name}:callback")
CALLBACK_NAMESPACE = _AZ_IRANIAN_BANK_GATEWAYS.get(
"CALLBACK_NAMESPACE", f"{AZIranianBankGatewaysConfig.name}:callback"
)
GO_TO_BANK_GATEWAY_NAMESPACE = _AZ_IRANIAN_BANK_GATEWAYS.get(
"GO_TO_BANK_GATEWAY_NAMESPACE", f"{AZIranianBankGatewaysConfig.name}:go-to-bank-gateway"
)
SAMPLE_RESULT_NAMESPACE = _AZ_IRANIAN_BANK_GATEWAYS.get(
"SAMPLE_RESULT_NAMESPACE", f"{AZIranianBankGatewaysConfig.name}:sample-result"
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Generated by Django 5.0.3 on 2024-03-28 13:42

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('azbankgateways', '0004_auto_20211115_1500'),
]

operations = [
migrations.AlterField(
model_name='bank',
name='bank_type',
field=models.CharField(
choices=[
('BMI', 'BMI'),
('SEP', 'SEP'),
('ZARINPAL', 'Zarinpal'),
('IDPAY', 'IDPay'),
('ZIBAL', 'Zibal'),
('BAHAMTA', 'Bahamta'),
('MELLAT', 'Mellat'),
('PAYV1', 'PayV1'),
],
max_length=50,
verbose_name='Bank',
),
),
migrations.AlterField(
model_name='bank',
name='created_at',
field=models.DateTimeField(auto_now_add=True, verbose_name='Created at'),
),
migrations.AlterField(
model_name='bank',
name='status',
field=models.CharField(
choices=[
('WAITING', 'Waiting'),
('REDIRECT_TO_BANK', 'Redirect to bank'),
('RETURN_FROM_BANK', 'Return from bank'),
('CANCEL_BY_USER', 'Cancel by user'),
('EXPIRE_GATEWAY_TOKEN', 'Expire gateway token'),
('EXPIRE_VERIFY_PAYMENT', 'Expire verify payment'),
('COMPLETE', 'Complete'),
('ERROR', 'Unknown error acquired'),
],
max_length=50,
verbose_name='Status',
),
),
migrations.AlterField(
model_name='bank',
name='update_at',
field=models.DateTimeField(auto_now=True, verbose_name='Updated at'),
),
]
25 changes: 12 additions & 13 deletions azbankgateways/models/enum.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

import azbankgateways.default_settings as settings


class BankType(settings.TEXT_CHOICES):
class BankType(models.TextChoices):
BMI = "BMI", _("BMI")
SEP = "SEP", _("SEP")
ZARINPAL = "ZARINPAL", _("Zarinpal")
Expand All @@ -14,7 +13,7 @@ class BankType(settings.TEXT_CHOICES):
PAYV1 = "PAYV1", _("PayV1")


class CurrencyEnum(settings.TEXT_CHOICES):
class CurrencyEnum(models.TextChoices):
IRR = "IRR", _("Rial")
IRT = "IRT", _("Toman")

Expand All @@ -27,12 +26,12 @@ def toman_to_rial(cls, amount):
return amount * 10


class PaymentStatus(settings.TEXT_CHOICES):
WAITING = _("Waiting")
REDIRECT_TO_BANK = _("Redirect to bank")
RETURN_FROM_BANK = _("Return from bank")
CANCEL_BY_USER = _("Cancel by user")
EXPIRE_GATEWAY_TOKEN = _("Expire gateway token")
EXPIRE_VERIFY_PAYMENT = _("Expire verify payment")
COMPLETE = _("Complete")
ERROR = _("Unknown error acquired")
class PaymentStatus(models.TextChoices):
WAITING = "WAITING", _("Waiting")
REDIRECT_TO_BANK = "REDIRECT_TO_BANK", _("Redirect to bank")
RETURN_FROM_BANK = "RETURN_FROM_BANK", _("Return from bank")
CANCEL_BY_USER = "CANCEL_BY_USER", _("Cancel by user")
EXPIRE_GATEWAY_TOKEN = "EXPIRE_GATEWAY_TOKEN", _("Expire gateway token")
EXPIRE_VERIFY_PAYMENT = "EXPIRE_VERIFY_PAYMENT", _("Expire verify payment")
COMPLETE = "COMPLETE", _("Complete")
ERROR = "ERROR", _("Unknown error acquired")
77 changes: 0 additions & 77 deletions azbankgateways/models/enum_django.py

This file was deleted.

2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ include_package_data = true
zip_safe = false
install_requires =
six
Django >= 3.2, < 6
Django >= 3.0
pycryptodome >= 3.9.7
zeep

Expand Down

0 comments on commit 912a8c0

Please sign in to comment.