Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Allow editing of workout sessions from calendar view

Roland Geidere278b1542d2e
diff --git a/wger/manager/templates/mobile/workout/calendar.html b/wger/manager/templates/mobile/workout/calendar.html
index 96f95c3d1..273b72dd4 100644
--- a/wger/manager/templates/mobile/workout/calendar.html
+++ b/wger/manager/templates/mobile/workout/calendar.html
@@ -33,28 +33,31 @@ $(document).ready(function() {
{# TODO: what if some of the entries don't belong to a workout? #}
{% with tmp=grouped_logs|first %}
{% with first_log=tmp.list|first %}
- <div class="ui-grid-a">
- <div class="ui-block-a">
+ {% with session=first_log.get_workout_session %}
+
<a href="{{first_log.workout.get_absolute_url}}"
- data-role="button"
- data-icon="arrow-r">{% trans "Workout" %}</a>
- </div>
- <div class="ui-block-b">
+ data-role="button">{{ first_log.workout }}</a>
+
<a href="{% url 'workout-log' first_log.workout.id %}"
- data-role="button"
- data-icon="arrow-r">{% trans "Log overview" %}</a>
- </div>
- </div>
+ data-role="button">{% trans "Log overview" %}</a>
+
+ <a href="{% url 'workout-session-edit' session.pk %}"
+ data-role="button">{% trans "Edit session" %}</a>
+
- {% with session=first_log.get_workout_session %}
{% if session %}
<p>
- <strong>{% trans "Notes" %}:</strong> {{session.notes}}<br>
+ <strong>{% trans "Time" %}:</strong>
+ {% if session.time_start %}
+ {{session.time_start|time:"H:i"}} - {{session.time_end|time:"H:i"}}
+ {% else %}
+ -/-
+ {% endif %}<br>
<strong>{% trans "General impression" %}: </strong> {% trans session.get_impression_display %}<br>
- <strong>{% trans "Time" %}:</strong> {{session.time_start|time:"H:i"}} - {{session.time_end|time:"H:i"}}
+ <strong>{% trans "Notes" %}:</strong> {{session.notes}}
</p>
{% endif %}
- {% endwith %}
+ {% endwith %}
{% endwith %}
{% endwith %}
diff --git a/wger/manager/templates/workout/calendar.html b/wger/manager/templates/workout/calendar.html
index 9bd34519d..5491334d9 100644
--- a/wger/manager/templates/workout/calendar.html
+++ b/wger/manager/templates/workout/calendar.html
@@ -38,19 +38,27 @@ $(document).ready(function() {
{# TODO: what if some of the entries don't belong to a workout? #}
{% with tmp=grouped_logs|first %}
{% with first_log=tmp.list|first %}
+ {% with session=first_log.get_workout_session %}
<p>
- <a href="{{first_log.workout.get_absolute_url}}" class="btn">{% trans "Workout" %}</a>
+ <a href="{{first_log.workout.get_absolute_url}}" class="btn">{{ first_log.workout }}</a>
<a href="{% url 'workout-log' first_log.workout.id %}" class="btn">{% trans "Log overview" %}</a>
+ {% if session %}
+ <a href="{% url 'workout-session-edit' session.pk %}" class="btn modal-dialog">{% trans "Edit session" %}</a>
+ {% endif %}
</p>
- {% with session=first_log.get_workout_session %}
{% if session %}
<p>
- <strong>{% trans "Notes" %}:</strong> {{session.notes}}<br>
+ <strong>{% trans "Time" %}:</strong>
+ {% if session.time_start %}
+ {{session.time_start|time:"H:i"}} - {{session.time_end|time:"H:i"}}
+ {% else %}
+ -/-
+ {% endif %}<br>
<strong>{% trans "General impression" %}: </strong> {% trans session.get_impression_display %}<br>
- <strong>{% trans "Time" %}:</strong> {{session.time_start|time:"H:i"}} - {{session.time_end|time:"H:i"}}
+ <strong>{% trans "Notes" %}:</strong> {{session.notes}}
</p>
{% endif %}
- {% endwith %}
+ {% endwith %}
{% endwith %}
{% endwith %}
<ul class="grouper-list">
diff --git a/wger/manager/views/workout_session.py b/wger/manager/views/workout_session.py
index bf1327b76..bf196412a 100644
--- a/wger/manager/views/workout_session.py
+++ b/wger/manager/views/workout_session.py
@@ -43,12 +43,14 @@ class WorkoutSessionUpdateView(WgerFormMixin, UpdateView, WgerPermissionMixin):
Generic view to edit an existing workout session entry
'''
model = WorkoutSession
+ form_class = WorkoutSessionForm
login_required = True
def get_context_data(self, **kwargs):
context = super(WorkoutSessionUpdateView, self).get_context_data(**kwargs)
- context['form_action'] = reverse('workout-log-edit', kwargs={'pk': self.object.id})
+ context['form_action'] = reverse('workout-session-edit', kwargs={'pk': self.object.id})
context['title'] = _('Edit workout session for %s') % self.object.date
+ context['select_lists'] = ('impression', )
return context