diff --git a/aleksis/apps/tezor/models/invoice.py b/aleksis/apps/tezor/models/invoice.py index 84b44135a91e478dda880bbaa7ae4be0848f23f6..2cdc04ad4039012177bed15729d2edb88982c0e8 100644 --- a/aleksis/apps/tezor/models/invoice.py +++ b/aleksis/apps/tezor/models/invoice.py @@ -33,6 +33,13 @@ class InvoiceGroup(ExtensibleModel): 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( InvoiceGroup, verbose_name=_("Invoice group"), related_name="invoices", on_delete=models.SET_NULL, null=True ) @@ -43,6 +50,12 @@ class Invoice(BasePayment, PureDjangoModel): for_object_id = models.PositiveIntegerField() 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): return self.for_object.get_purchased_items() diff --git a/aleksis/apps/tezor/templates/tezor/invoice/full.html b/aleksis/apps/tezor/templates/tezor/invoice/full.html index 955d195353ea012175bf3496c65a5ca20ccea699..e8fc99bf2d5aab51bd8fa484da7f873ba316d4d6 100644 --- a/aleksis/apps/tezor/templates/tezor/invoice/full.html +++ b/aleksis/apps/tezor/templates/tezor/invoice/full.html @@ -64,14 +64,10 @@ <table class="highlight"> <tr> <td> - {% if object.variant == "paypal" %} - <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 %} + <i class="material-icons iconify" data-icon="{{ object.get_variant_icon }}"></i> </td> <td> - {{ object.variant }} + {{ object.get_variant_name }} </td> </tr> <tr>