From ca7cd790b51045ab9743d00dc39f998794cd0ddc Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Thu, 4 Jan 2024 16:58:47 +0100 Subject: [PATCH] Update check icons in statement table --- .../category/templates/category/category_plot.html | 2 +- nummi/category/templatetags/category.py | 11 ----------- .../templates/statement/statement_form.html | 2 +- .../templates/statement/statement_table.html | 9 ++------- nummi/statement/templatetags/statement_extras.py | 14 ++++++++++++++ 5 files changed, 18 insertions(+), 20 deletions(-) create mode 100644 nummi/statement/templatetags/statement_extras.py diff --git a/nummi/category/templates/category/category_plot.html b/nummi/category/templates/category/category_plot.html index c152c10..2b76bc5 100644 --- a/nummi/category/templates/category/category_plot.html +++ b/nummi/category/templates/category/category_plot.html @@ -1,4 +1,4 @@ -{% load main_extras category %} +{% load main_extras statement_extras %} {% load i18n %}
diff --git a/nummi/category/templatetags/category.py b/nummi/category/templatetags/category.py index aaf3bf9..b085bf2 100644 --- a/nummi/category/templatetags/category.py +++ b/nummi/category/templatetags/category.py @@ -1,7 +1,6 @@ from django import template from django.db import models from django.db.models.functions import Greatest -from main.templatetags.main_extras import remix register = template.Library() @@ -31,13 +30,3 @@ def category_plot(transactions, budget=True, **kwargs): total=models.Sum("sum"), ) ) - - -@register.filter -def check(s, diff): - if s is None: - s = 0 - if s == diff: - return remix("check", "green") - else: - return remix("close", "red") diff --git a/nummi/statement/templates/statement/statement_form.html b/nummi/statement/templates/statement/statement_form.html index f5e04c8..cfe210b 100644 --- a/nummi/statement/templates/statement/statement_form.html +++ b/nummi/statement/templates/statement/statement_form.html @@ -1,5 +1,5 @@ {% extends "main/form/base.html" %} -{% load i18n main_extras category %} +{% load i18n main_extras statement_extras category %} {% block title_new %} {% translate "Create statement" %} {% endblock %} diff --git a/nummi/statement/templates/statement/statement_table.html b/nummi/statement/templates/statement/statement_table.html index 514dc16..32a83f3 100644 --- a/nummi/statement/templates/statement/statement_table.html +++ b/nummi/statement/templates/statement/statement_table.html @@ -1,5 +1,4 @@ -{% load main_extras %} -{% load i18n %} +{% load i18n main_extras statement_extras %}
@@ -34,11 +33,7 @@ {% for snap in statements %} - {% if snap.sum == snap.diff %} - - {% else %} - - {% endif %} + diff --git a/nummi/statement/templatetags/statement_extras.py b/nummi/statement/templatetags/statement_extras.py new file mode 100644 index 0000000..a8631d1 --- /dev/null +++ b/nummi/statement/templatetags/statement_extras.py @@ -0,0 +1,14 @@ +from django import template +from main.templatetags.main_extras import remix + +register = template.Library() + + +@register.filter +def check(s, diff): + if s is None: + s = 0 + if s == diff: + return remix("check", "green") + else: + return remix("close", "red")
{{ "check"|remix }}{{ "close"|remix }}{{ snap.sum|check:snap.diff }} {% if snap.file %}{{ "attachment"|remix }}{% endif %}