Render payment method details.
This commit is contained in:
parent
ff481b6317
commit
37c9183c1e
|
@ -1,7 +1,13 @@
|
||||||
|
import ast
|
||||||
|
import logging
|
||||||
|
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class OrchestraModel:
|
class OrchestraModel:
|
||||||
""" Base class from which all orchestra models will inherit. """
|
""" Base class from which all orchestra models will inherit. """
|
||||||
api_name = None
|
api_name = None
|
||||||
|
@ -16,9 +22,6 @@ class OrchestraModel:
|
||||||
for (param, default) in self.param_defaults.items():
|
for (param, default) in self.param_defaults.items():
|
||||||
setattr(self, param, kwargs.get(param, default))
|
setattr(self, param, kwargs.get(param, default))
|
||||||
|
|
||||||
# def get(self, key):
|
|
||||||
# # retrieve attr of the object and if undefined get raw data
|
|
||||||
# return getattr(self, key, self.data.get(key))
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new_from_json(cls, data, **kwargs):
|
def new_from_json(cls, data, **kwargs):
|
||||||
|
@ -35,8 +38,7 @@ class OrchestraModel:
|
||||||
|
|
||||||
c = cls(**json_data)
|
c = cls(**json_data)
|
||||||
c._json = data
|
c._json = data
|
||||||
# TODO(@slamora) remove/replace by private variable to ovoid name collisions
|
|
||||||
c.data = data
|
|
||||||
return c
|
return c
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -65,6 +67,15 @@ class PaymentSource(OrchestraModel):
|
||||||
"is_active": False,
|
"is_active": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
# payment details are passed as a plain string
|
||||||
|
# try to convert to a python structure
|
||||||
|
try:
|
||||||
|
self.data = ast.literal_eval(self.data)
|
||||||
|
except (ValueError, SyntaxError) as e:
|
||||||
|
logger.error(e)
|
||||||
|
|
||||||
|
|
||||||
class UserAccount(OrchestraModel):
|
class UserAccount(OrchestraModel):
|
||||||
api_name = 'accounts'
|
api_name = 'accounts'
|
||||||
|
|
|
@ -48,8 +48,12 @@
|
||||||
payment method: {{ payment.method }}
|
payment method: {{ payment.method }}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{# TODO(@slamora) format payment method details #}
|
{% if payment.method == 'SEPADirectDebit' %}
|
||||||
{{ payment.data.data }}
|
IBAN {{ payment.data.iban }}
|
||||||
|
{% else %}
|
||||||
|
{# <!-- "TODO handle Credit Card" --> #}
|
||||||
|
Details: {{ payment.data }}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue