Update tables to hide redundant fields

Closes #7
This commit is contained in:
Edgar P. Burkhart 2023-01-01 10:36:40 +01:00
parent 695e1d4d52
commit 63253526fa
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
3 changed files with 54 additions and 41 deletions

View file

@ -1,13 +1,14 @@
{% load main_extras %} {% load main_extras %}
{% load i18n %} {% load i18n %}
<div id="snapshots" class="table {% if account %}col2-4{% else %}col2-5{% endif %}"> <div id="snapshots"
class="table {% if account %}col2-4{% else %}col2-5{% endif %}">
<div class="header"> <div class="header">
<strong class="diff center"><i class="fa fa-check"></i></strong> <strong class="diff center"><i class="fa fa-check"></i></strong>
<strong class="attach center"><i class="fa fa-paperclip"></i></strong> <strong class="attach center"><i class="fa fa-paperclip"></i></strong>
<strong class="date center">{% translate "Date" %}</strong> <strong class="date center">{% translate "Date" %}</strong>
{% if not account %} {% if not account %}
<strong class="account center">{% translate "Account" %}</strong> <strong class="account center">{% translate "Account" %}</strong>
{% endif %} {% endif %}
<strong class="value center">{% translate "Value" %}</strong> <strong class="value center">{% translate "Value" %}</strong>
<strong class="diff center">{% translate "Difference" %}</strong> <strong class="diff center">{% translate "Difference" %}</strong>
<strong class="diff center">{% translate "Transactions" %}</strong> <strong class="diff center">{% translate "Transactions" %}</strong>
@ -19,13 +20,13 @@
{% endif %} {% endif %}
{% for snap in snapshots %} {% for snap in snapshots %}
<div class="snapshot"> <div class="snapshot">
<span class="valid center"> <span class="valid center">
{% if snap.sum == snap.diff %} {% if snap.sum == snap.diff %}
<i class="fa fa-check green"></i> <i class="fa fa-check green"></i>
{% else %} {% else %}
<i class="fa fa-xmark red"></i> <i class="fa fa-xmark red"></i>
{% endif %} {% endif %}
</span> </span>
<span class="attach center"> <span class="attach center">
{% if snap.file %} {% if snap.file %}
<a href="{{ snap.file.url }}"> <a href="{{ snap.file.url }}">
@ -36,15 +37,15 @@
<span class="date num center"> <span class="date num center">
<a href="{% url 'snapshot' pk=snap.id %}">{{ snap.date|date:"Y-m-d" }}</a> <a href="{% url 'snapshot' pk=snap.id %}">{{ snap.date|date:"Y-m-d" }}</a>
</span> </span>
{% if not account %} {% if not account %}
<span class="account text center"> <span class="account text center">
<i class="fa fa-{{ snap.account.icon }}"></i> <i class="fa fa-{{ snap.account.icon }}"></i>
<a href="{% url 'account' pk=snap.account.id %}">{{ snap.account }}</a> <a href="{% url 'account' pk=snap.account.id %}">{{ snap.account }}</a>
</span> </span>
{% endif %} {% endif %}
<span class="value num right">{{ snap.value|value }}</span> <span class="value num right">{{ snap.value|value }}</span>
<span class="diff num right">{{ snap.diff|pmvalue }}</span> <span class="diff num right">{{ snap.diff|pmvalue }}</span>
<span class="sum num right">{{ snap.sum|pmvalue }}</span> <span class="sum num right">{{ snap.sum|pmvalue }}</span>
</div> </div>
{% endfor %} {% endfor %}
{% if snapshots_url %} {% if snapshots_url %}

View file

@ -1,14 +1,19 @@
{% load main_extras %} {% load main_extras %}
{% load i18n %} {% load i18n %}
<div id="transactions" class="table col1-7"> <div id="transactions"
class="table col1-{% if account or category %}6{% else %}7{% endif %}">
<div class="header"> <div class="header">
<strong class="attach center"><i class="fa fa-paperclip"></i></strong> <strong class="attach center"><i class="fa fa-paperclip"></i></strong>
<strong class="date center">{% translate "Date" %}</strong> <strong class="date center">{% translate "Date" %}</strong>
<strong class="name">{% translate "Name" %}</strong> <strong class="name">{% translate "Name" %}</strong>
<strong class="value center">{% translate "Value" %}</strong> <strong class="value center">{% translate "Value" %}</strong>
<strong class="trader center">{% translate "Trader" %}</strong> <strong class="trader center">{% translate "Trader" %}</strong>
<strong class="category center">{% translate "Category" %}</strong> {% if not category %}
<strong class="account center">{% translate "Account" %}</strong> <strong class="category center">{% translate "Category" %}</strong>
{% endif %}
{% if not account %}
<strong class="account center">{% translate "Account" %}</strong>
{% endif %}
<strong class="description">{% translate "Description" %}</strong> <strong class="description">{% translate "Description" %}</strong>
</div> </div>
{% if new_transaction_url %} {% if new_transaction_url %}
@ -31,22 +36,26 @@
<span class="name text"><a href="{% url 'transaction' pk=trans.id %}">{{ trans.name }}</a></span> <span class="name text"><a href="{% url 'transaction' pk=trans.id %}">{{ trans.name }}</a></span>
<span class="value num right">{{ trans.value|pmvalue }}</span> <span class="value num right">{{ trans.value|pmvalue }}</span>
<span class="trader text center">{{ trans.trader|default_if_none:"" }}</span> <span class="trader text center">{{ trans.trader|default_if_none:"" }}</span>
<span class="category text center"> {% if not category %}
{% if trans.category %} <span class="category text center">
<i class="fa fa-{{ trans.category.icon }}"></i> {% if trans.category %}
<a href="{% url 'category' pk=trans.category.id %}">{{ trans.category }}</a> <i class="fa fa-{{ trans.category.icon }}"></i>
{% else %} <a href="{% url 'category' pk=trans.category.id %}">{{ trans.category }}</a>
{% else %}
{% endif %}
</span> {% endif %}
<span class="account text center"> </span>
{% if trans.account %} {% endif %}
<i class="fa fa-{{ trans.account.icon }}"></i> {% if not account %}
<a href="{% url 'account' pk=trans.account.id %}">{{ trans.account }}</a> <span class="account text center">
{% else %} {% if trans.account %}
<i class="fa fa-{{ trans.account.icon }}"></i>
{% endif %} <a href="{% url 'account' pk=trans.account.id %}">{{ trans.account }}</a>
</span> {% else %}
{% endif %}
</span>
{% endif %}
<span class="description text">{{ trans.description }}</span> <span class="description text">{{ trans.description }}</span>
</div> </div>
{% endfor %} {% endfor %}

View file

@ -288,7 +288,8 @@ class AccountMixin:
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
return super().get_context_data(**kwargs) | { return super().get_context_data(**kwargs) | {
"object": Account.objects.get(pk=self.kwargs.get("pk")) "object": Account.objects.get(pk=self.kwargs.get("pk")),
"account": True,
} }
@ -298,7 +299,8 @@ class SnapshotMixin:
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
return super().get_context_data(**kwargs) | { return super().get_context_data(**kwargs) | {
"object": Snapshot.objects.get(pk=self.kwargs.get("pk")) "object": Snapshot.objects.get(pk=self.kwargs.get("pk")),
"snapshot": True,
} }
@ -308,7 +310,8 @@ class CategoryMixin:
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
return super().get_context_data(**kwargs) | { return super().get_context_data(**kwargs) | {
"object": Category.objects.get(pk=self.kwargs.get("pk")) "object": Category.objects.get(pk=self.kwargs.get("pk")),
"category": True,
} }