diff --git a/nummi/history/templates/history/plot.html b/nummi/history/templates/history/plot.html index 3f0b456..16e2b94 100644 --- a/nummi/history/templates/history/plot.html +++ b/nummi/history/templates/history/plot.html @@ -41,7 +41,9 @@ {{ date.sum_m|pmrvalue }} -
+ {% if date.sum_m %} +
+ {% endif %} {% if date.sum < 0 %}
{{ date.sum|pmrvalue }} @@ -49,7 +51,9 @@ {% endif %} -
+ {% if date.sum_p %} +
+ {% endif %} {% if date.sum > 0 %}
{{ date.sum|pmrvalue }} @@ -60,7 +64,7 @@ {% else %} - + {% endif %} {% endfor %} @@ -94,6 +98,9 @@ {{ year.y }} {% for m in year.d %} + {% if forloop.parentloop.last and forloop.first %} + {% for _ in history.offset.0 %}{% endfor %} + {% endif %} {% if m %} @@ -101,6 +108,9 @@ {% else %} {% endif %} + {% if forloop.parentloop.first and forloop.last %} + {% for _ in history.offset.1 %}{% endfor %} + {% endif %} {% endfor %} {% endfor %} @@ -108,4 +118,3 @@
-{{ history.years|json_script }} diff --git a/nummi/history/utils.py b/nummi/history/utils.py index 2af095f..282d354 100644 --- a/nummi/history/utils.py +++ b/nummi/history/utils.py @@ -26,23 +26,26 @@ def history(transaction_set): has_transactions=Value(1), ).order_by("-month") + _data = [ + { + "y": y, + "d": [ + _history.filter(month=datetime.date(y, m + 1, 1)).first() + for m in range( + _first_month.month if _first_month.year == y else 0, + _last_month.month if _last_month.year == y else 12, + ) + ], + } + for y in range( + _first_month.year, + _last_month.year + 1, + ) + ] + return { - "years": [ - { - "y": y, - "d": [ - _history.filter(month=datetime.date(y, m + 1, 1)).first() - for m in range( - 0, - _last_month.month if _last_month.year == y else 12, - ) - ], - } - for y in range( - _first_month.year, - _last_month.year + 1, - ) - ], + "years": _data, + "offset": [range(_first_month.month), range(12 - _last_month.month)], "max": max( _history.aggregate( max=Max("sum_p", default=0), diff --git a/nummi/main/templates/main/base.html b/nummi/main/templates/main/base.html index 3b3d2aa..6c60492 100644 --- a/nummi/main/templates/main/base.html +++ b/nummi/main/templates/main/base.html @@ -3,15 +3,15 @@ - - + + {% block title %}Nummi{% endblock %} {% block link %} - - - + + + {% endblock %} @@ -19,7 +19,7 @@ {% spaceless %}