Skip to content
Snippets Groups Projects
Verified Commit 065d3a3c authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Move status icon to Invoice model

parent e0e17cec
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ from django.shortcuts import reverse ...@@ -6,7 +6,7 @@ from django.shortcuts import reverse
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from djmoney.models.fields import CurrencyField, MoneyField from djmoney.models.fields import CurrencyField, MoneyField
from payments import PurchasedItem from payments import PaymentStatus, PurchasedItem
from payments.models import BasePayment from payments.models import BasePayment
from aleksis.core.mixins import ExtensibleModel, PureDjangoModel from aleksis.core.mixins import ExtensibleModel, PureDjangoModel
...@@ -40,6 +40,15 @@ class Invoice(BasePayment, PureDjangoModel): ...@@ -40,6 +40,15 @@ class Invoice(BasePayment, PureDjangoModel):
"pledge": (_("Payment pledge / manual payment"), "mdi:hand-coin"), "pledge": (_("Payment pledge / manual payment"), "mdi:hand-coin"),
"sdd": (_("SEPA Direct Debit"), "mdi:bank-transfer"), "sdd": (_("SEPA Direct Debit"), "mdi:bank-transfer"),
} }
STATUS_ICONS = {
PaymentStatus.WAITING: "mdi:cash-lock-open",
PaymentStatus.INPUT: "mdi:cash-lock-open",
PaymentStatus.PREAUTH: "mdi:cash-lock",
PaymentStatus.CONFIRMED: "mdi:cash-check",
PaymentStatus.REFUNDED: "mdi:cash-refund",
PaymentStatus.REJECTED: "mdi:cash-remove",
PaymentStatus.ERROR: "mdi:cash-remove",
}
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
...@@ -64,6 +73,9 @@ class Invoice(BasePayment, PureDjangoModel): ...@@ -64,6 +73,9 @@ class Invoice(BasePayment, PureDjangoModel):
def get_variant_icon(self): def get_variant_icon(self):
return self.__class__.VARIANT_DISPLAY[self.variant][1] return self.__class__.VARIANT_DISPLAY[self.variant][1]
def get_status_icon(self):
return self.__class__.STATUS_ICONS[self.status]
def get_purchased_items(self): def get_purchased_items(self):
return self.for_object.get_purchased_items() return self.for_object.get_purchased_items()
......
...@@ -72,17 +72,7 @@ ...@@ -72,17 +72,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
{% if object.status == "waiting" or object.status == "input" %} <i class="material-icons iconify" data-icon="object.get_status_icon"></i>
<i class="material-icons iconify" data-icon="mdi:cash-lock-open"></i>
{% elif object.status == "rejected" or object.status == "error" %}
<i class="material-icons iconify" data-icon="mdi:cash-remove"></i>
{% elif object.status == "preauth" %}
<i class="material-icons iconify" data-icon="mdi:cash-lock"></i>
{% elif object.status == "confirmed" %}
<i class="material-icons iconify" data-icon="mdi:cash-check"></i>
{% elif object.status == "refunded" %}
<i class="material-icons iconify" data-icon="mdi:cash-refund"></i>
{% endif %}
</td> </td>
<td> <td>
{{ object.get_status_display }} {{ object.get_status_display }}
......
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