Merge branch 'feature/htmx'

# Conflicts:
#	package.json
#	wger/manager/templates/schedule/view.html
#	yarn.lock
This commit is contained in:
Roland Geider
2024-11-14 19:22:02 +01:00
73 changed files with 10662 additions and 11811 deletions

View File

@@ -10,6 +10,7 @@
},
"homepage": "https://github.com/wger-project/wger",
"dependencies": {
"htmx.org": "^2.0.3",
"bootstrap": "5.3.3",
"components-font-awesome": "5.9.0",
"datatables.net-bs5": "^2.1.8",

View File

@@ -8,10 +8,9 @@
# Local
from .celery_configuration import app
MIN_APP_VERSION = (1, 7, 4, 'final', 1)
VERSION = (2, 3, 0, 'alpha', 2)
VERSION = (2, 3, 0, 'alpha', 3)
RELEASE = True

View File

@@ -15,44 +15,6 @@
*/
'use strict';
/*
AJAX related functions
See https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax for
more information
*/
function getCookie(name) {
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;
}
function csrfSafeMethod(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'));
}
}
});
function getCurrentLanguage() {
// Returns a short name, like 'en' or 'de'
@@ -60,154 +22,6 @@ function getCurrentLanguage() {
}
/*
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 {
console.log('No X-wger-redirect found but also no .has-error!');
$('#wger-ajax-info').modal('hide');
$form.html(data);
}
// 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 + ' .wger-form',
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);
}
// 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
}
// 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();
}
$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('.wger-form').length > 0) {
modalDialogFormEdit();
}
});
});
}
/*
Returns a random hex string. This is useful, e.g. to add a unique ID to generated
HTML elements
@@ -223,8 +37,8 @@ function getRandomHex() {
Template-like function that adds form elements to the ajax exercise selection in the edit set page
*/
function addExercise(exercise) {
var $exerciseSearchLog;
var resultDiv;
let $exerciseSearchLog;
let resultDiv;
resultDiv = '<div id="DIV-ID" class="ajax-exercise-select">\n' +
' <a href="#" ' +
'data-role="button" ' +
@@ -248,15 +62,15 @@ function addExercise(exercise) {
}
function getExerciseFormset(baseId) {
var formsetUrl;
var setValue;
let formsetUrl;
let setValue;
setValue = $('#id_sets').val();
if (setValue && parseInt(setValue, 10) && baseId && parseInt(baseId, 10)) {
formsetUrl = '/' + getCurrentLanguage() +
'/routine/set/get-formset/' + baseId + '/' + setValue;
$.get(formsetUrl, function (data) {
var $formsets;
let $formsets;
$formsets = $('#formsets');
$formsets.append(data);
$('#exercise-search-log').scrollTop(0);
@@ -269,13 +83,13 @@ function getExerciseFormset(baseId) {
Updates all exercise formsets, e.g. when the number of sets changed
*/
function updateAllExerciseFormset() {
var setValue;
let 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;
let promise;
let exerciseId;
let formsetUrl;
exerciseId = value.value;
promise = $().promise();
if (exerciseId && parseInt(exerciseId, 10)) {
@@ -284,7 +98,7 @@ function updateAllExerciseFormset() {
'get-formset/' + exerciseId + '/' + setValue;
promise.done(function () {
promise = $.get(formsetUrl, function (data) {
var $formsets;
let $formsets;
$('#formset-base-' + exerciseId).remove();
$formsets = $('#formsets');
$formsets.append(data);
@@ -303,7 +117,7 @@ function updateAllExerciseFormset() {
*/
function initRemoveExerciseFormset() {
$('.ajax-exercise-select a').click(function (e) {
var baseId;
let baseId;
e.preventDefault();
baseId = $(this).parent('div').find('input').val();
$('#formset-base-' + baseId).remove();
@@ -352,9 +166,9 @@ function wgerInitEditSet() {
// Mobile select box
$('#id_exercise_list').change(function () {
var $idExerciseList;
var baseId;
var exerciseName;
let $idExerciseList;
let baseId;
let exerciseName;
$idExerciseList = $('#id_exercise_list');
baseId = $idExerciseList.val();
exerciseName = $idExerciseList.find(':selected').text();
@@ -385,10 +199,10 @@ function wgerInitEditSet() {
$('#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;
let filter;
let baseUrl;
let categoryPk;
let languagePk;
languagePk = data.results[0].id;
categoryPk = $('#id_categories_list').val();
baseUrl = '/api/v2/exercise/';
@@ -401,7 +215,7 @@ function wgerInitEditSet() {
$.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;
let $idExerciseList;
exerciseData.results.sort(function (a, b) {
if (a.name < b.name) {
return -1;
@@ -428,28 +242,6 @@ function wgerInitEditSet() {
});
}
/*
Helper function to load the target of a link into the main-content DIV (the main left colum)
*/
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 used in the workout log dialog to fetch existing workout sessions through the
@@ -457,7 +249,7 @@ function wgerLoadMaincontent() {
*/
function wgerGetWorkoutSession() {
$('#id_date').on('change', function () {
var date = $('#id_date').val();
let date = $('#id_date').val();
if (date) {
$.get('/api/v2/workoutsession/?date=' + date, function (data) {
if (data.results.length === 1) {
@@ -479,14 +271,14 @@ function wgerGetWorkoutSession() {
$(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;
let targetUrl;
let token;
let uid;
let workoutId;
let downloadComments;
let downloadImages;
let downloadType;
let downloadInfo;
e.preventDefault();
downloadInfo = $('#pdf-download-info');
@@ -511,14 +303,14 @@ $(document).ready(function () {
// 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;
let targetUrl;
let token;
let uid;
let scheduleId;
let downloadComments;
let downloadImages;
let downloadType;
let downloadInfo;
e.preventDefault();
downloadInfo = $('#pdf-download-info');

View File

@@ -1,23 +1,10 @@
{% extends extend_template %}
{% load i18n crispy_forms_tags %}
<!--
Title
-->
{% block title %}{{title}}{% endblock %}
<h4>{{ title }}</h4>
<p>{% translate "Are you sure you want to delete this? This action cannot be undone." %}</p>
{% if delete_message %}
<p>{{ delete_message }}</p>
{% endif %}
{% crispy form %}
<!--
Main Content
-->
{% block content %}
<div class="wger-form">
<p>{% translate "Are you sure you want to delete this? This action cannot be undone." %}</p>
{% if delete_message %}
<p>{{ delete_message }}</p>
{% endif %}
{% crispy form %}
</div>
{% endblock %}

View File

@@ -1,29 +1,4 @@
{% extends extend_template %}
{% load i18n static crispy_forms_tags %}
{% load crispy_forms_tags %}
{% block header %}
{{ form.media }}
{% if custom_js %}
<script type="text/javascript">
$(document).ready(function() {
{{custom_js|safe}}
});
</script>
{% endif %}
{% endblock %}
{% block title %}{{title}}{% endblock %}
{% block content %}
{% if form %}
{% crispy form %}
{% else %}
Looks like you clicked on an invalid link. Please try again.
{% endif %}
{% endblock %}
<!--
Side bar
-->
{% block sidebar %}{% if sidebar %}{% include sidebar %}{% endif %}{% endblock %}
<h4>{{ title }}</h4>
{% crispy form %}

View File

@@ -0,0 +1,29 @@
{% extends 'base.html' %}
{% load i18n static crispy_forms_tags %}
{% block header %}
{{ form.media }}
{% if custom_js %}
<script type="text/javascript">
$(document).ready(function () {
{{ custom_js|safe }}
});
</script>
{% endif %}
{% endblock %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
{% if form %}
{% crispy form %}
{% else %}
Looks like you clicked on an invalid link. Please try again.
{% endif %}
{% endblock %}
<!--
Sidebar
-->
{% block sidebar %}{% if sidebar %}{% include sidebar %}{% endif %}{% endblock %}

View File

@@ -31,7 +31,6 @@
{# Options #}
{# #}
{% block options %}
<a href="{% url 'core:language:add' %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add" %}
</a>
{% translate 'Add' as text %}
{% modal_link url="core:language:add" text=text %}
{% endblock %}

View File

@@ -61,17 +61,15 @@
{% translate "Options" %}
</button>
<div class="dropdown-menu">
<a href="{% url 'core:language:edit' view_language.id %}"
class="wger-modal-dialog dropdown-item">
<span class="{% fa_class 'edit' %}"></span>
{% translate "Edit" %}
</a>
{% translate 'Edit' as text %}
{% url 'core:language:edit' view_language.id as url %}
{% modal_link url=url text=text css_class="dropdown-item" %}
<div role="separator" class="dropdown-divider"></div>
<a href="{% url 'core:language:delete' view_language.id %}"
class="wger-modal-dialog dropdown-item">
<span class="{% fa_class 'trash' %}"></span>
{% translate "Delete" %}
</a>
{% translate 'Delete' as text %}
{% url 'core:language:delete' view_language.id as url %}
{% modal_link url=url text=text css_class="dropdown-item" %}
</div>
</div>
</div>

View File

@@ -9,14 +9,18 @@
{% for license in license_list %}
<li class="list-group-item list-group-item-action">
<div class="btn-group float-end">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm" data-bs-toggle="dropdown">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm"
data-bs-toggle="dropdown">
<span class="{% fa_class 'cog' %}"></span>
</button>
<div class="dropdown-menu" role="menu">
<a href="{% url 'core:license:edit' license.id %}"
class="dropdown-item wger-modal-dialog">{% translate 'Edit' %}</a>
<a href="{% url 'core:license:delete' license.id %}"
class="dropdown-item wger-modal-dialog">{% translate 'Delete' %}</a>
{% translate 'Edit' as text %}
{% url 'core:license:edit' license.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% translate 'Delete' as text %}
{% url 'core:license:delete' license.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
{{ license }}
@@ -36,8 +40,7 @@
{# #}
{% block options %}
{% if perms.core.add_license %}
<a href="{% url 'core:license:add' %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add" %}
</a>
{% translate 'Add' as text %}
{% modal_link url='core:license:add' text=text %}
{% endif %}
{% endblock %}

View File

@@ -1,50 +0,0 @@
% extends "base.html" %}
{% load i18n static wger_extras %}
{% block title %}{% translate "License list" %}{% endblock %}
{% block content %}
<ul class="list-group">
{% for license in license_list %}
<li class="list-group-item ">
<div class="btn-group float-end">
<button type="button" class="btn btn-light dropdown-toggle btn-sm" data-bs-toggle="dropdown">
<span class="{% fa_class 'cog' %}"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a href="{% url 'core:license:edit' license.id %}"
class="wger-modal-dialog">{% translate 'Edit' %}</a>
</li>
<li>
<a href="{% url 'core:license:delete' license.id %}"
class="wger-modal-dialog">{% translate 'Delete' %}</a>
</li>
</ul>
</div>
{{ license }}
</li>
{% empty %}
<li class="list-group-item">
{% translate "Nothing found" %}
</li>
{% endfor %}
</ul>
{% endblock %}
{% block sidebar %}
{% if perms.core.add_license %}
<p>
<a href="{% url 'core:license:add' %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add" %}
</a>
</p>
<p>{% blocktranslate %}If a license has been localized, e.g. the Creative Commons
licenses for the different countries, add them as separate entries here.{% endblocktranslate %}</p>
{% endif %}
{% endblock %}

View File

@@ -175,7 +175,8 @@
</a>
</li>
<li>
<a class="dropdown-item" href="{% url 'nutrition:ingredient:list' %}">
<a class="dropdown-item"
href="{% url 'nutrition:ingredient:list' %}">
{% translate "Ingredient overview" %}
</a>
</li>
@@ -183,7 +184,8 @@
<li class="dropdown-divider"></li>
<li class="dropdown-header">{% translate "Administration" %}</li>
<li>
<a class="dropdown-item" href="{% url 'nutrition:weight_unit:list' %}">
<a class="dropdown-item"
href="{% url 'nutrition:weight_unit:list' %}">
{% translate "Ingredient weight units" %}
</a>
</li>
@@ -211,11 +213,8 @@
</a>
</li>
<li>
<a class="dropdown-item"
href="{% url 'weight:add' %}"
rel="nofollow">
{% translate "Add weight entry" %}
</a>
{% translate 'Add weight entry' as text %}
{% modal_link url='weight:add' text=text css_class='dropdown-item' %}
</li>
</ul>
</li>

View File

@@ -10,14 +10,18 @@
<li class="list-group-item list-group-item-action">
{% if unit.id != 1 and unit.id != 2 %}
<div class="btn-group float-end">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm" data-bs-toggle="dropdown">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm"
data-bs-toggle="dropdown">
<span class="{% fa_class 'cog' %}"></span>
</button>
<ul class="dropdown-menu" role="menu">
<a href="{% url 'core:repetition-unit:edit' unit.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Edit' %}</a>
<a href="{% url 'core:repetition-unit:delete' unit.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Delete' %}</a>
{% translate 'Edit' as text %}
{% url 'core:repetition-unit:edit' unit.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% translate 'Delete' as text %}
{% url 'core:repetition-unit:delete' unit.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</ul>
</div>
{% endif %}
@@ -39,8 +43,7 @@
{# #}
{% block options %}
{% if perms.core.add_license %}
<a href="{% url 'core:repetition-unit:add' %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add" %}
</a>
{% translate 'Add' as text %}
{% modal_link url='core:repetition-unit:add' text=text %}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,12 @@
{% load static i18n %}
<a
href="{{ url }}"
class="{{ css_class }}"
hx-get="{{ url }}"
hx-target="#ajax-info-content"
data-bs-toggle="modal"
data-bs-target="#wger-ajax-info"
>
{{ text }}
</a>

View File

@@ -68,6 +68,7 @@
<script src="{% static 'yarn/jquery/dist/jquery.js' %}"></script>
<script src="{% static 'yarn/bootstrap/dist/js/bootstrap.bundle.min.js' %}"></script>
<script src="{% static 'yarn/d3/dist/d3.js' %}"></script>
<script src="{% static 'yarn/htmx.org/dist/htmx.min.js' %}"></script>
<script src="{% static 'yarn/popper.js/dist/umd/popper.js' %}"></script>
<script src="{% static 'yarn/devbridge-autocomplete/dist/jquery.autocomplete.min.js' %}">
</script>
@@ -87,12 +88,6 @@
if (typeof wgerCustomPageInit !== "undefined") {
wgerCustomPageInit();
}
// Init the modal dialog for editing forms
wgerFormModalDialog();
// Initialise the hook to reload the main-content
wgerLoadMaincontent();
});
</script>
@@ -115,7 +110,6 @@
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="ajax-info-title">Modal title</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>

View File

@@ -1,15 +1,7 @@
{% extends "base.html" %}
{% load i18n static wger_extras crispy_forms_tags %}
{% block title %}{% translate "Delete account" %}{% endblock %}
<h4>{% translate "Delete account" %}</h4>
{% block header %}
{% endblock %}
{% block content %}
<div class="wger-form">
<div class="card bg-light">
<div class="card-header">
<h4 class="card-title">
@@ -26,9 +18,3 @@ and can't be undone. {% endblocktranslate %}{% endwith %}</p>
</div>
<div class="mt-2"></div>
{% crispy form %}
</div>
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@@ -201,20 +201,38 @@
{% translate "Actions" %} <span class="caret"></span>
</button>
<div class="dropdown-menu" role="menu">
<a href="{% url 'core:user:edit' current_user.pk %}" class="wger-modal-dialog dropdown-item">{% translate "Edit"%}</a>
{% translate 'Edit' as text %}
{% url 'core:user:edit' current_user.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
<div class="dropdown-divider"></div>
{% if current_user.is_active %}
<a href="{% url 'core:user:deactivate' current_user.pk %}" class="dropdown-item">{% translate "Deactivate user"%}</a>
{% else %}
<a href="{% url 'core:user:activate' current_user.pk %}" class="dropdown-item">{% translate "Activate user"%}</a>
{% endif %}
<a data-url="{% url 'gym:gym:reset-user-password' current_user.pk %}" data-bs-toggle="modal" data-bs-target="#confirmation-modal" class="dropdown-item">{% translate "Reset user password" %}</a>
{% translate 'Deactivate user' as text %}
{% url 'core:user:deactivate' current_user.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% else %}
{% translate 'Activate user' as text %}
{% url 'core:user:activate' current_user.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
<a
data-url="{% url 'gym:gym:reset-user-password' current_user.pk %}"
data-bs-toggle="modal"
data-bs-target="#confirmation-modal"
class="dropdown-item">
{% translate "Reset user password" %}
</a>
{% if perms.gym.manage_gym or perms.gym.manage_gyms %}
{% if current_user.userprofile.gym %}
<a href="{% url 'gym:gym:edit-user-permission' current_user.pk %}" class="wger-modal-dialog dropdown-item">{% translate "Roles"%}</a>
{% translate 'Roles' as text %}
{% url 'gym:gym:edit-user-permission' current_user.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
{% endif %}
<a href="{% url 'core:user:delete' current_user.pk %}" class="wger-modal-dialog dropdown-item">{% translate "Delete"%}</a>
{% translate 'Delete' as text %}
{% url 'core:user:delete' current_user.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
@@ -362,7 +380,10 @@
</button>
<div class="dropdown-menu" role="menu">
<a href="{% url 'gym:admin_note:list' current_user.pk %}" class="dropdown-item">{% translate "Overview" %}</a>
<a href="{% url 'gym:admin_note:add' current_user.pk %}" class="wger-modal-dialog dropdown-item">{% translate "Add"%}</a>
{% translate 'Add' as text %}
{% url 'gym:admin_note:add' current_user.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
@@ -442,7 +463,10 @@
{% translate "Actions" %} <span class="caret"></span>
</button>
<div class="dropdown-menu" role="menu">
<a href="{% url 'gym:user_config:edit' current_user.gymuserconfig.pk %}" class="wger-modal-dialog dropdown-item">{% translate "Edit"%}</a>
{% translate 'Edit' as text %}
{% url 'gym:user_config:edit' current_user.gymuserconfig.pk %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
{% endif %}

View File

@@ -27,7 +27,9 @@
</p>
{% endif %}
<p>
<small class="text-muted">{% translate "You need to verify your email to contribute exercises" %}</small>
<small class="text-muted">
{% translate "You need to verify your email to contribute exercises" %}
</small>
</p>
{% endblock %}
@@ -39,8 +41,11 @@
{% block options %}
<div class="btn-group">
<div class="btn-group" role="group">
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<button type="button"
class="btn btn-primary btn-sm dropdown-toggle"
data-bs-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
<span class="{% fa_class 'cog' %}"></span>
{% translate "Options" %}
</button>
@@ -54,10 +59,8 @@
{% translate "API key" %}
</a>
<div role="separator" class="dropdown-divider"></div>
<a href="{% url 'core:user:delete' %}" class="wger-modal-dialog dropdown-item">
<span class="{% fa_class 'trash' %}"></span>
{% translate "Delete account" %}
</a>
{% translate 'Delete account' as text %}
{% modal_link url='core:user:delete' text=text css_class='dropdown-item' %}
</div>
</div>
</div>

View File

@@ -10,14 +10,18 @@
<li class="list-group-item list-group-item-action">
{% if unit.id != 1 and unit.id != 2 %}
<div class="btn-group float-end">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm" data-bs-toggle="dropdown">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm"
data-bs-toggle="dropdown">
<span class="{% fa_class 'cog' %}"></span>
</button>
<div class="dropdown-menu" role="menu">
<a href="{% url 'core:weight-unit:edit' unit.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Edit' %}</a>
<a href="{% url 'core:weight-unit:delete' unit.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Delete' %}</a>
{% translate 'Edit' as text %}
{% url 'core:weight-unit:edit' unit.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% translate 'Delete' as text %}
{% url 'core:weight-unit:delete' unit.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
{% endif %}
@@ -39,8 +43,7 @@
{# #}
{% block options %}
{% if perms.core.add_license %}
<a href="{% url 'core:weight-unit:add' %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add" %}
</a>
{% translate 'Add' as text %}
{% modal_link url='core:weight-unit:add' text=text %}
{% endif %}
{% endblock %}

View File

@@ -26,6 +26,7 @@ from django.utils.translation import (
pgettext,
)
from wger.core.tests.base_testcase import get_reverse
# wger
from wger.manager.models import Day
from wger.utils.constants import (
@@ -34,7 +35,6 @@ from wger.utils.constants import (
)
from wger.utils.language import get_language_data
register = template.Library()
@@ -177,6 +177,11 @@ def fa_class(class_name='', icon_type='fas', fixed_width=True):
return mark_safe(css)
@register.inclusion_tag('tags/modal_link.html')
def modal_link(url: str, text: str, css_class='btn btn-success btn-sm'):
return {'url': get_reverse(url), 'text': text, 'css_class': css_class}
@register.simple_tag
def trans_weight_unit(unit, user=None):
"""

View File

@@ -104,7 +104,6 @@ from wger.utils.generic_views import (
from wger.utils.language import load_language
from wger.weight.models import WeightEntry
logger = logging.getLogger(__name__)
@@ -297,7 +296,7 @@ def registration(request):
template_data['form'] = form
template_data['title'] = _('Register')
return render(request, 'form.html', template_data)
return render(request, 'form_content.html', template_data)
@login_required
@@ -549,8 +548,8 @@ class UserDetailView(LoginRequiredMixin, WgerMultiplePermissionRequiredMixin, De
)
context['workouts'] = out
context['weight_entries'] = WeightEntry.objects.filter(user=self.object).order_by('-date')[
:5
]
:5
]
context['nutrition_plans'] = NutritionPlan.objects.filter(user=self.object).order_by(
'-creation_date'
)[:5]
@@ -606,7 +605,7 @@ class UserListView(LoginRequiredMixin, PermissionRequiredMixin, ListView):
class WgerPasswordChangeView(PasswordChangeView):
template_name = 'form.html'
template_name = 'form_content.html'
success_url = reverse_lazy('core:user:preferences')
title = gettext_lazy('Change password')
@@ -627,7 +626,7 @@ class WgerPasswordChangeView(PasswordChangeView):
class WgerPasswordResetView(PasswordResetView):
template_name = 'form.html'
template_name = 'form_content.html'
email_template_name = 'registration/password_reset_email.html'
success_url = reverse_lazy('core:user:password_reset_done')
from_email = settings.WGER_SETTINGS['EMAIL_FROM']
@@ -641,7 +640,7 @@ class WgerPasswordResetView(PasswordResetView):
class WgerPasswordResetConfirmView(PasswordResetConfirmView):
template_name = 'form.html'
template_name = 'form_content.html'
success_url = reverse_lazy('core:user:login')
def get_form(self, form_class=None):

View File

@@ -9,14 +9,18 @@
{% for category in exercisecategory_list %}
<li class="list-group-item list-group-item-action">
<div class="btn-group float-end">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm" data-bs-toggle="dropdown">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm"
data-bs-toggle="dropdown">
<span class="{% fa_class 'cog' %}"></span>
</button>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<a href="{% url 'exercise:category:edit' category.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Edit' %}</a>
<a href="{% url 'exercise:category:delete' category.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Delete' %}</a>
{% translate 'Edit' as text %}
{% url 'exercise:category:edit' category.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% translate 'Delete' as text %}
{% url 'exercise:category:delete' category.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
{{ category }}
@@ -32,11 +36,8 @@
{% block options %}
{% if perms.exercises.add_exercisecategory %}
<p>
<a href="{% url 'exercise:category:add' %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add" %}
</a>
</p>
{% endif %}
{% if perms.exercises.add_exercisecategory %}
{% translate 'Add' as text %}
{% modal_link url='exercise:category:add' text=text %}
{% endif %}
{% endblock %}

View File

@@ -9,14 +9,18 @@
{% for equipment in equipment_list %}
<li class="list-group-item list-group-item-action">
<div class="btn-group float-end">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm" data-bs-toggle="dropdown">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm"
data-bs-toggle="dropdown">
<span class="{% fa_class 'cog' %}"></span>
</button>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<a href="{% url 'exercise:equipment:edit' equipment.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Edit' %}</a>
<a href="{% url 'exercise:equipment:delete' equipment.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Delete' %}</a>
{% translate 'Edit' as text %}
{% url 'exercise:equipment:edit' equipment.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% translate 'Delete' as text %}
{% url 'exercise:equipment:delete' equipment.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
{{ equipment.name }}
@@ -30,14 +34,9 @@
{% endblock %}
{% block sidebar %}
{% block options %}
{% if perms.exercises.add_equipment %}
<p>
<a href="{% url 'exercise:equipment:add' %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add new equipment" %}
</a>
</p>
{% translate 'Add' as text %}
{% modal_link url='exercise:equipment:add' text=text %}
{% endif %}
{% endblock %}

View File

@@ -13,10 +13,13 @@
<span class="{% fa_class 'cog' %}"></span>
</button>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<a href="{% url 'exercise:muscle:edit' muscle.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Edit' %}</a>
<a href="{% url 'exercise:muscle:delete' muscle.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Delete' %}</a>
{% translate 'Edit' as text %}
{% url 'exercise:muscle:edit' muscle.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% translate 'Delete' as text %}
{% url 'exercise:muscle:delete' muscle.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
{{ muscle }}
@@ -34,8 +37,7 @@
{% block options %}
{% if perms.exercises.add_equipment %}
<a href="{% url 'exercise:muscle:add' %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add muscle" %}
</a>
{% translate 'Add' as text %}
{% modal_link url='exercise:muscle:add' text=text %}
{% endif %}
{% endblock %}

View File

@@ -22,29 +22,27 @@
{% for note in adminusernote_list %}
<li class="list-group-item ">
<div class="btn-group float-end">
<button type="button" class="btn btn-light dropdown-toggle btn-sm" data-bs-toggle="dropdown">
<button type="button" class="btn btn-light dropdown-toggle btn-sm"
data-bs-toggle="dropdown">
<span class="{% fa_class 'cog' %}"></span>
</button>
<ul class="dropdown-menu" role="menu">
<div class="dropdown-menu" role="menu">
{% if perms.gym.change_adminusernote %}
<li>
<a href="{% url 'gym:admin_note:edit' note.pk %}" class="wger-modal-dialog">
{% translate 'Edit' %}
</a>
</li>
{% translate 'Edit' as text %}
{% url 'gym:admin_note:edit' note.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
{% if perms.gym.delete_adminusernote %}
<li>
<a href="{% url 'gym:admin_note:delete' note.pk %}" class="wger-modal-dialog">
{% translate 'Delete' %}
</a>
<li>
{% translate 'Delete' as text %}
{% url 'gym:admin_note:delete' note.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
</ul>
</div>
</div>
<h4 class="list-group-item-heading">{{ note.timestamp_created }} - {{ note.user|format_username }}</h4>
<h4 class="list-group-item-heading">{{ note.timestamp_created }}
- {{ note.user|format_username }}</h4>
<p class="list-group-item-text">{{ note.note }}</p>
</li>
{% empty %}
@@ -62,9 +60,9 @@
{# Options #}
{# #}
{% block options %}
{% if perms.gym.add_adminusernote %}
<a href="{% url 'gym:admin_note:add' member.pk %}" class="wger-modal-dialog btn btn-success btn-sm">
{% translate "Add" %}
</a>
{% endif %}
{% if perms.gym.add_adminusernote %}
{% translate 'Add' as text %}
{% url 'gym:admin_note:add' member.pk as url %}
{% modal_link url=url text=text %}
{% endif %}
{% endblock %}

View File

@@ -21,24 +21,21 @@
{% for contract in contract_list %}
<li class="list-group-item list-group-item-action">
<div class="btn-group float-end">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm" data-bs-toggle="dropdown">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm"
data-bs-toggle="dropdown">
<span class="{% fa_class 'cog' %}"></span>
</button>
<ul class="dropdown-menu" role="menu">
<div class="dropdown-menu" role="menu">
{% if perms.gym.change_contract %}
<li>
<a href="{% url 'gym:contract:edit' contract.pk %}">
{% translate 'Edit' %}
</a>
</li>
<li>
<a href="{% url 'gym:contract:view' contract.pk %}">
{% translate 'Show' %}
</a>
</li>
{% endif %}
{% translate 'Edit' as text %}
{% url 'gym:contract:edit' contract.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</ul>
{% translate 'Show' as text %}
{% url 'gym:contract:view' contract.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
</div>
</div>
@@ -69,6 +66,7 @@
{# Options #}
{# #}
{% block options %}
<a href="{% url 'gym:contract:add' member.pk %}"
class="wger-modal-dialog btn btn-sm btn-success">{% translate "Add" %}</a>
{% translate 'Add' as text %}
{% url 'gym:contract:add' member.pk as url %}
{% modal_link url=url text=text %}
{% endblock %}

View File

@@ -102,7 +102,8 @@
{% block sidebar %}
<h4>{% translate 'Options' %}</h4>
<a href="{% url 'gym:contract:edit' object.pk %}" class="wger-modal-dialog">{% translate 'Edit' %}</a>
{% block options %}
{% translate 'Edit' as text %}
{% url 'gym:contract:edit' object.pk as url %}
{% modal_link url=url text=text %}
{% endblock %}

View File

@@ -24,26 +24,20 @@
<button type="button" class="btn btn-dark dropdown-toggle btn-sm" data-bs-toggle="dropdown">
<span class="{% fa_class 'cog' %}"></span>
</button>
<ul class="dropdown-menu" role="menu">
<div class="dropdown-menu" role="menu">
{% if perms.gym.change_contracttype %}
<li>
<a href="{% url 'gym:contract-option:edit' option.pk %}"
class="wger-modal-dialog dropdown-item">
{% translate 'Edit' %}
</a>
</li>
{% translate 'Edit' as text %}
{% url 'gym:contract-option:edit' option.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
{% if perms.gym.delete_contracttype %}
<li>
<a href="{% url 'gym:contract-option:delete' option.pk %}"
class="wger-modal-dialog dropdown-item">
{% translate 'Delete' %}
</a>
</li>
{% translate 'Delete' as text %}
{% url 'gym:contract-option:delete' option.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
</ul>
</div>
</div>
@@ -68,7 +62,7 @@
{# Options #}
{# #}
{% block options %}
<a href="{% url 'gym:contract-option:add' gym.id %}" class="wger-modal-dialog btn btn-sm btn-success">
{% translate "Add" %}
</a>
{% translate 'Add' as text %}
{% url 'gym:contract-option:add' gym.id as url %}
{% modal_link url=url text=text %}
{% endblock %}

View File

@@ -21,29 +21,23 @@
{% for contract_type in contracttype_list %}
<li class="list-group-item list-group-item-action">
<div class="btn-group float-end">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm" data-bs-toggle="dropdown">
<button type="button" class="btn btn-dark dropdown-toggle btn-sm"
data-bs-toggle="dropdown">
<span class="{% fa_class 'cog' %}"></span>
</button>
<ul class="dropdown-menu" role="menu">
<div class="dropdown-menu" role="menu">
{% if perms.gym.change_contracttype %}
<li>
<a href="{% url 'gym:contract_type:edit' contract_type.pk %}"
class="wger-modal-dialog dropdown-item">
{% translate 'Edit' %}
</a>
</li>
{% translate 'Edit' as text %}
{% url 'gym:contract_type:edit' contract_type.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
{% if perms.gym.delete_contracttype %}
<li>
<a href="{% url 'gym:contract_type:delete' contract_type.pk %}"
class="wger-modal-dialog dropdown-item">
{% translate 'Delete' %}
</a>
</li>
{% translate 'Delete' as text %}
{% url 'gym:contract_type:delete' contract_type.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
</ul>
</div>
</div>
@@ -51,7 +45,8 @@
{{ contract_type.name }}
</h4>
<p class="list-group-item-text" style="white-space: pre-line;">{{ contract_type.description }}</p>
<p class="list-group-item-text"
style="white-space: pre-line;">{{ contract_type.description }}</p>
</li>
{% empty %}
<li class="list-group-item">
@@ -68,7 +63,7 @@
{# Options #}
{# #}
{% block options %}
<a href="{% url 'gym:contract_type:add' gym.id %}" class="wger-modal-dialog btn btn-sm btn-success">
{% translate "Add" %}
</a>
{% translate 'Add' as text %}
{% url 'gym:contract_type:add' gym.id as url %}
{% modal_link url=url text=text %}
{% endblock %}

View File

@@ -22,32 +22,32 @@
{% for document in userdocument_list %}
<li class="list-group-item ">
<div class="btn-group float-end">
<button type="button" class="btn btn-light dropdown-toggle btn-sm" data-bs-toggle="dropdown">
<button type="button" class="btn btn-light dropdown-toggle btn-sm"
data-bs-toggle="dropdown">
<span class="{% fa_class 'cog' %}"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a href="{{ document.document.url }}" download="{{ document.original_name }}">
<span class="glyphicon glyphicon-download"></span>
<a href="{{ document.document.url }}"
download="{{ document.original_name }}" class="dropdown-item">
{% translate 'Download' %}
</a>
</li>
{% if perms.gym.change_userdocument %}
<li>
<a href="{% url 'gym:document:edit' document.pk %}">
{% translate 'Edit' %}
</a>
{% translate 'Edit' as text %}
{% url 'gym:document:edit' document.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</li>
{% endif %}
{% if perms.gym.delete_userdocument %}
<li>
<a href="{% url 'gym:document:delete' document.pk %}" class="wger-modal-dialog">
{% translate 'Delete' %}
</a>
{% translate 'Delete' as text %}
{% url 'gym:document:delete' document.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</li>
{% endif %}
</ul>
</div>
@@ -75,8 +75,8 @@
{# #}
{% block options %}
{% if perms.gym.add_userdocument %}
<a href="{% url 'gym:document:add' member.pk %}" class="btn btn-sm btn-success">
{% translate "Add" %}
</a>
{% translate 'Add' as text %}
{% url 'gym:document:add' member.pk as url %}
{% modal_link url=url text=text %}
{% endif %}
{% endblock %}

View File

@@ -16,10 +16,13 @@
<span class="{% fa_class 'cog' %}"></span>
</button>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<a href="{% url 'gym:gym:edit' gym.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Edit' %}</a>
<a href="{% url 'gym:gym:delete' gym.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Delete' %}</a>
{% translate 'Edit' as text %}
{% url 'gym:gym:edit' gym.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% translate 'Delete' as text %}
{% url 'gym:gym:delete' gym.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
<a href="{% url 'gym:gym:user-list' gym.pk %}">{{ gym }}</a>
@@ -42,8 +45,8 @@
{% translate "Actions" %} <span class="caret"></span>
</button>
<div class="dropdown-menu" role="menu">
<a href="{% url 'config:gym_config:edit' %}"
class="wger-modal-dialog dropdown-item">{% translate "Edit" %}</a>
{% translate 'Edit' as text %}
{% modal_link url='config:gym_config:edit' text=text css_class='dropdown-item' %}
</div>
</div>
{% endif %}
@@ -62,9 +65,8 @@
{# Options #}
{# #}
{% block options %}
{% if perms.gym.add_gym %}
<a href="{% url 'gym:gym:add' %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add new gym" %}
</a>
{% endif %}
{% if perms.gym.add_gym %}
{% translate 'Add new gym' as text %}
{% modal_link url='gym:gym:add' text=text %}
{% endif %}
{% endblock %}

View File

@@ -58,7 +58,14 @@
{% if perms.gym.manage_gym or perms.gym.manage_gyms %}
<td style="text-align: right;">
<a href="{% url 'gym:gym:edit-user-permission' current_user.obj.pk %}" class="btn btn-light btn-sm wger-modal-dialog">
<a
href="{% url 'gym:gym:edit-user-permission' current_user.obj.pk %}"
class="btn btn-light btn-sm "
hx-get="{% url 'gym:gym:edit-user-permission' current_user.obj.pk %}"
hx-target="#ajax-info-content"
data-bs-toggle="modal"
data-bs-target="#wger-ajax-info"
>
<span class="{% fa_class 'cog' %}"></span>
</a>
</td>
@@ -84,8 +91,13 @@
{% translate "Actions" %} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<a href="{% url 'gym:gym:edit' gym.id %}" class="dropdown-item wger-modal-dialog">{% translate "Edit"%}</a>
<a href="{% url 'gym:export:users' gym.id %}" class="dropdown-item">{% translate "Export"%}</a>
{% translate 'Edit' as text %}
{% url 'gym:gym:edit' gym.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% translate 'Export' as text %}
{% url 'gym:export:users' gym.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
{% endif %}
@@ -137,7 +149,9 @@
{% translate "Actions" %} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right">
<a href="{% url 'gym:config:edit' gym.config.id %}" class="wger-modal-dialog dropdown-item">{% translate "Edit"%}</a>
{% translate 'Edit' as text %}
{% url 'gym:config:edit' gym.config.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
{% endif %}
@@ -173,7 +187,9 @@
{% translate "Actions" %} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<a href="{% url 'gym:admin_config:edit' user.gymadminconfig.id %}" class="dropdown-item wger-modal-dialog">{% translate "Edit"%}</a>
{% translate 'Edit' as text %}
{% url 'gym:admin_config:edit' user.gymadminconfig.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
</div>
@@ -208,7 +224,10 @@
</a>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<a href="{% url 'gym:contract_type:list' gym.id %}" class="dropdown-item">{% translate "Overview" %}</a>
<a href="{% url 'gym:contract_type:add' gym.id %}" class="dropdown-item wger-modal-dialog">{% translate "Add" %}</a>
{% translate 'Add' as text %}
{% url 'gym:contract_type:add' gym.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
@@ -241,7 +260,10 @@
</button>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<a href="{% url 'gym:contract-option:list' gym.id %}" class="dropdown-item">{% translate "Overview" %}</a>
<a href="{% url 'gym:contract-option:add' gym.id %}" class="dropdown-item wger-modal-dialog">{% translate "Add" %}</a>
{% translate 'Add' as text %}
{% url 'gym:contract-option:add' gym.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
@@ -311,8 +333,8 @@
{# #}
{% block options %}
{% if perms.gym.manage_gym or perms.gym.manage_gyms %}
<a href="{% url 'gym:gym:add-user' gym.pk %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add member" %}
</a>
{% translate 'Add member' as text %}
{% url 'gym:gym:add-user' gym.pk as url %}
{% modal_link url=url text=text %}
{% endif %}
{% endblock %}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -59,19 +59,20 @@
{% if is_owner %}
<span class="dropdown">
<div class="float-end">
<button type="button" class="btn btn-link dropdown-toggle btn-sm"
<button type="button"
class="btn btn-link dropdown-toggle btn-sm"
data-bs-toggle="dropdown">
</button>
<div class="dropdown-menu">
<a href="{% url 'manager:log:edit' log.pk %}"
class="wger-modal-dialog dropdown-item">
{% translate 'Edit' %}
</a>
{% translate 'Edit' as text %}
{% url 'manager:log:edit' log.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
<div class="dropdown-divider"></div>
<a href="{% url 'manager:log:delete' log.pk %}"
class="wger-modal-dialog dropdown-item">
{% translate 'Delete' %}
</a>
{% translate 'Delete' as text %}
{% url 'manager:log:delete' log.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
</span>

View File

@@ -81,13 +81,13 @@ $(document).ready(function() {
<button type="button" class="btn btn-link dropdown-toggle btn-sm" data-bs-toggle="dropdown">
</button>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<a href="{% url 'manager:log:edit' log.pk %}" class="wger-modal-dialog dropdown-item">
{% translate 'Edit' %}
</a>
<div class="dropdown-divider"></div>
<a href="{% url 'manager:log:delete' log.pk %}" class="wger-modal-dialog dropdown-item">
{% translate 'Delete' %}
</a>
{% translate 'Edit' as text %}
{% url 'manager:log:edit' log.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% translate 'Delete' as text %}
{% url 'manager:log:delete' log.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
{% endif %}

View File

@@ -13,24 +13,26 @@
<span class="caret"></span>
</button>
<div class="dropdown-menu">
<a href="{% url 'manager:session:edit' value.session.pk %}" class="wger-modal-dialog dropdown-item">
<span class="{% fa_class 'edit-o' %}"></span>
{% translate "Edit" %}
</a>
{% translate 'Edit' as text %}
{% url 'manager:session:edit' value.session.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
<div class="dropdown-divider"></div>
<a href="{% url 'manager:session:delete' value.session.pk %}" class="wger-modal-dialog dropdown-item">
<span class="{% fa_class 'trash' %}"></span>
{% translate "Delete" %}
</a>
<a href="{% url 'manager:session:delete' value.session.pk 'logs' %}" class="wger-modal-dialog dropdown-item">
<span class="{% fa_class 'trash' %}"></span>
{% translate "Delete with logs" %}
</a>
{% translate 'Delete' as text %}
{% url 'manager:session:delete' value.session.pk as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% translate 'Delete with logs' as text %}
{% url 'manager:session:delete' value.session.pk 'logs' as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
</div>
{% else %}
<a href="{% url 'manager:session:add' value.workout.id date|date:'Y' date|date:'m' date|date:'d' %}" class="btn btn-light btn-block wger-modal-dialog">{% translate "Add workout impression" %}</a>
{% translate 'Add workout impression' as text %}
{% url 'manager:session:add' value.workout.id date|date:'Y' date|date:'m' date|date:'d' as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
{% endif %}
</div>

View File

@@ -1,6 +1,5 @@
{% extends "base.html" %}
{% load i18n %}
{% load static %}
{% load i18n static wger_extras %}
{% block title %}{% translate "Your schedules" %}{% endblock %}
@@ -11,7 +10,8 @@
{% block content %}
<div class="list-group">
{% for schedule in schedules %}
<a href="{% url 'manager:schedule:view' schedule.id %}" class="list-group-item list-group-item-action">
<a href="{% url 'manager:schedule:view' schedule.id %}"
class="list-group-item list-group-item-action">
<span class="glyphicon glyphicon-chevron-right float-end"></span>
{% if schedule.is_active %}
@@ -24,9 +24,9 @@
<p class="list-group-item-text">{{ schedule.start_date }}</p>
</a>
{% empty %}
<a href="{% url 'manager:schedule:add' %}" class="list-group-item list-group-item-action wger-modal-dialog">
{% translate "No schedules found." %}<br>{% translate "Add one now." %}
</a>
{% translate "No schedules found." %}
{% translate 'Add one now' as text %}
{% modal_link url='manager:schedule:add' text=text css_class='dropdown-item' %}
{% endfor %}
</div>
{% endblock %}
@@ -38,7 +38,8 @@
<p>{% blocktranslate %}You can indicate how long you want to do each workout
before jumping to the next. It is also possible to create a loop, so you
always do the same workouts in succession, e.g. A > B > C > A > B > C and so on.{% endblocktranslate %}</p>
always do the same workouts in succession, e.g. A > B > C > A > B > C and so
on.{% endblocktranslate %}</p>
<p>{% blocktranslate %}The currently active schedule will remain active (and be
shown e.g. in your dashboard) till it reaches the last workout or till you
@@ -47,7 +48,6 @@
{% block options %}
<a href="{% url 'manager:schedule:add' %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add schedule" %}
</a>
{% translate 'Add schedule' as text %}
{% modal_link url='manager:schedule:add' text=text %}
{% endblock %}

View File

@@ -65,16 +65,29 @@
</td>
{% if is_owner %}
<td style="min-width: 6em;">
<span class="editoptions">
<a href="{% url 'manager:step:edit' step.id %}"
title="{% translate 'Edit' %}"
class="wger-modal-dialog">
<span class="{% fa_class 'edit' %}"></span></a>
<a href="{% url 'manager:step:delete' step.id %}"
title="{% translate 'Delete' %}"
class="wger-modal-dialog">
<span class="{% fa_class 'trash' %}"></span></a>
</span>
<span class="editoptions">
<a
href="{% url 'manager:step:edit' step.id %}"
class="{{ css_class }}"
hx-get="{% url 'manager:step:edit' step.id %}"
hx-target="#ajax-info-content"
data-bs-toggle="modal"
data-bs-target="#wger-ajax-info"
>
<span class="{% fa_class 'edit' %}"></span>
</a>
<a
href="{% url 'manager:step:delete' step.id %}"
class="{{ css_class }}"
hx-get="{% url 'manager:step:delete' step.id %}"
hx-target="#ajax-info-content"
data-bs-toggle="modal"
data-bs-target="#wger-ajax-info"
>
<span class="{% fa_class 'trash' %}"></span>
</a>
</span>
</td>
{% endif %}
<td>
@@ -91,10 +104,9 @@
{% if is_owner %}
<tr>
<td colspan="4">
<a href="{% url 'manager:step:add' schedule.id %}"
class="wger-modal-dialog btn btn-block btn-light">
{% translate "No workouts found." %} {% translate "Add one now." %}
</a>
{% translate 'Add one now.' as text %}
{% url 'manager:step:add' schedule.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</td>
</tr>
{% endif %}
@@ -103,17 +115,16 @@
<tr>
<td colspan="4">
{% if not schedule.is_active %}
<a href="{% url 'manager:schedule:start' schedule.pk %}" class="btn btn-success btn-sm">
<a href="{% url 'manager:schedule:start' schedule.pk %}"
class="btn btn-success btn-sm">
<span class="{% fa_class 'play' %}"></span>
{% translate "Start schedule" %}
</a>
{% endif %}
<a href="{% url 'manager:step:add' schedule.id %}"
class="wger-modal-dialog btn btn-light btn-sm">
<span class="{% fa_class 'plus' %}"></span>
{% translate "Add workout" %}
</a>
{% translate 'Add workout' as text %}
{% url 'manager:step:add' schedule.id as url %}
{% modal_link url=url text=text css_class='btn btn-light btn-sm' %}
</td>
<td colspan="2">
</td>
@@ -182,13 +193,16 @@
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">{% translate "Export calendar file" %}</h4>
<button type="button" class="close" data-bs-dismiss="modal" aria-hidden="true">&times;</button>
<button type="button" class="close" data-bs-dismiss="modal" aria-hidden="true">
&times;
</button>
</div>
<div class="modal-body">
<p>{% translate "Export this schedule as a calendar file." %}</p>
<p>{% blocktranslate %}You can then import the file it into your calendar
application for example google calendar, outlook or iCal. This will create
an appointment for each training day with the appropriate exercises.{% endblocktranslate %}</p>
an appointment for each training day with the appropriate
exercises.{% endblocktranslate %}</p>
<p>
<a href="{% url 'manager:schedule:ical' schedule.id uid token %}"
class="btn btn-block btn-light">
@@ -197,7 +211,8 @@
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">{% translate "Close" %}</button>
<button type="button" class="btn btn-light"
data-bs-dismiss="modal">{% translate "Close" %}</button>
</div>
</div>
</div>
@@ -208,17 +223,21 @@
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">{% translate "Download as PDF" %}</h4>
<button type="button" class="close" data-bs-dismiss="modal" aria-hidden="true">&times;</button>
<button type="button" class="close" data-bs-dismiss="modal" aria-hidden="true">
&times;
</button>
</div>
<div class="modal-body">
<form class="wger-form">
{% crispy download_form %}
<div id="pdf-download-info" data-schedule-id="{{ schedule.id|unlocalize }}" data-uid="{{ uid }}"
<div id="pdf-download-info" data-schedule-id="{{ schedule.id|unlocalize }}"
data-uid="{{ uid }}"
data-token="{{ token }}"></div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">{% translate "Close" %}</button>
<button type="button" class="btn btn-light"
data-bs-dismiss="modal">{% translate "Close" %}</button>
</div>
</div>
</div>
@@ -231,30 +250,33 @@
{% block options %}
<div class="btn-group">
<div class="btn-group">
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown"
<button type="button" class="btn btn-primary btn-sm dropdown-toggle"
data-bs-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<span class="{% fa_class 'cog' %}"></span>
{% translate "Options" %}
</button>
<div class="dropdown-menu">
<a href="#" data-bs-toggle="modal" data-bs-target="#export-ical-popup" class="dropdown-item">
<a href="#" data-bs-toggle="modal" data-bs-target="#export-ical-popup"
class="dropdown-item">
<span class="{% fa_class 'calendar' %}"></span>
{% translate "Export calendar file" %}
</a>
<a data-bs-toggle="modal" data-bs-target="#download-pdf-popup" class="dropdown-item">
<a data-bs-toggle="modal" data-bs-target="#download-pdf-popup"
class="dropdown-item">
<span class="{% fa_class 'download' %}"></span>
{% translate "Download as PDF" %}
</a>
{% if is_owner %}
<a href="{% url 'manager:schedule:edit' schedule.id %}" class="wger-modal-dialog dropdown-item">
<span class="{% fa_class 'edit' %}"></span>
{% translate "Edit schedule" %}
</a>
{% translate 'Edit' as text %}
{% url 'manager:schedule:edit' schedule.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
<div role="separator" class="dropdown-divider"></div>
<a href="{% url 'manager:schedule:delete' schedule.id %}" class="wger-modal-dialog dropdown-item">
<span class="{% fa_class 'trash' %}"></span>
{% translate "Delete schedule" %}
</a>
{% translate 'Delete' as text %}
{% url 'manager:schedule:delete' schedule.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
</div>
</div>

View File

@@ -1,4 +1,4 @@
{% extends extend_template %}
{% extends 'base_empty.html' %}
{% load i18n static crispy_forms_tags %}

View File

@@ -67,21 +67,26 @@
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">{% translate "Export calendar file" %}</h4>
<button type="button" class="close" data-bs-dismiss="modal" aria-hidden="true">&times;</button>
<button type="button" class="close" data-bs-dismiss="modal" aria-hidden="true">
&times;
</button>
</div>
<div class="modal-body">
<p>{% translate "Export this workout as a calendar file." %}</p>
<p>{% blocktranslate %}You can then import the file it into your calendar
application for example google calendar, outlook or iCal. This will create
an appointment for each training day with the appropriate exercises.{% endblocktranslate %}</p>
an appointment for each training day with the appropriate
exercises.{% endblocktranslate %}</p>
<p>
<a href="{% url 'manager:workout:ical' workout.id uid token %}" class="btn btn-block btn-light">
<a href="{% url 'manager:workout:ical' workout.id uid token %}"
class="btn btn-block btn-light">
{% translate "Export calendar file" %}
</a>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">{% translate "Close" %}</button>
<button type="button" class="btn btn-light"
data-bs-dismiss="modal">{% translate "Close" %}</button>
</div>
</div>
</div>
@@ -92,35 +97,41 @@
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">{% translate "Download as PDF" %}</h4>
<button type="button" class="close float-end" data-bs-dismiss="modal" aria-hidden="true">&times;
<button type="button" class="close float-end" data-bs-dismiss="modal"
aria-hidden="true">&times;
</button>
</div>
<div class="modal-body">
<form class="wger-form">
<div id="pdf-download-info" data-workout-id="{{ workout.id|unlocalize }}" data-uid="{{ uid }}"
<div id="pdf-download-info" data-workout-id="{{ workout.id|unlocalize }}"
data-uid="{{ uid }}"
data-token="{{ token }}"></div>
<div class="form-group form-check-inline">
<input type="radio" name="pdf_type" class="form-check-input" id="id_type_log" value="log"
<input type="radio" name="pdf_type" class="form-check-input"
id="id_type_log" value="log"
checked>
<label class="form-check-label" for="id_type_log">
{% translate "Log" %}
</label>
</div>
<div class="form-group form-check-inline">
<input type="radio" name="pdf_type" id="id_type_table" class="form-check-input"
<input type="radio" name="pdf_type" id="id_type_table"
class="form-check-input"
value="table">
<label class="form-check-label" for="id_type_table">
{% translate "Table" %}
</label>
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" name="images" id="id_images" checked>
<input type="checkbox" class="form-check-input" name="images"
id="id_images" checked>
<label for="id_images" class="form-check-label">
{% translate "with images" %}
</label>
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" name="comments" id="id_comments" checked>
<input type="checkbox" class="form-check-input" name="comments"
id="id_comments" checked>
<label for="id_comments" class="form-check-label">
{% translate "with comments" %}
</label>
@@ -134,7 +145,8 @@
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">{% translate "Close" %}</button>
<button type="button" class="btn btn-light"
data-bs-dismiss="modal">{% translate "Close" %}</button>
</div>
</div>
</div>
@@ -143,7 +155,8 @@
{% if workout.canonical_representation.day_list %}
<h4>{% translate "Logs" %}</h4>
<p>
<a class="btn btn-primary btn-sm" href="{% url 'manager:log:log' workout.id %}">{% translate 'View logs' %}</a>
<a class="btn btn-primary btn-sm"
href="{% url 'manager:log:log' workout.id %}">{% translate 'View logs' %}</a>
</p>
{% endif %}
@@ -157,19 +170,20 @@
{% block options %}
<div class="btn-group" role="group">
<div class="btn-group" role="group">
<button id="btnGroupWorkout" type="button" class="btn btn-primary btn-sm dropdown-toggle"
<button id="btnGroupWorkout" type="button"
class="btn btn-primary btn-sm dropdown-toggle"
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="{% fa_class 'cog' %}"></span>
{% translate "Options" %}
</button>
<div class="dropdown-menu" aria-labelledby="btnGroupWorkout">
{% if is_owner %}
<a href="{% url 'manager:workout:edit' workout.id %}" class="dropdown-item wger-modal-dialog">
<span class="{% fa_class 'edit' %}"></span>
{% translate "Edit workout" %}
</a>
{% translate 'Edit' as text %}
{% url 'manager:workout:edit' workout.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
<a class="dropdown-item" data-bs-toggle="modal" data-bs-target="#download-pdf-popup">
<a class="dropdown-item" data-bs-toggle="modal"
data-bs-target="#download-pdf-popup">
<span class="{% fa_class 'download' %}"></span>
{% translate "Download as PDF" %}
</a>
@@ -177,16 +191,17 @@
<span class="{% fa_class 'calendar' %}"></span>
{% translate "Export calendar file" %}
</a>
<a href="{% url 'manager:workout:make-template' workout.id %}" class="dropdown-item wger-modal-dialog">
<span class="{% fa_class 'clone' %}"></span>
{% translate "Mark as template" %}
</a>
{% translate 'Mark as template' as text %}
{% url 'manager:workout:make-template' workout.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% if is_owner %}
<div class="dropdown-divider"></div>
<a href="{% url 'manager:workout:delete' workout.id %}" class="dropdown-item wger-modal-dialog">
<span class="{% fa_class 'trash' %}"></span>
{% translate "Delete" %}
</a>
{% translate 'Delete' as text %}
{% url 'manager:workout:delete' workout.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% endif %}
</div>
</div>

View File

@@ -41,7 +41,6 @@ from wger.manager.models import (
)
from wger.utils.generic_views import WgerFormMixin
logger = logging.getLogger(__name__)
@@ -105,6 +104,7 @@ class DayCreateView(DayView, CreateView):
title = gettext_lazy('Add workout day')
owner_object = {'pk': 'workout_pk', 'class': Workout}
template_name = 'form_content.html'
def form_valid(self, form):
"""

View File

@@ -41,8 +41,8 @@
{% endif %}
<div style="padding-top:3em;"></div>
{% pagination paginator page_obj %}
<div style="padding-top:3em;"></div>
{% pagination paginator page_obj %}
{% endblock %}
{% block sidebar %}
@@ -56,10 +56,8 @@
{# Options #}
{# #}
{% block options %}
{% if perms.nutrition.add_ingredient and user.is_authenticated and not user.userprofile.is_temporary %}
<a href="{% url 'nutrition:ingredient:add' %}"
class="btn btn-success btn-sm">
{% translate "Add ingredient" %}
</a>
{% if perms.nutrition.add_ingredient %}
{% translate 'Add' as text %}
{% modal_link url='nutrition:ingredient:add' text=text %}
{% endif %}
{% endblock %}

View File

@@ -139,11 +139,10 @@ $(document).ready(function() {
{% if perms.nutrition.delete_ingredient %}
<h4>{% translate "Weight units" %}</h4>
<p>
<a href="{% url 'nutrition:unit_ingredient:add' ingredient.id %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add new weight unit" %}
</a>
</p>
{% translate 'Add new weight unit' as text %}
{% url 'nutrition:unit_ingredient:add' ingredient.id as url %}
{% modal_link url=url text=text %}
{% if ingredient.ingredientweightunit_set.exists %}
<table class="table">
@@ -162,8 +161,13 @@ $(document).ready(function() {
<span class="{% fa_class 'cog' %}"></span>
</button>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<a href="{% url 'nutrition:unit_ingredient:edit' unit.id %}" class="wger-modal-dialog dropdown-item">{% translate 'Edit' %}</a>
<a href="{% url 'nutrition:unit_ingredient:delete' unit.id %}" class="wger-modal-dialog dropdown-item">{% translate 'Delete' %}</a>
{% translate 'Edit' as text %}
{% url 'nutrition:unit_ingredient:edit' unit.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
{% translate 'Delete' as text %}
{% url 'nutrition:unit_ingredient:delete' unit.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
</td>
@@ -202,17 +206,15 @@ $(document).ready(function() {
{% translate "Options" %}
</button>
<div class="dropdown-menu">
<a href="{% url 'nutrition:ingredient:edit' ingredient.id %}"
title="{% translate 'Edit ingredient' %}"
class="dropdown-item">
<span class="{% fa_class 'edit' %}"></span>
{% translate 'Edit ingredient' %}
</a>
{% translate 'Edit' as text %}
{% url 'nutrition:ingredient:edit' ingredient.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
<div role="separator" class="dropdown-divider"></div>
<a href="{% url 'nutrition:ingredient:delete' ingredient.id %}"
title="{% translate 'Delete ingredient' %}" class="wger-modal-dialog dropdown-item" >
<span class="{% fa_class 'trash' %}"></span>
{% translate 'Delete' %}
{% translate 'Delete' as text %}
{% url 'nutrition:ingredient:delete' ingredient.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</a>
</div>
</div>

View File

@@ -11,15 +11,20 @@
{% for unit in unit_list %}
<li class="list-group-item ">
<div class="btn-group float-end">
<button type="button" class="btn btn-light dropdown-toggle btn-sm" data-bs-toggle="dropdown">
<button type="button" class="btn btn-light dropdown-toggle btn-sm"
data-bs-toggle="dropdown">
<span class="{% fa_class 'cog' %}"></span>
</button>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<a href="{% url 'nutrition:weight_unit:edit' unit.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Edit' %}</a>
{% translate 'Edit' as text %}
{% url 'nutrition:weight_unit:edit' unit.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
<div class="dropdown-divider"></div>
<a href="{% url 'nutrition:weight_unit:delete' unit.id %}"
class="wger-modal-dialog dropdown-item">{% translate 'Delete' %}</a>
{% translate 'Delete' as text %}
{% url 'nutrition:weight_unit:delete' unit.id as url %}
{% modal_link url=url text=text css_class='dropdown-item' %}
</div>
</div>
{{ unit.name }}
@@ -42,7 +47,6 @@
{# Options #}
{# #}
{% block options %}
<a href="{% url 'nutrition:weight_unit:add' %}" class="btn btn-success btn-sm wger-modal-dialog">
{% translate "Add new weight unit" %}
</a>
{% translate 'Add new weight unit' as text %}
{% modal_link url='nutrition:weight_unit:add' text=text %}
{% endblock %}

View File

@@ -205,11 +205,11 @@ class IngredientDetailTestCase(WgerTestCase):
# Only authorized users see the edit links
if editor:
self.assertContains(response, 'Edit ingredient')
self.assertContains(response, 'Delete ingredient')
self.assertContains(response, 'Edit')
self.assertContains(response, 'Delete')
else:
self.assertNotContains(response, 'Edit ingredient')
self.assertNotContains(response, 'Delete ingredient')
self.assertNotContains(response, 'Edit')
self.assertNotContains(response, 'Delete')
# Non-existent ingredients throw a 404.
response = self.client.get(reverse('nutrition:ingredient:view', kwargs={'pk': 42}))
@@ -249,8 +249,7 @@ class IngredientSearchTestCase(WgerTestCase):
Helper function
"""
kwargs = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'}
response = self.client.get(reverse('ingredient-search'), {'term': 'test'}, **kwargs)
response = self.client.get(reverse('ingredient-search'), {'term': 'test'})
self.assertEqual(response.status_code, 200)
result = json.loads(response.content.decode('utf8'))
self.assertEqual(len(result['suggestions']), 2)

View File

@@ -30,7 +30,6 @@ def processor(request):
full_path = request.get_full_path()
i18n_path = {}
static_path = static('images/logos/logo-social.png')
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
for lang in settings.AVAILABLE_LANGUAGES:
i18n_path[lang[0]] = '/{0}/{1}'.format(lang[0], '/'.join(full_path.split('/')[2:]))
@@ -72,9 +71,6 @@ def processor(request):
# current gym, if available
'custom_header': get_custom_header(request),
# Template to extend in forms, kinda ugly but will be removed in the future
'extend_template': 'base_empty.html' if is_ajax else 'base.html',
}
# yapf: enable