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