Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Remove test_timer.py file

Roland Geider940c14604dc7
diff --git a/wger/core/api/serializers.py b/wger/core/api/serializers.py
index 2ddae9be6..37c1f3f46 100644
--- a/wger/core/api/serializers.py
+++ b/wger/core/api/serializers.py
@@ -52,8 +52,6 @@ class UserprofileSerializer(serializers.ModelSerializer):
'workout_duration',
'last_workout_notification',
'notification_language',
- 'timer_active',
- 'timer_active',
'age',
'birthdate',
'height',
diff --git a/wger/core/fixtures/test-user-data.json b/wger/core/fixtures/test-user-data.json
index 92c52a426..022388dd4 100644
--- a/wger/core/fixtures/test-user-data.json
+++ b/wger/core/fixtures/test-user-data.json
@@ -498,8 +498,6 @@
"workout_reminder": 20,
"workout_duration": 8,
"notification_language": 1,
- "timer_active": true,
- "timer_pause": 90,
"gym": 1,
"weight_unit": "kg",
"ro_access": true,
@@ -531,8 +529,6 @@
"workout_reminder": 14,
"workout_duration": 12,
"notification_language": 2,
- "timer_active": true,
- "timer_pause": 90,
"gym": 1,
"weight_unit": "kg",
"ro_access": false,
@@ -595,9 +591,7 @@
"workout_reminder": 14,
"workout_duration": 12,
"notification_language": 2,
- "timer_active": true,
- "timer_pause": 90,
- "gym": 1,
+ "gym": 1,
"weight_unit": "kg",
"ro_access": false,
"num_days_weight_reminder": 0,
@@ -628,8 +622,6 @@
"workout_reminder": 14,
"workout_duration": 12,
"notification_language": 2,
- "timer_active": true,
- "timer_pause": 90,
"gym": 1,
"weight_unit": "kg",
"ro_access": false,
@@ -661,8 +653,6 @@
"workout_reminder": 14,
"workout_duration": 12,
"notification_language": 2,
- "timer_active": true,
- "timer_pause": 90,
"gym": 1,
"weight_unit": "kg",
"ro_access": false,
@@ -694,8 +684,6 @@
"workout_reminder": 14,
"workout_duration": 12,
"notification_language": 2,
- "timer_active": true,
- "timer_pause": 90,
"gym": 2,
"weight_unit": "lb",
"ro_access": false,
@@ -727,8 +715,6 @@
"workout_reminder": 14,
"workout_duration": 12,
"notification_language": 2,
- "timer_active": true,
- "timer_pause": 90,
"gym": 2,
"weight_unit": "lb",
"ro_access": true,
@@ -760,8 +746,6 @@
"workout_reminder": 14,
"workout_duration": 12,
"notification_language": 2,
- "timer_active": true,
- "timer_pause": 90,
"gym": 1,
"weight_unit": "kg",
"ro_access": false,
@@ -793,8 +777,6 @@
"workout_reminder": 14,
"workout_duration": 12,
"notification_language": 2,
- "timer_active": true,
- "timer_pause": 90,
"gym": 1,
"weight_unit": "kg",
"ro_access": false,
@@ -826,8 +808,6 @@
"workout_reminder": 14,
"workout_duration": 12,
"notification_language": 2,
- "timer_active": true,
- "timer_pause": 90,
"gym": 2,
"weight_unit": "lb",
"ro_access": false,
@@ -859,8 +839,6 @@
"workout_reminder": 14,
"workout_duration": 12,
"notification_language": 2,
- "timer_active": true,
- "timer_pause": 90,
"gym": 1,
"weight_unit": "kg",
"ro_access": false,
@@ -892,8 +870,6 @@
"workout_reminder": 14,
"workout_duration": 12,
"notification_language": 2,
- "timer_active": true,
- "timer_pause": 90,
"gym": 2,
"weight_unit": "lb",
"ro_access": true,
@@ -918,8 +894,6 @@
"workout_reminder_active": false,
"work_intensity": "1",
"user": 14,
- "timer_active": true,
- "timer_pause": 90,
"work_hours": 8,
"freetime_intensity": "1",
"gender": "1",
@@ -951,8 +925,6 @@
"workout_reminder_active": false,
"work_intensity": "1",
"user": 15,
- "timer_active": true,
- "timer_pause": 90,
"work_hours": 8,
"freetime_intensity": "1",
"gender": "1",
@@ -984,8 +956,6 @@
"workout_reminder_active": false,
"work_intensity": "1",
"user": 16,
- "timer_active": true,
- "timer_pause": 90,
"work_hours": 8,
"freetime_intensity": "1",
"gender": "1",
@@ -1017,8 +987,6 @@
"workout_reminder_active": false,
"work_intensity": "1",
"user": 17,
- "timer_active": true,
- "timer_pause": 90,
"work_hours": 8,
"freetime_intensity": "1",
"gender": "1",
@@ -1050,8 +1018,6 @@
"workout_reminder_active": false,
"work_intensity": "1",
"user": 18,
- "timer_active": true,
- "timer_pause": 90,
"work_hours": 8,
"freetime_intensity": "1",
"gender": "1",
@@ -1083,8 +1049,6 @@
"workout_reminder_active": false,
"work_intensity": "1",
"user": 19,
- "timer_active": true,
- "timer_pause": 90,
"work_hours": 8,
"freetime_intensity": "1",
"gender": "1",
@@ -1116,8 +1080,6 @@
"workout_reminder_active": false,
"work_intensity": "1",
"user": 20,
- "timer_active": true,
- "timer_pause": 90,
"work_hours": 8,
"freetime_intensity": "1",
"gender": "1",
@@ -1149,8 +1111,6 @@
"workout_reminder_active": false,
"work_intensity": "1",
"user": 21,
- "timer_active": true,
- "timer_pause": 90,
"work_hours": 8,
"freetime_intensity": "1",
"gender": "1",
@@ -1182,8 +1142,6 @@
"workout_reminder_active": false,
"work_intensity": "1",
"user": 22,
- "timer_active": true,
- "timer_pause": 90,
"work_hours": 8,
"freetime_intensity": "1",
"gender": "1",
@@ -1215,8 +1173,6 @@
"workout_reminder_active": false,
"work_intensity": "1",
"user": 23,
- "timer_active": true,
- "timer_pause": 90,
"work_hours": 8,
"freetime_intensity": "1",
"gender": "1",
@@ -1248,8 +1204,6 @@
"workout_reminder_active": false,
"work_intensity": "1",
"user": 24,
- "timer_active": true,
- "timer_pause": 90,
"work_hours": 8,
"freetime_intensity": "1",
"gender": "1",
diff --git a/wger/core/forms.py b/wger/core/forms.py
index 95c9ffc3d..21ecd5141 100644
--- a/wger/core/forms.py
+++ b/wger/core/forms.py
@@ -44,7 +44,7 @@ from crispy_forms.layout import (
Column,
Layout,
Row,
- Submit,
+ Submit, Fieldset, HTML,
)
# wger
@@ -90,8 +90,6 @@ class UserPreferencesForm(forms.ModelForm):
'workout_duration',
'notification_language',
'weight_unit',
- 'timer_active',
- 'timer_pause',
'ro_access',
'num_days_weight_reminder',
'birthdate',
@@ -102,35 +100,30 @@ class UserPreferencesForm(forms.ModelForm):
self.helper = FormHelper()
self.helper.form_class = 'wger-form'
self.helper.layout = Layout(
- Accordion(
- AccordionGroup(
- _("Personal data"),
- 'email',
- Row(
- Column('first_name', css_class='form-group col-6 mb-0'),
- Column('last_name', css_class='form-group col-6 mb-0'),
- css_class='form-row'
- ),
- ),
- AccordionGroup(
- _("Workout reminders"),
- 'workout_reminder_active',
- 'workout_reminder',
- 'workout_duration',
- ),
- AccordionGroup(
- f"{_('Gym mode')} ({_('mobile version only')})", "timer_active", "timer_pause"
- ),
- AccordionGroup(
- _("Other settings"),
- "ro_access",
- "notification_language",
- "weight_unit",
- "show_comments",
- "show_english_ingredients",
- "num_days_weight_reminder",
- "birthdate",
- )
+ Fieldset(
+ _("Personal data"), 'email',
+ Row(
+ Column('first_name', css_class='form-group col-6 mb-0'),
+ Column('last_name', css_class='form-group col-6 mb-0'),
+ css_class='form-row'
+ ), HTML("<hr>")
+ ),
+ Fieldset(
+ _("Workout reminders"),
+ 'workout_reminder_active',
+ 'workout_reminder',
+ 'workout_duration',
+ HTML("<hr>"),
+ ),
+ Fieldset(
+ _("Other settings"),
+ "ro_access",
+ "notification_language",
+ "weight_unit",
+ "show_comments",
+ "show_english_ingredients",
+ "num_days_weight_reminder",
+ "birthdate",
), ButtonHolder(Submit('submit', _("Save"), css_class='btn-success btn-block'))
)
diff --git a/wger/core/models/profile.py b/wger/core/models/profile.py
index 407581f16..9c1b46315 100644
--- a/wger/core/models/profile.py
+++ b/wger/core/models/profile.py
@@ -179,27 +179,6 @@ by the US Department of Agriculture. It is extremely complete, with around
on_delete=models.CASCADE
)
- timer_active = models.BooleanField(
- verbose_name=_('Use pauses in workout timer'),
- help_text=_('Check to activate timer pauses between '
- 'exercises.'),
- default=True
- )
- """
- Switch to activate pauses in the gym view
- """
-
- timer_pause = IntegerField(
- verbose_name=_('Default duration of workout pauses'),
- help_text=_('Default duration in seconds of pauses used by '
- 'the timer in the gym mode.'),
- default=90,
- validators=[MinValueValidator(10), MaxValueValidator(400)]
- )
- """
- Default duration of workout pauses in the gym view
- """
-
#
# User statistics
#
diff --git a/wger/core/tests/test_preferences.py b/wger/core/tests/test_preferences.py
index 1f19afc8e..eb259dd95 100644
--- a/wger/core/tests/test_preferences.py
+++ b/wger/core/tests/test_preferences.py
@@ -59,8 +59,6 @@ class PreferencesTestCase(WgerTestCase):
'workout_reminder': '30',
'workout_duration': 12,
'notification_language': 2,
- 'timer_active': False,
- 'timer_pause': 100,
'num_days_weight_reminder': 10,
'weight_unit': 'kg',
'birthdate': '02/25/1987',
@@ -86,8 +84,6 @@ class PreferencesTestCase(WgerTestCase):
'workout_reminder': 22,
'workout_duration': 10,
'notification_language': 2,
- 'timer_active': True,
- 'timer_pause': 40,
'num_days_weight_reminder': 10,
'weight_unit': 'lb',
'birthdate': '02/25/1987',
@@ -325,6 +321,4 @@ class PreferencesCalculationsTestCase(WgerTestCase):
# 'workout_reminder_active': True,
# 'workout_reminder': 22,
# 'workout_duration': 10,
-# 'notification_language': 2,
-# 'timer_active': True,
-# 'timer_pause': 40}
+# 'notification_language': 2}
diff --git a/wger/manager/forms.py b/wger/manager/forms.py
index c23da1409..eef2e9671 100644
--- a/wger/manager/forms.py
+++ b/wger/manager/forms.py
@@ -268,19 +268,3 @@ class WorkoutScheduleDownloadForm(Form):
css_id="download-pdf-button-schedule"
)
)
-
-
-class WorkoutSessionHiddenFieldsForm(ModelForm):
- """
- Workout Session form used in the timer view
- """
-
- class Meta:
- model = WorkoutSession
- exclude = []
- widgets = {
- 'time_start': widgets.HiddenInput(),
- 'time_end': widgets.HiddenInput(),
- 'user': widgets.HiddenInput(),
- 'notes': widgets.Textarea(attrs={'rows': 3})
- }
diff --git a/wger/manager/templates/workout/timer.html b/wger/manager/templates/workout/timer.html
deleted file mode 100644
index cdff28b2a..000000000
--- a/wger/manager/templates/workout/timer.html
+++ /dev/null
@@ -1,534 +0,0 @@
-{% extends "base.html" %}
-{% load i18n %}
-{% load l10n %}
-{% load static %}
-{% load wger_extras %}
-{% load cache %}
-
-{% block title %}{% endblock %}
-
-{% block header %}
-<script>
-"use strict";
-/*
- * http://fearlessflyer.com/how-to-create-your-own-jquery-content-slider/
- * https://github.com/fearlessflyer/content-slider
- * http://irae.pro.br/lab/canvas_pie_countdown/
- * http://www.html5canvastutorials.com/tutorials/html5-canvas-arcs/
- * http://bookofzeus.com/articles/build-a-fancy-countdown-with-html5
- */
-
-var div_height = $(window).height() * 0.80;
-var div_width = $(window).width() * 0.85;
-var start = new Date();
-
-var counter = {
-
- // counters (in seconds, except the milliseconds one)
- start: 0,
- end: 60,
- seconds: 0,
- milliseconds: 0,
-
- // other
- fps: 40,
- step_id: '',
- interval: 0,
-
- // Canvas info
- ctx: '',
- canvas_size: [0, 0],
- radius: 75,
- center: 75,
-
- draw_step: function () {
- /*
- * Step function, called every 1000/fps ms
- */
-
- // Perform exit cleanup if we finish the countdown
- if (this.milliseconds >= this.end * 1000) {
- clearInterval(this.interval);
- $('#counter-' + this.step_id).html('0');
-
- var step = $('li[data-step="' + this.step_id + '"]');
- paginate_to(step.data('number') + 1);
- return;
- }
-
- // Update the HTML element with the current remaining time once per second
- if (this.seconds !== Math.ceil(this.milliseconds / 1000)) {
- $('#counter-' + this.step_id).html(this.end - this.seconds);
- }
-
- // Draw the arc in the canvas element
- var step = this.milliseconds / (this.end * 1000);
- this.ctx.clearRect(0, 0, this.canvas_size[0], this.canvas_size[1]);
- this.ctx.beginPath();
- this.ctx.moveTo(this.center[0], this.center[1]);
- this.ctx.arc(
- this.center[0],
- this.center[1],
- this.radius,
- Math.PI * -0.5,
- Math.PI * (-0.5 + step * 2),
- true // anti clockwise
- );
- this.ctx.lineTo(this.center[0], this.center[1]); // line back to the center
- this.ctx.closePath();
- this.ctx.fillStyle = 'rgb(40, 40, 40)'; // color
- this.ctx.fill();
-
- // Update counters
- this.seconds = Math.ceil(this.milliseconds / 1000);
- this.milliseconds = this.milliseconds + 1000 / this.fps;
- },
-
- init_canvas: function (step_id, seconds) {
- /*
- * Initialise the canvas
- */
- var canvas = document.getElementById('canvas-div-' + step_id);
- this.ctx = canvas.getContext('2d');
- this.canvas_size = [canvas.width, canvas.height];
- this.radius = Math.min(this.canvas_size[0], this.canvas_size[1]) / 2;
- this.center = [this.canvas_size[0] / 2, this.canvas_size[1] / 2];
- }
-};
-
-function start_countdown(step_id, seconds) {
- /*
- * Initialise the counter objects and start the interval
- */
- counter.start = 0;
- counter.end = seconds;
- counter.milliseconds = 0;
- counter.seconds = 0;
- counter.step_id = step_id;
-
- counter.init_canvas(step_id, seconds);
- counter.interval = setInterval(
- function () {
- counter.draw_step(step_id, seconds);
- },
- 1000 / counter.fps
- );
-}
-
-function paginate_to(index) {
- /*
- * Paginate to the step page with the given index
- */
- $('ul#workout-timer').animate({
- "margin-left": (-index * div_width)
- }, 600)
-}
-
-$(document).ready(function () {
- var $timerstep = $('.timer-step');
- var $timercontainer = $('#timer-container');
- var $sessionform = $('#session-form');
- var $savebuttonform = $('#save_button_form');
-
- $('#page-title').remove();
-
- $timerstep.width(div_width);
- $timerstep.height(div_height);
-
- //wrap into mother div
- $timercontainer.find('ul').wrap('<div id="mother" />');
-
- //assign height width and overflow hidden to mother
- $('#mother').css({
- width: function () {
- return div_width;
- },
- height: function () {
- return div_height;
- },
- position: 'relative',
- overflow: 'hidden'
- });
-
- //get total of image sizes and set as width for ul
- var totalWidth = $timerstep.length * div_width;
- $timercontainer.find('ul').css({
- width: function () {
- return totalWidth;
- }
- });
-
- // Bind the buttons that create new logs
- $('.save_log').bind("click", function (e) {
- e.preventDefault();
- var step_id = $(this).parents('li').data('step');
- var form = $('#form-' + step_id);
-
- $.post(form.attr('action'), form.serialize(), function (data) {
- //response
- }
- );
- });
-
- // Bind the timer +/- buttons
- //timer-minus
- $('.timer-minus').bind("click", function (e) {
- e.preventDefault();
- counter.end = counter.end - 10;
- });
- $('.timer-plus').bind("click", function (e) {
- e.preventDefault();
- counter.end = counter.end + 10;
- });
-
- // Bind the pagination buttons
- $timercontainer.find('ul li.timer-step a.next').bind("click", function (e) {
- e.preventDefault();
- var step_id = $(this).parents('li').data('step');
- var step_time = $(this).parents('li').data('time');
- var step_nr = $(this).parents('li').data('number');
-
- //Cancel any previously running countdowns
- clearInterval(counter.interval);
-
- // Paginate to next step
- paginate_to(step_nr + 1);
-
- // Start the countdown for the next step slightly after the previous
- // pagination animation is finished
- var next_step = $(this).parents('li.timer-step').next();
- if (next_step.is('.pause-step')) {
- setTimeout(function () {
- start_countdown(next_step.data('step'), next_step.data('time'));
- }, 700);
- }
-
- // If we have reached the last page, compute total workout time
- if (next_step.is('#workout-complete')) {
- var end = new Date();
- var milliseconds = (end.getTime() - start.getTime());
-
- var hours = (milliseconds / 1000) / 3600;
- var minutes = (milliseconds / 1000) / 60 - Math.floor(hours) * 60;
- var seconds = milliseconds / 1000 - Math.floor(minutes) * 60 - Math.floor(hours) * 3600;
-
- hours = (hours < 10) ? '0' + hours : hours;
- minutes = (minutes < 10) ? '0' + minutes : minutes;
- seconds = (seconds < 10) ? '0' + seconds : seconds;
-
- //a.toLocaleTimeString()
- $('#total_time').html(Math.floor(hours) + ':' + Math.floor(minutes) + ':' + Math.floor(seconds));
-
- $('#id_time_start').val(start.getHours() + ':' + start.getMinutes());
- $('#id_time_end').val(end.getHours() + ':' + end.getMinutes());
- $('#id_date').val(end.getFullYear() + '-' + end.getMonth() + '-' + end.getDay());
- $('#id_user').val('1');
- }
-
- });
-
- // Bind the button to save the workout session form
- $savebuttonform.bind("click", function (e) {
- e.preventDefault();
- $.post($sessionform.attr('action'),
- $sessionform.serialize(),
-
- // After clicking on the save button once, disable it
- function (data) {
- var today = new Date();
- var date = '/' + today.getFullYear() + '/' + (today.getMonth() + 1) + '/' + today.getDate();
- window.location =
- '/' + getCurrentLanguage() + '/workout/calendar/' + wgerGetUsername() + date;
- $savebuttonform.unbind("click");
- $savebuttonform.addClass('disabled');
- $savebuttonform.bind("click", function (e) {
- e.preventDefault();
- });
- });
- });
-});
-</script>
-{% endblock %}
-
-{% block content %}
-{# #}
-{# Start page #}
-{# #}
-<div id="timer-container" style="position: relative; margin:0px; padding: 0px;">
-<ul id="workout-timer">
-<li class="timer-step" id="div-warmup" data-number="0">
- <h2>{% translate "Your workout today" %}</h2>
-
- <div class="filler_div">
- {% for set in canonical_day.set_list %}
- {% for exercise in set.exercise_list %}
- {{exercise.obj}}: {{exercise.setting_text}}<br>
- {% endfor %}
- {% endfor %}
- </div>
-
- <a class="next bottom_button wide_link btn btn-primary"
- href="#">{% translate "Start!" %}</a>
-</li>
-
-{% for step in step_list %}
- {# #}
- {# exercise page #}
- {# #}
- {% if step.type == 'exercise' %}
- <li class="timer-step exercise-step"
- id="div-{{step.current_step}}"
- data-step="{{step.current_step}}"
- data-number="{{step.step_nr}}">
- <h2>{{step.exercise}}</h2>
- <form action="/api/v2/workoutlog/"
- method="POST"
- id="form-{{step.current_step}}">
- {% csrf_token %}
- <input name="workout"
- id="id-workout"
- value="{{workout.pk}}"
- type="hidden">
- <input name="exercise"
- id="id-exercise-{{step.current_step}}"
- value="{{step.exercise.pk}}"
- type="hidden">
- <input name="date"
- id="id-date-{{step.current_step}}"
- value="{% now 'Y-m-j' %}"
- type="hidden">
- <div class="row">
- <div class="col-xs-6">
- <label for="id-reps-{{step.current_step}}">{% translate "Repetitions" %}:</label>
- <input name="reps"
- id="id-reps-{{step.current_step}}"
- placeholder="{% translate 'Repetitions' %}"
- value="{{step.reps}}"
- type="number"
- autocomplete="off"
- class="form-control">
- </div>
- <div class="col-xs-6">
- <label for="id-weight-{{step.current_step}}">{% translate "Weight" %}:</label>
- <input name="weight"
- id="id-weight-{{step.current_step}}"
- placeholder="{% translate 'Weight' %}"
- value="{{step.weight|unlocalize}}"
- type="number"
- autocomplete="off"
- 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 %}>
- {% translate 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 %}>
- {% translate unit.name %}
- </option>
- {% endfor %}
- </select>
- </div>
- </div>
- </form>
-
- <div class="sub_header">
- <h2>
- {% if step.weight %}
- {{step.reps}}
- {% if step.unit.id != 1 %}
- {{ step.unit }}
- {% endif %}
- × {{step.weight}} {% trans_weight_unit 'kg' user %}
- {% else %}
- {% if step.reps == 99 %}∞{% else %}{{step.reps}}{% endif %}
- {% if step.unit.id != 1 %}
- {{ step.unit }}
- {% else %}
- {% translate "reps" %}
- {% endif %}
- {% endif %}
- </h2>
- </div>
-
- <div class="row bottom_buttons">
- <div class="col-xs-6">
- <a class="next wide_link btn btn-light"
- href="#"><!-- {% translate "Skip" %}--> <span class="glyphicon glyphicon-forward"></span>
- </a>
- </div>
- <div class="col-xs-6">
- <a class="next save_log wide_link btn btn-success"
- href="#">{% translate "Save" %} <span class="glyphicon glyphicon-save"></span></a>
- </div>
- </div>
-
-
- <div id="progress-{{step.current_step}}" class="progress-bar">
- <span style="width: {{step.step_percent|stringformat:'f'}}%;"></span>
- </div>
- </li>
-
- {# #}
- {# pause page #}
- {# #}
- {% else %}
- <li class="timer-step pause-step"
- id="div-{{step.current_step}}"
- data-time="{{step.time}}"
- data-step="{{step.current_step}}"
- data-number="{{step.step_nr}}">
- <h2>{% translate "Pause!" %}</h2>
-
- <div style="width: 96%; text-align: center;">
- <canvas id="canvas-div-{{step.current_step}}" width="150" height="150"></canvas>
- </div>
-
-
- <div class="row sub_header">
- <div class="col-xs-4">
- <h2><span id="counter-{{step.current_step}}">{{step.time}}</span></h2>
- </div>
- <div class="col-xs-4">
- <a class="start timer-plus btn btn-light"
- href="#"
- id="button-plus-{{step.current_step}}">+10</a>
- </div>
- <div class="col-xs-4">
- <a class="start timer-minus btn btn-light"
- href="#"
- id="button-minus-{{step.current_step}}">-10</a>
- </div>
- </div>
-
-
- <a class="next bottom_button wide_link btn btn-light"
- href="#">{% translate "Skip" %} <span class="glyphicon glyphicon-forward"></span></a>
-
- <div id="progress-{{step.current_step}}" class="progress-bar">
- <span style="width: {{step.step_percent|stringformat:'f'}}%;"></span>
- </div>
- </li>
- {% endif %}
-{% endfor %}
-
-{# #}
-{# last page #}
-{# #}
-<li class="timer-step" id="workout-complete">
- <h2>{% translate "Workout complete!" %}</h2>
-
- <div class="filler_div">
- <form action="{{ form_action }}" id="session-form">
- {% csrf_token %}
- {{ session_form.time_start }}
- {{ session_form.time_end }}
- {{ session_form.user }}
-
-
- <div class="modal fade" id="info-{{session_form.notes.auto_id}}">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
- <h4 class="modal-title">{% translate "Info" %}</h4>
- </div>
- <div class="modal-body">
- {% translate session_form.notes.help_text %}
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-light" data-dismiss="modal">{% translate "Close" %}</button>
- </div>
- </div>
- </div>
- </div>
-
- <label for="{{session_form.notes.auto_id}}">
- <a href="#info-{{session_form.notes.auto_id}}"
- class="btn btn-light btn-sm"
- data-toggle="modal">
- <span class="glyphicon glyphicon-asterisk"></span>
- </a>
- {% translate session_form.notes.label %}
- </label>
- {{ session_form.notes|form_field_add_css:'form-control' }}
-
- <div class="modal fade" id="info-{{session_form.impression.auto_id}}">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
- <h4 class="modal-title">{% translate "Info" %}</h4>
- </div>
- <div class="modal-body">
- {% translate session_form.impression.help_text %}
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-light" data-dismiss="modal">{% translate "Close" %}</button>
- </div>
- </div>
- </div>
- </div>
- <label for="{{session_form.impression.auto_id}}">
- <a href="#info-{{session_form.impression.auto_id}}"
- class="btn btn-light btn-sm"
- data-toggle="modal">
- <span class="glyphicon glyphicon-asterisk"></span>
- </a>
- {% translate session_form.impression.label %}
- </label>
- {{ session_form.impression|form_field_add_css:'form-control' }}
-
- <!--
- {% render_form_field session_form.notes %}
- {% render_form_field session_form.impression %}
- -->
-
- </form>
- </div>
-
- <div class="sub_header">
- <h2><strong>{% translate "Time" %}:</strong> <span id="total_time">MM:SS</span></h2>
- </div>
-
- <div class="row bottom_buttons">
- <div class="col-xs-6">
- <a href="{% url 'core:dashboard' %}"
- class="wide_link btn btn-light">{% translate "Dashboard" %}</a>
- </div>
- <div class="col-xs-6">
- <a href=""
- id="save_button_form"
- class="wide_link btn btn-success">
- {% translate "Save" %}
- <span class="glyphicon glyphicon-save"></span>
- </a>
- </div>
- </div>
-
-
- <div id="progress-{{step.current_step}}" class="progress-bar">
- <span style="width: 100%;"></span>
- </div>
-</li>
-</ul>
-</div>
-{% endblock %}
-
-
-
-<!--
- Side bar
--->
-{% block sidebar %}
-
-{% endblock %}
diff --git a/wger/manager/tests/test_timer.py b/wger/manager/tests/test_timer.py
deleted file mode 100644
index b25e2f148..000000000
--- a/wger/manager/tests/test_timer.py
+++ /dev/null
@@ -1,204 +0,0 @@
-# This file is part of wger Workout Manager.
-#
-# wger Workout Manager is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# wger Workout Manager is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-
-# Standard Library
-import datetime
-import logging
-import math
-from decimal import Decimal
-from unittest import skip
-
-# Django
-from django.contrib.auth.models import User
-from django.urls import reverse
-
-# wger
-from wger.core.tests.base_testcase import WgerTestCase
-from wger.exercises.models import Exercise
-from wger.manager.models import (
- Workout,
- WorkoutSession,
-)
-
-
-logger = logging.getLogger(__name__)
-
-
-class WorkoutTimerTestCase(WgerTestCase):
- """
- Tests the timer view (gym mode) for a workout day
- """
-
- @skip("Skip till workout timer works again")
- def test_timer_no_weight(self):
- """
- Test the timer page when there are no saved weights
- """
-
- # Fetch the timer page
- self.user_login('test')
- response = self.client.get(reverse('manager:workout:timer', kwargs={'day_pk': 5}))
- self.assertEqual(response.status_code, 200)
-
- # Check some of the steps
- step_list = response.context['step_list']
- step_list.reverse()
-
- current_step = step_list.pop()
- self.assertEqual(current_step['weight'], '')
-
- @skip("Skip till workout timer works again")
- def timer(self, fail=True, pause_active=True, pause_seconds=90):
- """
- Helper function
- """
-
- # Fetch the timer page
- response = self.client.get(reverse('manager:workout:timer', kwargs={'day_pk': 2}))
-
- if fail:
- self.assertIn(response.status_code, (302, 404))
- else:
- self.assertEqual(response.status_code, 200)
-
- # Check some of the steps
- step_list = response.context['step_list']
- step_list.reverse()
- list_length = len(step_list)
-
- current_step = step_list.pop()
- self.assertEqual(current_step['exercise'], Exercise.objects.get(pk=2))
- self.assertEqual(current_step['reps'], 10)
- self.assertEqual(current_step['step_nr'], list_length - len(step_list))
- self.assertEqual(
- math.floor(current_step['step_percent']),
- math.floor(current_step['step_nr'] * (100.0 / list_length))
- )
- self.assertEqual(current_step['type'], 'exercise')
- self.assertEqual(current_step['weight'], Decimal(15))
-
- if pause_active:
- current_step = step_list.pop()
- self.assertEqual(current_step['step_nr'], list_length - len(step_list))
- self.assertEqual(
- math.floor(current_step['step_percent']),
- math.floor(current_step['step_nr'] * (100.0 / list_length))
- )
- self.assertEqual(current_step['time'], pause_seconds)
- self.assertEqual(current_step['type'], 'pause')
-
- current_step = step_list.pop()
- self.assertEqual(current_step['exercise'], Exercise.objects.get(pk=2))
- self.assertEqual(current_step['reps'], 10)
- self.assertEqual(current_step['step_nr'], list_length - len(step_list))
- self.assertEqual(
- math.floor(current_step['step_percent']),
- math.floor(current_step['step_nr'] * (100.0 / list_length))
- )
- self.assertEqual(current_step['type'], 'exercise')
- self.assertEqual(current_step['weight'], Decimal(15))
-
- if pause_active:
- current_step = step_list.pop()
- self.assertEqual(current_step['step_nr'], list_length - len(step_list))
- self.assertEqual(
- math.floor(current_step['step_percent']),
- math.floor(current_step['step_nr'] * (100.0 / list_length))
- )
- self.assertEqual(current_step['time'], pause_seconds)
- self.assertEqual(current_step['type'], 'pause')
-
- current_step = step_list.pop()
- self.assertEqual(current_step['exercise'], Exercise.objects.get(pk=2))
- self.assertEqual(current_step['reps'], 10)
- self.assertEqual(current_step['step_nr'], list_length - len(step_list))
- self.assertEqual(
- math.floor(current_step['step_percent']),
- math.floor(current_step['step_nr'] * (100.0 / list_length))
- )
- self.assertEqual(current_step['type'], 'exercise')
- self.assertEqual(current_step['weight'], Decimal(15))
-
- @skip("Skip till workout timer works again")
- def test_timer_anonymous(self):
- """
- Tests the timer as an anonymous user
- """
-
- self.timer(fail=True)
-
- @skip("Skip till workout timer works again")
- def test_timer_owner(self):
- """
- Tests the timer as the owner user
- """
- self.user_login('admin')
- self.timer(fail=False)
-
- @skip("Skip till workout timer works again")
- def test_timer_owner_custom_pause(self):
- """
- Tests the timer as the owner, use custom time
- """
- self.user_login('admin')
- user = User.objects.get(username='admin')
- user.userprofile.timer_pause = 120
- user.userprofile.save()
- self.timer(fail=False, pause_seconds=120)
-
- @skip("Skip till workout timer works again")
- def test_timer_owner_no_pause(self):
- """
- Tests the timer as the owner, deactivate timer
- """
- self.user_login('admin')
- user = User.objects.get(username='admin')
- user.userprofile.timer_active = False
- user.userprofile.save()
- self.timer(fail=False, pause_active=False)
-
- @skip("Skip till workout timer works again")
- def test_timer_other(self):
- """
- Tests the timer as a logged user not owning the data
- """
-
- self.user_login('test')
- self.timer(fail=True)
-
-
-class WorkoutTimerWorkoutSessionTestCase(WgerTestCase):
- """
- Other tests
- """
-
- @skip("Skip till workout timer works again")
- def test_workout_session(self):
- """
- Tests that the correct urls and forms for workout session is passed
- """
- WorkoutSession.objects.all().delete()
- self.user_login('test')
-
- self.client.get(reverse('manager:workout:timer', kwargs={'day_pk': 5}))
-
- session = WorkoutSession()
- session.user = User.objects.get(username='test')
- session.workout = Workout.objects.get(pk=2)
- session.date = datetime.date.today()
- session.notes = 'Something here'
- session.impression = '2'
- session.time_start = datetime.time(11, 00)
- session.time_end = datetime.time(13, 00)
- session.save()
diff --git a/wger/manager/urls.py b/wger/manager/urls.py
index 19d8708ef..99013e68d 100644
--- a/wger/manager/urls.py
+++ b/wger/manager/urls.py
@@ -163,11 +163,6 @@ patterns_workout = [
pdf.workout_view,
name='pdf-table',
),
- path(
- '<int:day_pk>/timer',
- workout.timer,
- name='timer',
- ),
]
# sub patterns for workout sessions
diff --git a/wger/manager/views/workout.py b/wger/manager/views/workout.py
index a4b4ca655..37aa6702d 100644
--- a/wger/manager/views/workout.py
+++ b/wger/manager/views/workout.py
@@ -51,21 +51,14 @@ from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
# wger
-from wger.core.models import (
- RepetitionUnit,
- WeightUnit,
-)
from wger.manager.forms import (
WorkoutCopyForm,
WorkoutForm,
- WorkoutSessionHiddenFieldsForm,
)
from wger.manager.models import (
- Day,
Schedule,
Workout,
WorkoutLog,
- WorkoutSession,
)
from wger.utils.generic_views import (
WgerDeleteMixin,
@@ -270,119 +263,3 @@ class LastWeightHelper:
self.last_weight_list[key] = weight
return self.last_weight_list.get(key)
-
-
-@login_required
-def timer(request, day_pk):
- """
- The timer view ("gym mode") for a workout
- """
-
- day = get_object_or_404(Day, pk=day_pk, training__user=request.user)
- canonical_day = day.canonical_representation
- context = {}
- step_list = []
- last_log = LastWeightHelper(request.user)
-
- # Go through the workout day and create the individual 'pages'
- for set_dict in canonical_day['set_list']:
-
- if not set_dict['is_superset']:
- for exercise_dict in set_dict['exercise_list']:
- exercise = exercise_dict['obj']
- for key, element in enumerate(exercise_dict['reps_list']):
- reps = exercise_dict['reps_list'][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]
- )
-
- step_list.append(
- {
- 'current_step': uuid.uuid4().hex,
- 'step_percent': 0,
- 'step_nr': len(step_list) + 1,
- 'exercise': exercise,
- 'type': 'exercise',
- 'reps': reps,
- '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,
- 'step_nr': len(step_list) + 1,
- 'type': 'pause',
- 'time': request.user.userprofile.timer_pause
- }
- )
-
- # Supersets need extra work to group the exercises and reps together
- else:
- total_reps = len(set_dict['exercise_list'][0]['reps_list'])
- for i in range(0, total_reps):
- for exercise_dict in set_dict['exercise_list']:
- reps = exercise_dict['reps_list'][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']
-
- step_list.append(
- {
- 'current_step': uuid.uuid4().hex,
- 'step_percent': 0,
- 'step_nr': len(step_list) + 1,
- 'exercise': exercise,
- 'type': 'exercise',
- 'reps': reps,
- 'rep_unit': rep_unit,
- 'weight_unit': weight_unit,
- 'weight': last_log.get_last_weight(exercise, reps, default_weight)
- }
- )
-
- if request.user.userprofile.timer_active:
- step_list.append(
- {
- 'current_step': uuid.uuid4().hex,
- 'step_percent': 0,
- 'step_nr': len(step_list) + 1,
- 'type': 'pause',
- 'time': 90
- }
- )
-
- # Remove the last pause step as it is not needed. If the list is empty,
- # because the user didn't add any repetitions to any exercise, do nothing
- try:
- step_list.pop()
- except IndexError:
- pass
-
- # Go through the page list and calculate the correct value for step_percent
- for i, s in enumerate(step_list):
- step_list[i]['step_percent'] = (i + 1) * 100.0 / len(step_list)
-
- # Depending on whether there is already a workout session for today, update
- # the current one or create a new one (this will be the most usual case)
- if WorkoutSession.objects.filter(user=request.user, date=datetime.date.today()).exists():
- session = WorkoutSession.objects.get(user=request.user, date=datetime.date.today())
- session_form = WorkoutSessionHiddenFieldsForm(instance=session)
- else:
- session_form = WorkoutSessionHiddenFieldsForm()
-
- # Render template
- context['day'] = day
- context['step_list'] = step_list
- context['canonical_day'] = canonical_day
- context['workout'] = day.training
- context['session_form'] = session_form
- context['weight_units'] = WeightUnit.objects.all()
- context['repetition_units'] = RepetitionUnit.objects.all()
- return render(request, 'workout/timer.html', context)