Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Cleanup and refactor template code for month links

Roland Geider35fc0fa99357
diff --git a/wger/core/static/css/workout-manager-common.css b/wger/core/static/css/workout-manager-common.css
index fce9831fe..66a39529e 100644
--- a/wger/core/static/css/workout-manager-common.css
+++ b/wger/core/static/css/workout-manager-common.css
@@ -328,11 +328,4 @@ table.month td.session-good {
table.month td.session-good:hover {
background-color: #449D44;
-}
-
-
-/* Timeline with years and months with logs */
-
-.timeline-log span{
- margin-left: 1em;
}
\ No newline at end of file
diff --git a/wger/manager/templates/calendar/month.html b/wger/manager/templates/calendar/month.html
index fc00f5de9..d10e81b41 100644
--- a/wger/manager/templates/calendar/month.html
+++ b/wger/manager/templates/calendar/month.html
@@ -163,17 +163,18 @@ you can click on them to see the details.{% endblocktrans %}</p>
</p>
{% endif %}
-<div class="timeline-log">
-{% for date in month_list %}
- {% ifchanged date.year %}
- <p><strong>{{ date|date:"Y" }}</strong></p>
- {% endifchanged %}
- {% if current_month = date.month and current_year = date.year %}
- <span>{{date|date:"F"}}</span><br>
- {% else %}
- <span><a href="{% url 'manager:workout:calendar' owner_user date.year date.month %}">{{date|date:"F"}}</a></span><br>
- {% endif %}
-{% endfor %}
-</div>
+{% regroup month_list by year as year_list %}
+{% for year in year_list reversed %}
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h3 class="panel-title">{{ year.grouper }}</h3>
+ </div>
+ <ul class="list-group">
+ {% for month in year.list %}
+ <a href="{% url 'manager:workout:calendar' owner_user year.grouper month.month %}" class="list-group-item">{{month|date:"F"}}</a>
+ {% endfor %}
+ </ul>
+ </div>
+{% endfor %}
{% endblock %}
diff --git a/wger/manager/templates/mobile/calendar/month.html b/wger/manager/templates/mobile/calendar/month.html
index b0e121b13..6dc2f5764 100644
--- a/wger/manager/templates/mobile/calendar/month.html
+++ b/wger/manager/templates/mobile/calendar/month.html
@@ -204,26 +204,18 @@ you can click on them to see the details.{% endblocktrans %}</p>
{% trans "Add new log" %}</a>
{% endif %}
-<div class="timeline-log" style="margin-top: 1em;">
- <div class="list-group">
- {% for date in month_list %}
- {% ifchanged date.year %}
- <a href="#" class="list-group-item active">
- {{ date|date:"Y" }}
- </a>
- {% endifchanged %}
- {% if current_month = date.month and current_year = date.year %}
- <a href="{% url 'manager:workout:calendar' owner_user date.year date.month %}" class="list-group-item wger-list-group-item">
- <em>{{date|date:"F"}}</em>
- </a>
- {% else %}
- <a href="{% url 'manager:workout:calendar' owner_user date.year date.month %}" class="list-group-item wger-list-group-item">
- <span class="glyphicon glyphicon-chevron-right pull-right"></span>
- {{date|date:"F"}}
- </a>
- {% endif %}
- {% endfor %}
+{% regroup month_list by year as year_list %}
+{% for year in year_list reversed %}
+<div class="panel panel-default" style="margin-top: 1em;">
+ <div class="panel-heading">
+ <h3 class="panel-title">{{ year.grouper }}</h3>
</div>
-</div>
+ <ul class="list-group">
+ {% for month in year.list %}
+ <a href="{% url 'manager:workout:calendar' owner_user year.grouper month.month %}" class="list-group-item">{{month|date:"F"}}</a>
+ {% endfor %}
+ </ul>
+</div>
+{% endfor %}
{% endblock %}