Update check icons in statement table
This commit is contained in:
parent
9d50dc7154
commit
ca7cd790b5
5 changed files with 18 additions and 20 deletions
|
@ -1,4 +1,4 @@
|
|||
{% load main_extras category %}
|
||||
{% load main_extras statement_extras %}
|
||||
{% load i18n %}
|
||||
<div class="plot">
|
||||
<table class="full-width">
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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>
|
||||
|
|
14
nummi/statement/templatetags/statement_extras.py
Normal file
14
nummi/statement/templatetags/statement_extras.py
Normal 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")
|
Loading…
Reference in a new issue