Self hosted FLOSS fitness/workout, nutrition and weight tracker
Adds weight details fixes to overview
Yuyu Aung6d2d185ad2fb
diff --git a/AUTHORS.rst b/AUTHORS.rstindex a2b41fca1..491f3aff7 100644--- a/AUTHORS.rst+++ b/AUTHORS.rst@@ -8,7 +8,7 @@ Developers* Helen Sherwood-Taylor - https://github.com/helenst* Tushar Gupta - https://github.com/Tushar-Gupta* Matheus Zorzete Marchiore - https://github.com/marchiore-+* Yu Yu Aung - https://github.com/max111Translators-----------diff --git a/wger/weight/templates/weight_overview.html b/wger/weight/templates/weight_overview.htmlindex eb5c42e9c..4e188c7a1 100644--- a/wger/weight/templates/weight_overview.html+++ b/wger/weight/templates/weight_overview.html@@ -39,15 +39,16 @@ $(document).ready(function () {{% if is_owner %}{% if last_five_weight_entries_details %}-<table border="1" style="width:100%">- <tr>- <th>Date</th>- <th>Weight</th>- <th>Change</th>- <th>Days</th>+<table class="table">+ <tr>+ <th>{% trans 'Date' %}</th>+ <th>{% trans 'Weight' %}</th>+ <th>{% trans 'Change' %}</th>+ <th>{% trans 'Days' %}</th></tr>{% for entry_detail in last_five_weight_entries_details %}- <tr><td>{{ entry_detail.0.date }}</td>+ <tr>+ <td>{{ entry_detail.0.date }}</td><td>{{ entry_detail.0.weight }}</td><td>{{ entry_detail.1 }}</td><td>{{ entry_detail.2 }}</td>diff --git a/wger/weight/views.py b/wger/weight/views.pyindex 8ca31d685..89753608c 100644--- a/wger/weight/views.py+++ b/wger/weight/views.py@@ -153,21 +153,21 @@ def overview(request, username=None):last_five_weight_entries = WeightEntry.objects.filter(user=user).order_by('-date')[:5]last_five_weight_entries_details = []- if last_five_weight_entries:- i = 0-- while (i != len(last_five_weight_entries)-1):- curr_entry = last_five_weight_entries[i]- prev_entry = last_five_weight_entries[i+1]- weight_diff = curr_entry.weight - prev_entry.weight- if weight_diff > 0:- weight_diff = '+'+str(weight_diff)- day_diff = (curr_entry.date - prev_entry.date).days- last_five_weight_entries_details.append((curr_entry, weight_diff, day_diff))- i += 1+ for index, entry in enumerate(last_five_weight_entries):+ curr_entry = entry+ prev_entry_index = index + 1++ if prev_entry_index < len(last_five_weight_entries):+ prev_entry = last_five_weight_entries[prev_entry_index]+ else:+ prev_entry = None- curr_entry = last_five_weight_entries[i]- last_five_weight_entries_details.append((curr_entry,'-/-', '-/-'))+ if prev_entry and curr_entry:+ weight_diff = curr_entry.weight - prev_entry.weight+ day_diff = (curr_entry.date - prev_entry.date).days+ else:+ weight_diff = day_diff = '-/-'+ last_five_weight_entries_details.append((curr_entry, weight_diff, day_diff))template_data['is_owner'] = is_ownertemplate_data['owner_user'] = user