use date filter instead of preparing date strings
This commit is contained in:
@@ -24,20 +24,23 @@
|
|||||||
{% for date, stat in graph_data.items %}
|
{% for date, stat in graph_data.items %}
|
||||||
{% if stat.div_percentage is None %}
|
{% if stat.div_percentage is None %}
|
||||||
<div class="graph-bar weak grey"
|
<div class="graph-bar weak grey"
|
||||||
onmouseover="showGraphBarDate('{{ stat.date_string }}')"
|
onmouseover="showGraphBarDate('{{ date|date:"d.m.y" }}')"
|
||||||
onmouseleave="clearGraphBarDate()">
|
onmouseleave="clearGraphBarDate()">
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="graph-bar {{ stat.div_opacity_class }} {{ stat.div_color_class }}"
|
<div class="graph-bar {{ stat.div_opacity_class }} {{ stat.div_color_class }}"
|
||||||
style="height: {{ stat.div_percentage }}%"
|
style="height: {{ stat.div_percentage }}%"
|
||||||
onmouseover="showGraphBarDate('{{ stat.date_string }}')"
|
onmouseover="showGraphBarDate('{{ date|date:"d.m.y" }}')"
|
||||||
onmouseleave="clearGraphBarDate()">
|
onmouseleave="clearGraphBarDate()">
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>No enough data from {{ range_start }} til {{ range_end }} to show a graph.</p>
|
<p>
|
||||||
|
No enough data from {{ range_start|date:"d.m.y" }} til
|
||||||
|
{{ range_end|date:"d.m.y" }} to show a graph.
|
||||||
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -54,7 +57,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for balance in balance_list %}
|
{% for balance in balance_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ balance.date }}</td>
|
<td>{{ balance.date|date:"d.m.y" }}</td>
|
||||||
<td>{{ balance.amount }}</td>
|
<td>{{ balance.amount }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -83,9 +86,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{ transaction.subject }}</td>
|
<td>{{ transaction.subject }}</td>
|
||||||
<td>{{ transaction.amount }}</td>
|
<td>{{ transaction.amount }}</td>
|
||||||
<td>{{ transaction.booking_date }}</td>
|
<td>{{ transaction.booking_date|date:"d.m.y" }}</td>
|
||||||
<td>{{ transaction.recurring_months }}</td>
|
<td>{{ transaction.recurring_months }}</td>
|
||||||
<td>{{ transaction.not_recurring_after }}</td>
|
<td>{{ transaction.not_recurring_after|date:"d.m.y" }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -109,7 +112,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for date, subject, amount in actual_transactions %}
|
{% for date, subject, amount in actual_transactions %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ date }}</td>
|
<td>{{ date|date:"d.m.y" }}</td>
|
||||||
<td>{{ subject }}</td>
|
<td>{{ subject }}</td>
|
||||||
<td>{{ amount }}</td>
|
<td>{{ amount }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -8,10 +8,6 @@ def current_date():
|
|||||||
return datetime.now().date()
|
return datetime.now().date()
|
||||||
|
|
||||||
|
|
||||||
def format_date(d):
|
|
||||||
return d.strftime("%d.%m.%Y")
|
|
||||||
|
|
||||||
|
|
||||||
def round_with_dec_places(number, places):
|
def round_with_dec_places(number, places):
|
||||||
if number is None:
|
if number is None:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ from django.contrib.auth.decorators import login_required
|
|||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
from financeplanner.utils import format_date
|
|
||||||
|
|
||||||
|
|
||||||
def _get_relevant_balances(user, range_start, range_end):
|
def _get_relevant_balances(user, range_start, range_end):
|
||||||
balance_list = []
|
balance_list = []
|
||||||
@@ -151,7 +149,6 @@ def _build_graph_data(range_start, range_end, calculation_start, balance_list, a
|
|||||||
stats = _trim_stats(stats, range_start)
|
stats = _trim_stats(stats, range_start)
|
||||||
amount_limit = _calculate_scale(stats)
|
amount_limit = _calculate_scale(stats)
|
||||||
for date in stats.keys():
|
for date in stats.keys():
|
||||||
stats[date]["date_string"] = format_date(date)
|
|
||||||
amount = stats[date]["amount"]
|
amount = stats[date]["amount"]
|
||||||
if amount is None:
|
if amount is None:
|
||||||
stats[date]["div_percentage"] = None
|
stats[date]["div_percentage"] = None
|
||||||
@@ -194,8 +191,8 @@ def index(request):
|
|||||||
else:
|
else:
|
||||||
graph_data = None
|
graph_data = None
|
||||||
context = {
|
context = {
|
||||||
"range_start": format_date(range_start),
|
"range_start": range_start,
|
||||||
"range_end": format_date(range_end),
|
"range_end": range_end,
|
||||||
"today": today,
|
"today": today,
|
||||||
"balance_list": balance_list,
|
"balance_list": balance_list,
|
||||||
"transaction_list": transaction_list,
|
"transaction_list": transaction_list,
|
||||||
|
|||||||
Reference in New Issue
Block a user