Skip to content

Commit

Permalink
fix: remove deprecated enum
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-zahedi committed Mar 28, 2024
1 parent 17f86c2 commit b614fde
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 94 deletions.
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"
)
)
9 changes: 4 additions & 5 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,7 +26,7 @@ def toman_to_rial(cls, amount):
return amount * 10


class PaymentStatus(settings.TEXT_CHOICES):
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")
Expand Down
77 changes: 0 additions & 77 deletions azbankgateways/models/enum_django.py

This file was deleted.

0 comments on commit b614fde

Please sign in to comment.