Skip to content
Snippets Groups Projects
Commit 1751df82 authored by Nik | Klampfradler's avatar Nik | Klampfradler Committed by Tom Teichler
Browse files

Move payment variant icon/name lookup to model

parent 62f81689
No related branches found
No related tags found
2 merge requests!9Resolve "Add payment processing UI",!3Implement payment backends and interaction
Pipeline #59253 failed
...@@ -33,6 +33,13 @@ class InvoiceGroup(ExtensibleModel): ...@@ -33,6 +33,13 @@ class InvoiceGroup(ExtensibleModel):
class Invoice(BasePayment, PureDjangoModel): class Invoice(BasePayment, PureDjangoModel):
VARIANT_DISPLAY = {
"paypal": (_("PayPal"), "logos:paypal"),
"sofort": (_("Klarna / Sofort"), "simple-icons:klarna"),
"pledge": (_("Payment pledge / manual payment"), "mdi:hand-coin"),
"sdd": (_("SEPA Direct Debit"), "mdi:bank-transfer"),
}
group = models.ForeignKey( group = models.ForeignKey(
InvoiceGroup, verbose_name=_("Invoice group"), related_name="invoices", on_delete=models.SET_NULL, null=True InvoiceGroup, verbose_name=_("Invoice group"), related_name="invoices", on_delete=models.SET_NULL, null=True
) )
...@@ -43,6 +50,12 @@ class Invoice(BasePayment, PureDjangoModel): ...@@ -43,6 +50,12 @@ class Invoice(BasePayment, PureDjangoModel):
for_object_id = models.PositiveIntegerField() for_object_id = models.PositiveIntegerField()
for_object = GenericForeignKey("for_content_type", "for_object_id") for_object = GenericForeignKey("for_content_type", "for_object_id")
def get_variant_name(self):
return self.__class__.VARIANT_DISPLAY[self.variant][0]
def get_variant_icon(self):
return self.__class__.VARIANT_DISPLAY[self.variant][1]
def get_purchased_items(self): def get_purchased_items(self):
return self.for_object.get_purchased_items() return self.for_object.get_purchased_items()
......
...@@ -64,14 +64,10 @@ ...@@ -64,14 +64,10 @@
<table class="highlight"> <table class="highlight">
<tr> <tr>
<td> <td>
{% if object.variant == "paypal" %} <i class="material-icons iconify" data-icon="{{ object.get_variant_icon }}"></i>
<i class="material-icons iconify" data-icon="logos:paypal"></i>
{% elif object.variant == "sofort" %}
<i class="material-icons iconify" data-icon="simple-icons:klarna"></i>
{% endif %}
</td> </td>
<td> <td>
{{ object.variant }} {{ object.get_variant_name }}
</td> </td>
</tr> </tr>
<tr> <tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment