Self hosted FLOSS fitness/workout, nutrition and weight tracker
Refactor to code style
Peter van der Doesdf223420e880
diff --git a/wger/core/static/js/wger-core.js b/wger/core/static/js/wger-core.jsindex 266ba41a9..1f54ec540 100644--- a/wger/core/static/js/wger-core.js+++ b/wger/core/static/js/wger-core.js@@ -1,700 +1,716 @@/*- * 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- */+ This file is part of wger Workout Manager.-/*jslint browser: true*/-/*global $, jQuery, alert*/+ 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.-/*- * Own functions- *+ You should have received a copy of the GNU Affero General Public License*/--"use strict";-+'use strict';/*- * AJAX related functions- *- * See https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax for- * more information+ AJAX related functions++ See https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax for+ more information*/function getCookie(name) {- var cookieValue = null;- if (document.cookie && document.cookie != '') {- var cookies = document.cookie.split(';');- for (var i = 0; i < cookies.length; i++) {- var cookie = jQuery.trim(cookies[i]);- // Does this cookie string begin with the name we want?- if (cookie.substring(0, name.length + 1) == (name + '=')) {- cookieValue = decodeURIComponent(cookie.substring(name.length + 1));- break;- }- }+ var cookie;+ var cookies;+ var cookieValue = null;+ var loopCounter;+ if (document.cookie && document.cookie !== '') {+ cookies = document.cookie.split(';');+ for (loopCounter = 0; loopCounter < cookies.length; loopCounter++) {+ cookie = jQuery.trim(cookies[loopCounter]);+ // Does this cookie string begin with the name we want?+ if (cookie.substring(0, name.length + 1) === (name + '=')) {+ cookieValue = decodeURIComponent(cookie.substring(name.length + 1));+ break;+ }}- return cookieValue;+ }+ return cookieValue;}-function csrfSafeMethod(method) {- // these HTTP methods do not require CSRF protection- return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));+ // These HTTP methods do not require CSRF protection+ return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));}$.ajaxSetup({- crossDomain: false, // obviates need for sameOrigin test- beforeSend: function(xhr, settings) {- if (!csrfSafeMethod(settings.type)) {- xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));- }+ crossDomain: false, // obviates need for sameOrigin test+ beforeSend: function (xhr, settings) {+ if (!csrfSafeMethod(settings.type)) {+ xhr.setRequestHeader('X-CSRFToken', getCookie('csrftoken'));}+ }});+function getCurrentLanguage() {+ // Returns a short name, like 'en' or 'de'+ return $('#current-language').data('currentLanguage');+}/*- * Others+ Setup sortable to make the sets sortable*/-function get_current_language() {- /* Returns a short name, like 'en' or 'de' */- return $('#current-language').data('currentLanguage');+function wgerSetupSortable() {+ var elements = document.getElementsByTagName('tbody');+ $.each(elements, function (index, element) {+ Sortable.create(element, {+ handle: '.dragndrop-handle',+ animation: 150,+ onUpdate: function (event) {+ var dayId;+ dayId = $(event.target).parents('table').data('id');+ $.each(($(event.from).children('tr')), function (eventIndex, eventElement) {+ var trElement;+ var setId;+ trElement = $(eventElement);++ // The last table element has no ID attribute (has only the 'add exercise' link+ if (trElement.data('id')) {+ setId = trElement.data('id');+ $.ajax({+ url: '/api/v2/set/' + setId + '/',+ type: 'PATCH',+ data: { order: eventIndex + 1 }+ });+ }+ });++ // Replace the content of the table with a fresh version that has+ // correct indexes.+ $.get('/' + getCurrentLanguage() + '/workout/day/' + dayId + '/view/');+ $('#div-day-' + dayId)+ .load('/' + getCurrentLanguage() + '/workout/day/' + dayId + '/view/');+ }+ });+ });}+/*+ Functions related to the user's preferences+ *//*- * Setup sortable to make the sets sortable+ Updates a single field in the user profile*/-function setup_sortable() {- var elements = document.getElementsByTagName('tbody');- $.each(elements, function(index, element) {- Sortable.create(element, {- handle: '.dragndrop-handle',- animation: 150,- onUpdate: function (event) {- var day_id = $(event.target).parents('table').data('id');- $.each(($(event.from).children('tr')), function(index, tr_element) {- var tr_element = $(tr_element);-- // The last table element has no ID attribute (has only the- // 'add exercise' link- if( tr_element.data('id') )- {- var set_id = tr_element.data('id');- $.ajax({- url:'/api/v2/set/' + set_id + '/',- type: 'PATCH',- data: {'order': index + 1}- }).done(function(data) {- //console.log(data);- });- }- });-- // Replace the content of the table with a fresh version that has- // correct indexes.- $.get('/' + get_current_language() + "/workout/day/" + day_id + "/view/");- $("#div-day-" + day_id).load('/' + get_current_language() + "/workout/day/" + day_id + "/view/");- }- });+function setProfileField(field, newValue) {+ var dataDict = {};+ dataDict[field] = newValue;+ $.get('/api/v2/userprofile', function () {+ }).done(function (userprofile) {+ console.log('Updating profile field "' + field + '" to value: ' + newValue);+ $.ajax({+ url: '/api/v2/userprofile/' + userprofile.results[0].id + '/',+ type: 'PATCH',+ data: dataDict});+ });}--+/*+ Get a single field from the user's profile.+ Synchronous request, use sparingly!+ */+function getProfileField(field) {+ var result;+ result = null;+ $.ajax({+ url: '/api/v2/userprofile/',+ type: 'GET',+ async: false,+ success: function (userprofile) {+ result = userprofile.results[0][field];+ }+ });+ return result;+}/*- *- * Functions related to the user's preferences- *+ Get the current user's username.+ Do not use with anonymous users!+ Synchronous request, use sparingly!*/-function set_profile_field(field, newValue) {- /*- * Updates a single field in the user profile- */-- var dataDict = new Object;- dataDict[field] = newValue;- $.get('/api/v2/userprofile', function(data) {- }).done(function(userprofile) {- console.log('Updating profile field "' + field + '" to value: ' + newValue);- $.ajax({- url:'/api/v2/userprofile/' + userprofile.results[0].id + '/',- type: 'PATCH',- data: dataDict- });- });+function wgerGetUsername() {+ var userId;+ var result;+ userId = getProfileField('user');+ result = null;+ $.ajax({+ url: '/api/v2/userprofile/' + userId + '/username/',+ type: 'GET',+ async: false,+ success: function (user) {+ result = user.username;+ }+ });+ return result;}+function wgerToggleComments() {+ $('#exercise-comments-toggle').click(function (e) {+ var showComment;+ e.preventDefault();-function get_username() {- /*- * Get the current user's username- *- * Do not use with anonymous users!- *- * Synchronous request, use sparingly!- */+ showComment = getProfileField('show_comments');+ if (!showComment) {+ $('.exercise-comments').show();+ } else {+ $('.exercise-comments').hide();+ }- var user_id = get_profile_field('user');- var result;- $.ajax({- url:'/api/v2/userprofile/' + user_id + '/username/',- type: 'GET',- async: false,- success: function(user) {- result = user.username;- }- });- return result;+ // Update user profile+ setProfileField('show_comments', !showComment);+ });}+function wgerToggleReadOnlyAccess() {+ $('#toggle-ro-access').click(function (e) {+ var $shariffModal;+ var roAccess;+ e.preventDefault();+ roAccess = getProfileField('ro_access');++ // Update user profile+ setProfileField('ro_access', !roAccess);++ // Hide and show appropriate divs++ $shariffModal = $('#shariffModal');+ if (!roAccess) {+ $shariffModal.find('.shariff').removeClass('hidden');+ $shariffModal.find('.noRoAccess').addClass('hidden');+ } else {+ $shariffModal.find('.shariff').addClass('hidden');+ $shariffModal.find('.noRoAccess').removeClass('hidden');+ }+ });+}-function get_profile_field(field) {- /*- * Get a single field from the user's profile- *- * Synchronous request, use sparingly!- */-- var result;- $.ajax({- url:'/api/v2/userprofile/',- type: 'GET',- async: false,- success: function(userprofile) {- result = userprofile.results[0][field];- }+/*+ Init calls for tinyMCE editor+ */+function wgerInitTinymce() {+ // Only try to init it on pages that loaded its JS file (so they probably need it)+ //+ // See the following links on detail about configuring the menus+ // http://www.tinymce.com/wiki.php/Configuration:toolbar+ // http://www.tinymce.com/wiki.php/Configuration:menu+ if (typeof tinyMCE !== 'undefined') {+ tinyMCE.init({+ // General options+ mode: 'textareas',+ theme: 'modern',+ width: '100%',+ height: '200',+ entity_encoding: 'raw',+ menu: {},+ toolbar: 'undo redo | bold italic | bullist numlist '});- return result;+ }}-function toggle_comments() {- $("#exercise-comments-toggle").click(function (e) {- e.preventDefault();-- var showComment = get_profile_field('show_comments');- if(!showComment) {- $('.exercise-comments').show();+/*+ Open a modal dialog for form editing+ */+function modalDialogFormEdit() {+ var $submit;+ var $form;+ $form = $('#ajax-info-content').find('form');+ $submit = $($form).find('#form-save');++ $submit.click(function (e) {+ var formData;+ var formAction;+ e.preventDefault();+ formAction = $form.attr('action');+ formData = $form.serialize();++ // Unbind all click elements, so the form doesn't get submitted twice+ // if the user clicks 2 times on the button (while there is already a request+ // happening in the background)+ $submit.off();++ // Show a loader while we fetch the real page+ $form.html('<div style="text-align:center;">' ++ '<img src="/static/images/loader.svg" ' ++ 'width="48" ' ++ 'height="48"> ' ++ '</div>');+ $('#ajax-info-title').html('Processing'); // TODO: translate this++ // OK, we did the POST, what do we do with the result?+ $.ajax({+ type: 'POST',+ url: formAction,+ data: formData,+ beforeSend: function (jqXHR) {+ // Send a custom header so django's messages are not displayed in the next+ // request which will be not be displayed to the user, but on the next one+ // that will+ jqXHR.setRequestHeader('X-wger-no-messages', '1');+ },+ success: function (data, textStatus, jqXHR) {+ var url = jqXHR.getResponseHeader('X-wger-redirect');+ if (url) {+ window.location.href = url;+ /*+ if(document.URL.indexOf(url)) {+ history.pushState({}, "", url);+ }+ */+ } else if ($(data).find('form .has-error').length > 0) {+ // we must do the same with the new form as before, binding the click-event,+ // checking for errors etc, so it calls itself here again.+ $form.html($(data).find('form').html());+ $('#ajax-info-title').html($(data).find('#page-title').html());+ modalDialogFormEdit();} else {- $('.exercise-comments').hide();+ console.log('No X-wger-redirect found but also no .has-error!');+ $('#wger-ajax-info').modal('hide');+ $form.html(data);}- // Update user profile- set_profile_field('show_comments', !showComment);+ // Call other custom initialisation functions+ // (e.g. if the form as an autocompleter, it has to be initialised again)+ if (typeof wgerCustomModalInit !== 'undefined') {+ wgerCustomModalInit(); // eslint-disable-line no-undef+ }++ if (typeof wgerCustomPageInit !== 'undefined') {+ wgerCustomPageInit(); // eslint-disable-line no-undef+ }+ },+ error: function (jqXHR) {+ // console.log(errorThrown); // INTERNAL SERVER ERROR+ $('#ajax-info-content').html(jqXHR.responseText);+ }});+ });}+function wgerFormModalDialog() {+ var $wgerModalDialog;+ $wgerModalDialog = $('.wger-modal-dialog');+ // Unbind all other click events so we don't do this more than once+ $wgerModalDialog.off();++ // Load the edit dialog when the user clicks on an edit link+ $wgerModalDialog.click(function (e) {+ var $ajaxInfoContent;+ var targetUrl;+ e.preventDefault();+ targetUrl = $(this).attr('href');++ // It's not possible to have more than one modal open at any time, so close them+ $('.modal').modal('hide');++ // Show a loader while we fetch the real page+ $ajaxInfoContent = $('#ajax-info-content');+ $ajaxInfoContent.html('<div style="text-align:center;">' ++ '<img src="/static/images/loader.svg" ' ++ 'width="48" ' ++ 'height="48"> ' ++ '</div>');+ $('#ajax-info-title').html('Loading...');+ $('#wger-ajax-info').modal('show');++ $ajaxInfoContent.load(targetUrl + ' .form-horizontal',+ function (responseText, textStatus, XMLHttpRequest) {+ var $ajaxInfoTitle;+ var modalTitle;+ $ajaxInfoTitle = $('#ajax-info-title');+ if (textStatus === 'error') {+ $ajaxInfoTitle.html('Sorry but an error occured');+ $('#ajax-info-content').html(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);+ }-function toggle_ro_access() {- $("#toggle-ro-access").click(function (e) {- e.preventDefault();- var ro_access = get_profile_field('ro_access');-- // Update user profile- set_profile_field('ro_access', !ro_access);+ // Call other custom initialisation functions+ // (e.g. if the form as an autocompleter, it has to be initialised again)+ if (typeof wgerCustomModalInit !== 'undefined') {+ // Function is defined in templates. Eslint doesn't check the templates resulting in a+ // un-def error message.+ wgerCustomModalInit(); // eslint-disable-line no-undef+ }- // Hide and show appropriate divs- if(!ro_access) {- $('#shariffModal .shariff').removeClass('hidden');- $('#shariffModal .noRoAccess').addClass('hidden');+ // Set the new title+ modalTitle = '';+ if ($(responseText).find('#page-title').length > 0) {+ // Complete HTML page+ modalTitle = $(responseText).find('#page-title').html();+ } else {+ // Page fragment+ modalTitle = $(responseText).filter('#page-title').html();}- else {- $('#shariffModal .shariff').addClass('hidden');- $('#shariffModal .noRoAccess').removeClass('hidden');+ $ajaxInfoTitle.html(modalTitle);++ // If there is a form in the modal dialog (there usually is) prevent the submit+ // button from submitting it and do it here with an AJAX request. If there+ // are errors (there is an element with the class 'ym-error' in the result)+ // reload the content back into the dialog so the user can correct the entries.+ // If there isn't assume all was saved correctly and load that result into the+ // page's main DIV (#main-content). All this must be done like this because there+ // doesn't seem to be any reliable and easy way to detect redirects with AJAX.+ if ($(responseText).find('.form-horizontal').length > 0) {+ modalDialogFormEdit();}- });+ });+ });}-/*- * Init calls for tinyMCE editor+ Returns a random hex string. This is useful, e.g. to add a unique ID to generated+ HTML elements*/-function init_tinymce() {-- // Only try to init it on pages that loaded its JS file (so they probably need it)- //- // See the following links on detail about configuring the menus- // http://www.tinymce.com/wiki.php/Configuration:toolbar- // http://www.tinymce.com/wiki.php/Configuration:menu- if (typeof tinyMCE !== 'undefined') {- tinyMCE.init({- // General options- mode : "textareas",- theme : "modern",- width : "100%",- height : "200",- entity_encoding : "raw",- menu: {},- toolbar: "undo redo | bold italic | bullist numlist "- });- }-}+function getRandomHex() {+ return Math.floor(+ Math.random() * 0x10000 // 65536+ ).toString(16);+}/*- * Open a modal dialog for form editing+ Template-like function that adds form elements to the ajax exercise selection in the edit set page*/-function form_modal_dialog() {- // Unbind all other click events so we don't do this more than once- $(".wger-modal-dialog").off();-- // Load the edit dialog when the user clicks on an edit link- $(".wger-modal-dialog").click(function (e) {- e.preventDefault();- var targetUrl = $(this).attr("href");-- // It's not possible to have more than one modal open at any time, so close them- $('.modal').modal('hide');-- // Show a loader while we fetch the real page- $("#ajax-info-content").html('<div style="text-align:center;">' +- '<img src="/static/images/loader.svg" ' +- 'width="48" ' +- 'height="48"> ' +- '</div>');- $("#ajax-info-title").html('Loading...');- $("#wger-ajax-info").modal("show");-- $("#ajax-info-content").load(targetUrl + " .form-horizontal",- function(responseText, textStatus, XMLHttpRequest){-- if (textStatus == "error") {- $("#ajax-info-title").html("Sorry but an error occured")- $("#ajax-info-content").html(XMLHttpRequest.status + " " + XMLHttpRequest.statusText);- }-- // Call other custom initialisation functions- // (e.g. if the form as an autocompleter, it has to be initialised again)- if (typeof custom_modal_init !== "undefined") {- custom_modal_init();- }-- // Set the new title- var modal_title = '';- if ($(responseText).find("#page-title").length > 0) {- // Complete HTML page- modal_title = $(responseText).find("#page-title").html();- }- else {- // Page fragment- modal_title = $(responseText).filter("#page-title").html();- }- $("#ajax-info-title").html(modal_title);-- // If there is a form in the modal dialog (there usually is) prevent the submit- // button from submitting it and do it here with an AJAX request. If there- // are errors (there is an element with the class 'ym-error' in the result)- // reload the content back into the dialog so the user can correct the entries.- // If there isn't assume all was saved correctly and load that result into the- // page's main DIV (#main-content). All this must be done like this because there- // doesn't seem to be any reliable and easy way to detect redirects with AJAX.- if ($(responseText).find(".form-horizontal").length > 0) {- modal_dialog_form_edit();- }- });- });+function addExercise(exercise) {+ var $exerciseSearchLog;+ var resultDiv;+ resultDiv = '<div id="DIV-ID" class="ajax-exercise-select">\n' ++ ' <a href="#" ' ++ 'data-role="button" ' ++ 'class="btn btn-default btn-xs" ' ++ 'style="margin-top: 0.5em;">\n' ++ ' <span class="fa fa-times fa-fw"></span>\n' ++ ' EXERCISE\n' ++ ' </a>\n' ++ ' <input type="hidden" name="exercises" value="EXCERCISE-ID">\n' ++ '</div>';++ // Replace the values into the 'template'+ resultDiv = resultDiv.replace('DIV-ID', getRandomHex());+ resultDiv = resultDiv.replace('EXERCISE', exercise.value);+ resultDiv = resultDiv.replace('EXCERCISE-ID', exercise.id);++ $(resultDiv).appendTo('#exercise-search-log');+ $exerciseSearchLog = $('#exercise-search-log');+ $exerciseSearchLog.scrollTop(0);+ $exerciseSearchLog.trigger('create');}--function modal_dialog_form_edit() {- var form = $("#ajax-info-content").find("form");- var submit = $(form).find("#form-save");-- submit.click(function (e) {- e.preventDefault();- var form_action = form.attr('action');- var form_data = form.serialize();-- // Unbind all click elements, so the form doesn't get submitted twice- // if the user clicks 2 times on the button (while there is already a request- // happening in the background)- submit.off();-- // Show a loader while we fetch the real page- $("#ajax-info-content form").html('<div style="text-align:center;">' +- '<img src="/static/images/loader.svg" ' +- 'width="48" ' +- 'height="48"> ' +- '</div>');- $("#ajax-info-title").html('Processing'); // TODO: translate this--- // OK, we did the POST, what do we do with the result?- $.ajax({- type: "POST",- url: form_action,- data: form_data,- beforeSend: function (jqXHR, settings) {- // Send a custom header so django's messages are not displayed in the next- // request which will be not be displayed to the user, but on the next one- // that will- jqXHR.setRequestHeader("X-wger-no-messages", "1");- },- success: function (data, textStatus, jqXHR) {- var url = jqXHR.getResponseHeader('X-wger-redirect');- if (url) {- window.location.href = url;- /*- if(document.URL.indexOf(url)) {- history.pushState({}, "", url);- }- */- }- else {-- if ($(data).find('form .has-error').length > 0) {- // we must do the same with the new form as before, binding the click-event,- // checking for errors etc, so it calls itself here again.- $("#ajax-info-content form").html($(data).find('form').html());- $("#ajax-info-title").html($(data).find("#page-title").html());- modal_dialog_form_edit();- }- else {- console.log('No X-wger-redirect found but also no .has-error!');- $("#wger-ajax-info").modal("hide");- $("#ajax-info-content form").html(data);- }-- }-- // Call other custom initialisation functions- // (e.g. if the form as an autocompleter, it has to be initialised again)- if (typeof custom_modal_init !== "undefined") {- custom_modal_init();- }-- if (typeof custom_page_init !== "undefined") {- custom_page_init();- }- },- error: function (jqXHR, textStatus, errorThrown) {- //console.log(errorThrown); // INTERNAL SERVER ERROR- $("#ajax-info-content").html(jqXHR.responseText);- }- });+function getExerciseFormset(exerciseId) {+ var formsetUrl;+ var setValue;+ setValue = $('#id_sets').val();+ if (setValue && parseInt(setValue, 10) && exerciseId && parseInt(exerciseId, 10)) {+ formsetUrl = '/' + getCurrentLanguage() ++ '/workout/set/get-formset/' + exerciseId ++ '/' + setValue + '/';++ $.get(formsetUrl, function (data) {+ var $formsets;+ $formsets = $('#formsets');+ $formsets.append(data);+ $('#exercise-search-log').scrollTop(0);+ $formsets.trigger('create');});-+ }}--/*- * Returns a random hex string. This is useful, e.g. to add a unique ID to generated- * HTML elements+ Updates all exercise formsets, e.g. when the number of sets changed*/-function hex_random() {- return Math.floor(- Math.random() * 0x10000 /* 65536 */- ).toString(16);+function updateAllExerciseFormset() {+ var setValue;+ setValue = $('#id_sets').val();+ if (setValue && parseInt(setValue, 10)) {+ $.each($('#exercise-search-log').find('input'), function (index, value) {+ var promise;+ var exerciseId;+ var formsetUrl;+ exerciseId = value.value;+ promise = $().promise();+ if (exerciseId && parseInt(exerciseId, 10)) {+ formsetUrl = '/' + getCurrentLanguage() ++ '/workout/set/get-formset/' + exerciseId ++ '/' + setValue + '/';+ promise.done(function () {+ promise = $.get(formsetUrl, function (data) {+ var $formsets;+ $('#formset-exercise-' + exerciseId).remove();+ $formsets = $('#formsets');+ $formsets.append(data);+ $('#exercise-search-log').scrollTop(0);+ $formsets.trigger('create');+ }).promise();+ });+ }+ });+ }}-/*- * Template-like function that adds form elements to the ajax exercise selection- * in the edit set page+ Remove the result DIV (also contains the hidden form element) with the exercise+ formsets when the user clicks on the delete link*/-function add_exercise(exercise) {- var result_div = '<div id="DIV-ID" class="ajax-exercise-select"> \-<a href="#" data-role="button" class="btn btn-default btn-xs" style="margin-top: 0.5em;"> \-<span class="fa fa-times fa-fw"></span> \-EXERCISE \-</a> \-<input type="hidden" name="exercises" value="EXCERCISE-ID"> \-</div>';-- // Replace the values into the 'template'- result_div = result_div.replace('DIV-ID', hex_random());- result_div = result_div.replace('EXERCISE', exercise.value);- result_div = result_div.replace('EXCERCISE-ID', exercise.id);-- $(result_div).appendTo("#exercise-search-log");- $("#exercise-search-log").scrollTop(0);- $('#exercise-search-log').trigger('create');-}--function get_exercise_formset(exercise_id) {- var set_value = $('#id_sets').val();- if (set_value && parseInt(set_value, 10) && exercise_id && parseInt(exercise_id, 10)) {- var formset_url = '/' + get_current_language() +- '/workout/set/get-formset/' + exercise_id +- '/' + set_value + '/';-- $.get(formset_url, function (data) {- $('#formsets').append(data);- $("#exercise-search-log").scrollTop(0);- $('#formsets').trigger("create");- });- }+function initRemoveExerciseFormset() {+ $('.ajax-exercise-select a').click(function (e) {+ var exerciseId;+ e.preventDefault();+ exerciseId = $(this).parent('div').find('input').val();+ $('#formset-exercise-' + exerciseId).remove();+ $(this).parent('div').remove();+ });}-// Updates all exercise formsets, e.g. when the number of sets changed-function update_all_exercise_formset() {- var set_value = $('#id_sets').val();- if (set_value && parseInt(set_value, 10)) {- $.each($('#exercise-search-log input'), function (index, value) {-- var exercise_id = value.value;- var promise = $().promise();- if (exercise_id && parseInt(exercise_id, 10)) {- var formset_url = '/' + get_current_language() +- '/workout/set/get-formset/' + exercise_id +- '/' + set_value + '/';- promise.done(function(){- promise = $.get(formset_url, function (data) {- $('#formset-exercise-' + exercise_id).remove();- $('#formsets').append(data);- $('#exercise-search-log').scrollTop(0);- $('#formsets').trigger("create");- }).promise();- });+function wgerInitEditSet() {+ // Initialise the autocompleter (our widget, defined above)+ $('#exercise-search').devbridgeAutocomplete({+ serviceUrl: '/api/v2/exercise/search/?language=' + getCurrentLanguage(),+ showNoSuggestionNotice: true,+ onSelect: function (suggestion) {+ // Add the exercise to the list+ addExercise({+ id: suggestion.data.id,+ value: suggestion.value+ });++ // Load formsets+ getExerciseFormset(suggestion.data.id);++ // Init the remove buttons+ initRemoveExerciseFormset();++ // Reset the autocompleter+ $(this).val('');+ return false;+ },+ groupBy: 'category',+ paramName: 'term',+ transformResult: function (response) {+ // why is response not already a JSON object??+ var jsonResponse = $.parseJSON(response);+ return {+ suggestions: $.map(jsonResponse, function (item) {+ return {+ value: item.value,+ data: {+ id: item.id,+ category: item.category,+ image: item.image,+ thumbnail: item.image_thumbnail}- });+ };+ })+ };}-}--/*- * Remove the result DIV (also contains the hidden form element) with the exercise- * formsets when the user clicks on the delete link- */-function init_remove_exercise_formset() {- $(".ajax-exercise-select a").click(function (e) {- e.preventDefault();- var exercise_id = $(this).parent('div').find('input').val();- $('#formset-exercise-' + exercise_id).remove();- $(this).parent('div').remove();- });-}--function init_edit_set() {- // Initialise the autocompleter (our widget, defined above)- $('#exercise-search').devbridgeAutocomplete({- serviceUrl: '/api/v2/exercise/search/?language=' + get_current_language(),- showNoSuggestionNotice: true,- onSelect: function (suggestion) {- // Add the exercise to the list- add_exercise({id: suggestion.data.id,- value: suggestion.value});-- // Load formsets- get_exercise_formset(suggestion.data.id);-- // Init the remove buttons- init_remove_exercise_formset();-- // Reset the autocompleter- $(this).val("");- return false;- },- groupBy: 'category',- paramName: 'term',- transformResult: function(response) {- // why is response not already a JSON object??- var jsonResponse = $.parseJSON(response);- return {- suggestions: $.map(jsonResponse, function(item) {- return {value: item.value, data: {id: item.id,- category: item.category,- image: item.image,- thumbnail: item.image_thumbnail}};- })- };- }- });-- // Mobile select box- $('#id_exercise_list').change(function (e) {- var exercise_id = $('#id_exercise_list').val();- var exercise_name = $('#id_exercise_list').find(":selected").text();- add_exercise({id: exercise_id,- value: exercise_name});- get_exercise_formset(exercise_id);- init_remove_exercise_formset();- });-- // Delete button next to exercise- init_remove_exercise_formset();-- // Slider to set the number of sets- $("#id_sets").on("change", function() {- update_all_exercise_formset();- $('#id_sets_value').html($("#id_sets").val());+ });++ // Mobile select box+ $('#id_exercise_list').change(function () {+ var $idExerciseList;+ var exerciseId;+ var exerciseName;+ $idExerciseList = $('#id_exercise_list');+ exerciseId = $idExerciseList.val();+ exerciseName = $idExerciseList.find(':selected').text();+ addExercise({+ id: exerciseId,+ value: exerciseName});+ getExerciseFormset(exerciseId);+ initRemoveExerciseFormset();+ });++ // Delete button next to exercise+ initRemoveExerciseFormset();++ // Slider to set the number of sets+ $('#id_sets').on('change', function () {+ updateAllExerciseFormset();+ $('#id_sets_value').html($('#id_sets').val());+ });++ /*+ * Mobile version only+ */+ // Update the exercise list when the categories change+ $('#id_categories_list').on('change', function () {+ // Remember to filter by exercise language+ $.get('/api/v2/language/?short_name=' + getCurrentLanguage(), function (data) {+ var filter;+ var baseUrl;+ var categoryPk;+ var languagePk;+ languagePk = data.results[0].id;+ categoryPk = $('#id_categories_list').val();+ baseUrl = '/api/v2/exercise/';+ filter = '?limit=999&language=' + languagePk;++ if (categoryPk !== '') {+ filter += '&category=' + categoryPk;+ }++ $.get(baseUrl + filter, function (exerciseData) {+ // Sort the results by name, at the moment it's not possible+ // to search and sort the API at the same time+ var $idExerciseList;+ exerciseData.results.sort(function (a, b) {+ if (a.name < b.name) {+ return -1;+ }+ if (a.name > b.name) {+ return 1;+ }+ return 0;+ });+ // Remove existing options+ $idExerciseList = $('#id_exercise_list');+ $idExerciseList+ .find('option')+ .remove();- /*- * Mobile version only- */- // Update the exercise list when the categories change- $("#id_categories_list").on("change", function() {-- // Remember to filter by exercise language- $.get('/api/v2/language/?short_name=' + get_current_language(), function(data){- var language_pk = data.results[0].id;- var category_pk = $("#id_categories_list").val();- var base_url = '/api/v2/exercise/';- var filter = '?limit=999&language=' + language_pk;-- if (category_pk != '') {- filter += '&category=' + category_pk;- }-- $.get(base_url + filter, function(data){-- // Sort the results by name, at the moment it's not possible- // to search and sort the API at the same time- data.results.sort(function(a, b) {- if (a.name < b.name) {- return -1;- }- if (a.name > b.name) {- return 1;- }- return 0- });-- // Remove existing options- $('#id_exercise_list')- .find('option')- .remove();-- // ..and add the new ones- $("#id_exercise_list").append(new Option('---------', ''));- $.each(data.results, function(index, exercise) {- $("#id_exercise_list").append(new Option(exercise.name, exercise.id));- });- });+ // ..and add the new ones+ $idExerciseList.append(new Option('---------', ''));+ $.each(exerciseData.results, function (index, exercise) {+ $('#id_exercise_list').append(new Option(exercise.name, exercise.id));});+ });});+ });}-/*- *- * Helper function to load the target of a link into the main-content DIV (the- * main left colum)- *+ Helper function to load the target of a link into the main-content DIV (the main left colum)*/-function load_maincontent() {- $(".load-maincontent").click(function (e) {- e.preventDefault();- var targetUrl = $(this).attr("href");-- $.get(targetUrl, function (data) {- // Load the data- $('#main-content').html($(data).find('#main-content').html());-- // Update the browser's history- var current_url = $(data).find("#current-url").data('currentUrl');- history.pushState({}, "", current_url);-- load_maincontent();- });+function wgerLoadMaincontent() {+ $('.load-maincontent').click(function (e) {+ var targetUrl;+ e.preventDefault();+ targetUrl = $(this).attr('href');++ $.get(targetUrl, function (data) {+ var currentUrl;+ // Load the data+ $('#main-content').html($(data).find('#main-content').html());++ // Update the browser's history+ currentUrl = $(data).find('#current-url').data('currentUrl');+ history.pushState({}, '', currentUrl);++ wgerLoadMaincontent();});+ });}/*- * Helper function to prefetch images on a page+ Helper function to prefetch images on a page*/-function prefetch_images(imageArray) {- $(imageArray).each(function () {- (new Image()).src = this;- //console.log('Preloading image' + this);- });+function wgerPrefetchImages(imageArray) {+ $(imageArray).each(function () {+ (new Image()).src = this;+ // console.log('Preloading image' + this);+ });}-/*- * Helper function used in the workout log dialog to fetch existing- * workout sessions through the REST API+ Helper function used in the workout log dialog to fetch existing workout sessions through the+ REST API*/- function get_workout_session() {- $('#id_date').on('change', function() {- var date = $('#id_date').val();- if(date) {- $.get( '/api/v2/workoutsession/?date=' + date, function(data) {- if (data.results.length == 1) {- $('#id_notes').val(data.results[0].notes)- $('#id_impression').val(data.results[0].impression)- $('#id_time_start').val(data.results[0].time_start)- $('#id_time_end').val(data.results[0].time_end)- }- else {- $('#id_notes').val('');- $('#id_impression').val('2');- $('#id_time_start').val('');- $('#id_time_end').val('');- }- });+function wgerGetWorkoutSession() {+ $('#id_date').on('change', function () {+ var date = $('#id_date').val();+ if (date) {+ $.get('/api/v2/workoutsession/?date=' + date, function (data) {+ if (data.results.length === 1) {+ $('#id_notes').val(data.results[0].notes);+ $('#id_impression').val(data.results[0].impression);+ $('#id_time_start').val(data.results[0].time_start);+ $('#id_time_end').val(data.results[0].time_end);+ } else {+ $('#id_notes').val('');+ $('#id_impression').val('2');+ $('#id_time_start').val('');+ $('#id_time_end').val('');}- });+ });+ }+ });}-/*- * Handle the workout PDF download options for workouts- */-$(document).ready(function() {- $('#download-pdf-button').click(function (e) {- e.preventDefault();-- var downloadInfo = $('#pdf-download-info');- var downloadType = $('input[name="pdf_type"]:checked').val();- var downloadImages = $('#id_images').is(':checked') ? 1 : 0;- var downloadComments = $('#id_comments').is(':checked') ? 1 : 0;-- var workoutId = downloadInfo.data('workoutId');- var uid = downloadInfo.data('uid');- var token = downloadInfo.data('token');-- // Put together and redirect- var targetUrl = '/' + get_current_language() +- '/workout/' + workoutId + '/pdf' +- '/' + downloadType +- '/' + downloadImages +- '/' + downloadComments +- '/' + uid +- '/' + token;- window.location.href = targetUrl;- });-});---/*- * Handle the workout PDF download options for schedules- */-$(document).ready(function() {- $('#download-pdf-button-schedule').click(function (e) {- e.preventDefault();-- var downloadInfo = $('#pdf-download-info');- var downloadType = $('input[name="pdf_type"]:checked').val();- var downloadImages = $('#id_images').is(':checked') ? 1 : 0;- var downloadComments = $('#id_comments').is(':checked') ? 1 : 0;-- var scheduleId = downloadInfo.data('scheduleId');- var uid = downloadInfo.data('uid');- var token = downloadInfo.data('token');-- // Put together and redirect- var targetUrl = '/' + get_current_language() +- '/workout/schedule/' +scheduleId + '/pdf' +- '/' + downloadType +- '/' + downloadImages +- '/' + downloadComments +- '/' + uid +- '/' + token;- window.location.href = targetUrl;- });+$(document).ready(function () {+ // Handle the workout PDF download options for workouts+ $('#download-pdf-button').click(function (e) {+ var targetUrl;+ var token;+ var uid;+ var workoutId;+ var downloadComments;+ var downloadImages;+ var downloadType;+ var downloadInfo;+ e.preventDefault();++ downloadInfo = $('#pdf-download-info');+ downloadType = $('input[name="pdf_type"]:checked').val();+ downloadImages = $('#id_images').is(':checked') ? 1 : 0;+ downloadComments = $('#id_comments').is(':checked') ? 1 : 0;++ workoutId = downloadInfo.data('workoutId');+ uid = downloadInfo.data('uid');+ token = downloadInfo.data('token');++ // Put together and redirect+ targetUrl = '/' + getCurrentLanguage() ++ '/workout/' + workoutId + '/pdf' ++ '/' + downloadType ++ '/' + downloadImages ++ '/' + downloadComments ++ '/' + uid ++ '/' + token;+ window.location.href = targetUrl;+ });++ // Handle the workout PDF download options for schedules+ $('#download-pdf-button-schedule').click(function (e) {+ var targetUrl;+ var token;+ var uid;+ var scheduleId;+ var downloadComments;+ var downloadImages;+ var downloadType;+ var downloadInfo;+ e.preventDefault();++ downloadInfo = $('#pdf-download-info');+ downloadType = $('input[name="pdf_type"]:checked').val();+ downloadImages = $('#id_images').is(':checked') ? 1 : 0;+ downloadComments = $('#id_comments').is(':checked') ? 1 : 0;++ scheduleId = downloadInfo.data('scheduleId');+ uid = downloadInfo.data('uid');+ token = downloadInfo.data('token');++ // Put together and redirect+ targetUrl = '/' + getCurrentLanguage() ++ '/workout/schedule/' + scheduleId + '/pdf' ++ '/' + downloadType ++ '/' + downloadImages ++ '/' + downloadComments ++ '/' + uid ++ '/' + token;+ window.location.href = targetUrl;+ });});diff --git a/wger/core/templates/mobile/template.html b/wger/core/templates/mobile/template.htmlindex a4ce55ff7..b6f06a5c0 100644--- a/wger/core/templates/mobile/template.html+++ b/wger/core/templates/mobile/template.html@@ -81,16 +81,16 @@$('.row-offcanvas').toggleClass('active')});- if (typeof custom_page_init != "undefined")+ if (typeof wgerCustomPageInit != "undefined"){- custom_page_init();+ wgerCustomPageInit();}// Init the modal dialog for editing forms- form_modal_dialog();+ wgerFormModalDialog();// Check for RO-access before allowing sharing- toggle_ro_access();+ wgerToggleReadOnlyAccess();});</script>diff --git a/wger/core/templates/tags/render_day.html b/wger/core/templates/tags/render_day.htmlindex 1d6a5df1a..68eaf4962 100644--- a/wger/core/templates/tags/render_day.html+++ b/wger/core/templates/tags/render_day.html@@ -5,10 +5,10 @@ $(document).ready(function() {// Call the setup function to allow the sets to be sortable again after loading this// view via AJAX- setup_sortable();+ wgerSetupSortable();// Init the modal dialog to edit the exercise- form_modal_dialog();+ wgerFormModalDialog();})</script>diff --git a/wger/core/templates/template.html b/wger/core/templates/template.htmlindex 0084f3c6c..e073a617a 100644--- a/wger/core/templates/template.html+++ b/wger/core/templates/template.html@@ -76,19 +76,19 @@<script>$(document).ready(function() {- if (typeof custom_page_init != "undefined")+ if (typeof wgerCustomPageInit != "undefined"){- custom_page_init();+ wgerCustomPageInit();}// Init the modal dialog for editing forms- form_modal_dialog();+ wgerFormModalDialog();// Initialise the hook to reload the main-content- load_maincontent();+ wgerLoadMaincontent();// Check for RO-access before allowing sharing- toggle_ro_access();+ wgerToggleReadOnlyAccess();});</script>diff --git a/wger/exercises/models.py b/wger/exercises/models.pyindex d6f53fe22..c75b5c10b 100644--- a/wger/exercises/models.py+++ b/wger/exercises/models.py@@ -321,7 +321,7 @@ class Exercise(AbstractSubmissionModel, AbstractLicenseModel, models.Model):This is only used when creating exercises (via web or API)'''- if request.user.has_perm('exercises.add_exercise'):+ if request.user.has_perm('exercises.addExercise'):self.status = self.STATUS_ACCEPTEDif not self.license_author:self.license_author = request.get_host().split(':')[0]diff --git a/wger/exercises/templates/muscles/overview.html b/wger/exercises/templates/muscles/overview.htmlindex a3b405e48..ec54b3708 100644--- a/wger/exercises/templates/muscles/overview.html+++ b/wger/exercises/templates/muscles/overview.html@@ -14,9 +14,9 @@$(document).ready(function() {//Prefetch the background images{% for muscle in muscle_list|first %}- prefetch_images(['/static/images/muscles/main/muscle-' + {{muscle.id}} + '.svg']);+ wgerPrefetchImages(['/static/images/muscles/main/muscle-' + {{muscle.id}} + '.svg']);{% endfor %}- prefetch_images(['/static/images/muscles/muscular_system_back.svg']);+ wgerPrefetchImages(['/static/images/muscles/muscular_system_back.svg']);// Hightlight the first elementdiff --git a/wger/exercises/views/exercises.py b/wger/exercises/views/exercises.pyindex 793fceff9..7ebd8b168 100644--- a/wger/exercises/views/exercises.py+++ b/wger/exercises/views/exercises.py@@ -158,7 +158,7 @@ class ExercisesEditAddView(WgerFormMixin):model = Exercisesidebar = 'exercise/form.html'title = ugettext_lazy('Add exercise')- custom_js = 'init_tinymce();'+ custom_js = 'wgerInitTinymce();'clean_html = ('description', )def get_form_class(self):@@ -331,7 +331,7 @@ class PendingExerciseListView(LoginRequiredMixin, PermissionRequiredMixin, ListVreturn Exercise.objects.pending().order_by('-creation_date')-@permission_required('exercises.add_exercise')+@permission_required('exercises.addExercise')def accept(request, pk):'''Accepts a pending user submitted exercise and emails the user, if possible@@ -345,7 +345,7 @@ def accept(request, pk):return HttpResponseRedirect(exercise.get_absolute_url())-@permission_required('exercises.add_exercise')+@permission_required('exercises.addExercise')def decline(request, pk):'''Declines and deletes a pending user submitted exercisediff --git a/wger/manager/templates/day/log.html b/wger/manager/templates/day/log.htmlindex 9c9eb2d71..e82ddc4cf 100644--- a/wger/manager/templates/day/log.html+++ b/wger/manager/templates/day/log.html@@ -26,7 +26,7 @@{% block header %}<script type="text/javascript">$(document).ready(function () {- get_workout_session();+ wgerGetWorkoutSession();});</script>{% endblock %}diff --git a/wger/manager/templates/mobile/set/add.html b/wger/manager/templates/mobile/set/add.htmlindex 4735bef54..f0e4e1358 100644--- a/wger/manager/templates/mobile/set/add.html+++ b/wger/manager/templates/mobile/set/add.html@@ -15,7 +15,7 @@{% block header %}<script>$(document).ready(function() {- init_edit_set();+ wgerInitEditSet();});</script>{% endblock %}@@ -71,4 +71,4 @@ automatically becomes "4 x 10".{% endblocktrans %}</span></div>{% render_form_submit %}</form>-{% endblock %}\ No newline at end of file+{% endblock %}diff --git a/wger/manager/templates/mobile/workout/view.html b/wger/manager/templates/mobile/workout/view.htmlindex 6c5a49915..7480f3e40 100644--- a/wger/manager/templates/mobile/workout/view.html+++ b/wger/manager/templates/mobile/workout/view.html@@ -24,10 +24,10 @@{# #}{% block header %}<script>-function custom_modal_init()+function wgerCustomModalInit(){// Set up the edit set functions on modal dialogs- init_edit_set();+ wgerInitEditSet();}@@ -40,7 +40,7 @@ $(document).ready(function() {{% else %}$(".exercise-comments").hide();{% endif %}- toggle_comments();+ wgerToggleComments();});</script>@@ -77,7 +77,7 @@ $(document).ready(function() {<a href="{% url 'manager:day:add' workout.id %}" {% auto_link_css flavour "wger-modal-dialog" %}>{% trans "Add training day" %}</a>-+<a id="exercise-comments-toggle"href="{% url 'core:user:preferences' %}"{% auto_link_css flavour %}>diff --git a/wger/manager/templates/schedule/view.html b/wger/manager/templates/schedule/view.htmlindex 62adc5df4..d3edf40b5 100644--- a/wger/manager/templates/schedule/view.html+++ b/wger/manager/templates/schedule/view.html@@ -51,7 +51,7 @@$.get(current_url, function(data) {$('#schedule-table').html($(data).find('#schedule-table').html());init_sortable();- form_modal_dialog();+ wgerFormModalDialog();});}});@@ -351,4 +351,4 @@ an appointment for each training day with the appropriate exercises.{% endblockt{% endif %}</ul></div>-{% endblock %}\ No newline at end of file+{% endblock %}diff --git a/wger/manager/templates/set/add.html b/wger/manager/templates/set/add.htmlindex a19cc4ed9..1449d0a0e 100644--- a/wger/manager/templates/set/add.html+++ b/wger/manager/templates/set/add.html@@ -16,9 +16,9 @@-->{% block header %}<script>-function custom_page_init()+function wgerCustomPageInit(){- init_edit_set();+ wgerInitEditSet();}</script>{% endblock %}@@ -75,4 +75,4 @@ automatically becomes "4 x 10".{% endblocktrans %}</span>{% render_form_submit %}</form>-{% endblock %}\ No newline at end of file+{% endblock %}diff --git a/wger/manager/templates/workout/timer.html b/wger/manager/templates/workout/timer.htmlindex f58c2750a..630c52ff4 100644--- a/wger/manager/templates/workout/timer.html+++ b/wger/manager/templates/workout/timer.html@@ -233,12 +233,12 @@ $(document).ready(function() {e.preventDefault();$.post( $('#session-form').attr('action'),$('#session-form').serialize(),-+// After clicking on the save button once, disable itfunction( data ) {var today = new Date();var date = '/' + today.getFullYear() + '/' + (today.getMonth() + 1) + '/' + today.getDate();- window.location = '/' + get_current_language() + '/workout/calendar/' + get_username() + date;+ window.location = '/' + getCurrentLanguage() + '/workout/calendar/' + wgerGetUsername() + date;$('#save_button_form').unbind("click");$('#save_button_form').addClass('disabled');$('#save_button_form').bind("click", function(e) {diff --git a/wger/manager/templates/workout/view.html b/wger/manager/templates/workout/view.htmlindex a60921cbb..9e14ae836 100644--- a/wger/manager/templates/workout/view.html+++ b/wger/manager/templates/workout/view.html@@ -24,15 +24,15 @@{# #}{% block header %}<script>-function custom_modal_init()+function wgerCustomModalInit(){// Set up the edit set functions on modal dialogs- init_edit_set();+ wgerInitEditSet();}-$(document).ready(function() {+$(document).ready(function() {// Allow the sets to be sortable- setup_sortable();+ wgerSetupSortable();// Show/Hide the comments to the exercises{% if user.userprofile.show_comments %}@@ -40,7 +40,7 @@ $(document).ready(function() {{% else %}$(".exercise-comments").hide();{% endif %}- toggle_comments();+ wgerToggleComments();});</script>{% endblock %}@@ -262,4 +262,4 @@ an appointment for each training day with the appropriate exercises.{% endblockt</ul></div>{% endif %}-{% endblock %}\ No newline at end of file+{% endblock %}diff --git a/wger/manager/tests/test_weight_log.py b/wger/manager/tests/test_weight_log.pyindex 3c1c21f7d..4302cad70 100644--- a/wger/manager/tests/test_weight_log.py+++ b/wger/manager/tests/test_weight_log.py@@ -242,7 +242,7 @@ class WeightlogTestCase(WorkoutManagerTestCase):def test_get_workout_session(self):'''- Test the get_workout_session method+ Test the wgerGetWorkoutSession method'''user1 = User.objects.get(pk=1)diff --git a/wger/nutrition/templates/mobile/plan/view.html b/wger/nutrition/templates/mobile/plan/view.htmlindex d41b14be4..0bda54188 100644--- a/wger/nutrition/templates/mobile/plan/view.html+++ b/wger/nutrition/templates/mobile/plan/view.html@@ -23,7 +23,7 @@{# #}{% block header %}<script>-function custom_modal_init()+function wgerCustomModalInit(){// Init the autocompleter after loading the modal dialogwgerInitIngredientAutocompleter();diff --git a/wger/nutrition/templates/plan/view.html b/wger/nutrition/templates/plan/view.htmlindex 1df629bf3..d40511b64 100644--- a/wger/nutrition/templates/plan/view.html+++ b/wger/nutrition/templates/plan/view.html@@ -24,7 +24,7 @@{# #}{% block header %}<script>-function custom_modal_init()+function wgerCustomModalInit(){// Init the autocompleter after loading the modal dialogwgerInitIngredientAutocompleter();diff --git a/wger/utils/middleware.py b/wger/utils/middleware.pyindex a13e21d1b..85c7ad8b1 100644--- a/wger/utils/middleware.py+++ b/wger/utils/middleware.py@@ -104,7 +104,7 @@ class JavascriptAJAXRedirectionMiddleware(object):This is used for AJAX forms due to limitations of javascript. The way itwas done before was to load the whole redirected page, then read from a DIVin the page and redirect to that URL. This now just sends a header when the- form was called via the JS function form_modal_dialog() and no errors are+ form was called via the JS function wgerFormModalDialog() and no errors arepresent.'''