Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Allow selecting units in timer page

Roland Geider94fc94de0205
diff --git a/wger/core/static/css/workout-manager-mobile.css b/wger/core/static/css/workout-manager-mobile.css
index 6c2d1b2e1..cc25678a4 100644
--- a/wger/core/static/css/workout-manager-mobile.css
+++ b/wger/core/static/css/workout-manager-mobile.css
@@ -519,8 +519,8 @@ div#timer-container{
}
div#timer-container canvas, div#timer-container div.filler_div{
- width: 100%;
height: 150px;
+ margin-top: 1em;
margin-bottom: 30px;
}
diff --git a/wger/manager/templates/workout/timer.html b/wger/manager/templates/workout/timer.html
index dd00b0171..da7b8b8e5 100644
--- a/wger/manager/templates/workout/timer.html
+++ b/wger/manager/templates/workout/timer.html
@@ -8,9 +8,6 @@
{% block title %}{% endblock %}
{% block header %}
-<style>
-
-</style>
<script>
"use strict";
/*
@@ -296,7 +293,7 @@ $(document).ready(function() {
id="id-date-{{step.current_step}}"
value="{% now 'Y-m-j' %}"
type="hidden">
- <div class="row filler_div">
+ <div class="row">
<div class="col-xs-6">
<label for="id-reps-{{step.current_step}}">{% trans "Repetitions" %}:</label>
<input name="reps"
@@ -318,6 +315,26 @@ $(document).ready(function() {
class="form-control">
</div>
</div>
+ <div class="row filler_div">
+ <div class="col-xs-6">
+ <select name="repetition_unit" id="id-repetition-unit-{{step.current_step}}" class="form-control">
+ {% for unit in repetition_units %}
+ <option value="{{ unit.pk }}" {% if unit.pk = step.rep_unit.pk %}selected="selected"{% endif %}>
+ {% trans unit.name %}
+ </option>
+ {% endfor %}
+ </select>
+ </div>
+ <div class="col-xs-6">
+ <select name="weight_unit" id="id-weight-unit-{{step.current_step}}" class="form-control">
+ {% for unit in weight_units %}
+ <option value="{{ unit.pk }}" {% if unit.pk = step.weight_unit.pk %}selected="selected"{% endif %}>
+ {% trans unit.name %}
+ </option>
+ {% endfor %}
+ </select>
+ </div>
+ </div>
</form>
<div class="sub_header">
diff --git a/wger/manager/views/workout.py b/wger/manager/views/workout.py
index 032838ea7..d53adcb29 100644
--- a/wger/manager/views/workout.py
+++ b/wger/manager/views/workout.py
@@ -26,6 +26,10 @@ from django.utils.translation import ugettext_lazy, ugettext as _
from django.contrib.auth.decorators import login_required
from django.views.generic import DeleteView, UpdateView
+from wger.core.models import (
+ RepetitionUnit,
+ WeightUnit
+)
from wger.manager.models import (
Workout,
WorkoutSession,
@@ -291,7 +295,8 @@ def timer(request, day_pk):
exercise = exercise_dict['obj']
for key, element in enumerate(exercise_dict['reps_list']):
reps = exercise_dict['reps_list'][key]
- unit = exercise_dict['repetition_units'][key]
+ rep_unit = exercise_dict['repetition_units'][key]
+ weight_unit = exercise_dict['weight_units'][key]
default_weight = last_log.get_last_weight(exercise,
reps,
exercise_dict['weight_list'][key])
@@ -302,8 +307,9 @@ def timer(request, day_pk):
'exercise': exercise,
'type': 'exercise',
'reps': reps,
- 'unit': unit,
- 'weight': default_weight})
+ 'rep_unit': rep_unit,
+ 'weight': default_weight,
+ 'weight_unit': weight_unit})
if request.user.userprofile.timer_active:
step_list.append({'current_step': uuid.uuid4().hex,
'step_percent': 0,
@@ -317,7 +323,8 @@ def timer(request, day_pk):
for i in range(0, total_reps):
for exercise_dict in set_dict['exercise_list']:
reps = exercise_dict['reps_list'][i]
- unit = exercise_dict['repetition_units'][i]
+ rep_unit = exercise_dict['repetition_units'][i]
+ weight_unit = exercise_dict['weight_units'][i]
default_weight = exercise_dict['weight_list'][i]
exercise = exercise_dict['obj']
@@ -327,7 +334,8 @@ def timer(request, day_pk):
'exercise': exercise,
'type': 'exercise',
'reps': reps,
- 'unit': unit,
+ 'rep_unit': rep_unit,
+ 'weight_unit': weight_unit,
'weight': last_log.get_last_weight(exercise,
reps,
default_weight)})
@@ -371,4 +379,6 @@ def timer(request, day_pk):
context['workout'] = day.training
context['session_form'] = session_form
context['form_action'] = url
+ context['weight_units'] = WeightUnit.objects.all()
+ context['repetition_units'] = RepetitionUnit.objects.all()
return render(request, 'workout/timer.html', context)