Update check icons in statement table

This commit is contained in:
Edgar P. Burkhart 2024-01-04 16:58:47 +01:00
parent 9d50dc7154
commit ca7cd790b5
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
5 changed files with 18 additions and 20 deletions

View file

@ -1,4 +1,4 @@
{% load main_extras category %}
{% load main_extras statement_extras %}
{% load i18n %}
<div class="plot">
<table class="full-width">

View file

@ -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")

View file

@ -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 %}

View file

@ -1,5 +1,4 @@
{% load main_extras %}
{% load i18n %}
{% load i18n main_extras statement_extras %}
<div id="statements" class="table">
<table class="full-width {% if statements_url %}more{% endif %}">
<colgroup>
@ -34,11 +33,7 @@
<tbody>
{% for snap in statements %}
<tr>
{% if snap.sum == snap.diff %}
<td class="c">{{ "check"|remix }}</td>
{% else %}
<td class="c">{{ "close"|remix }}</td>
{% endif %}
<td class="c">{{ snap.sum|check:snap.diff }}</td>
<td class="c">
{% if snap.file %}<a href="{{ snap.file.url }}">{{ "attachment"|remix }}</a>{% endif %}
</td>

View file

@ -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")