Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

changed permission checks to rely on full exercise permissions so a trustworthy user did not see admin UI features

emuth4122fe00cff1
diff --git a/wger/core/templates/navigation.html b/wger/core/templates/navigation.html
index f71bcbc2d..1b977b609 100644
--- a/wger/core/templates/navigation.html
+++ b/wger/core/templates/navigation.html
@@ -48,7 +48,7 @@
<li><a class="dropdown-item" href="{% url 'exercise:exercise:add' %}">{% translate "Add new exercise" %}</a><li>
{% endif %}
- {% if perms.exercises %}
+ {% if user.userprofile.has_exercise_permission %}
<li class="dropdown-divider"></li>
<li class="dropdown-header">{% translate "Administration" %}</li>
<li><a class="dropdown-item" href="{% url 'exercise:exercise:pending' %}">{% translate "Exercises pending review" %}</a></li>
@@ -196,7 +196,7 @@
{# #}
{# Administration #}
{# #}
- {% if perms.exercises or perms.gym.manage_gyms or perms.gym.manage_gym or perms.gym.gym_trainer %}
+ {% if user.userprofile.has_exercise_permission or perms.gym.manage_gyms or perms.gym.manage_gym or perms.gym.gym_trainer %}
<li class="dropdown-divider"></li>
<li class="dropdown-header">{% translate "Administration" %}</li>
{% if perms.core.change_language %}
diff --git a/wger/exercises/templates/exercise/form.html b/wger/exercises/templates/exercise/form.html
index 71ef447f8..cd6c593d1 100644
--- a/wger/exercises/templates/exercise/form.html
+++ b/wger/exercises/templates/exercise/form.html
@@ -1,6 +1,6 @@
{% load i18n %}
-{% if not perms.exercises %}
+{% if not user.userprofile.has_exercise_permission %}
<h4>{% translate "Submitting an exercise" %}</h4>
<p><strong>{% blocktranslate %}Thank you for submitting an exercise. This is much
appreciated!{% endblocktranslate %}</strong></p>
diff --git a/wger/exercises/templates/exercise/form_correct.html b/wger/exercises/templates/exercise/form_correct.html
index 5bc3bff28..82cba341a 100644
--- a/wger/exercises/templates/exercise/form_correct.html
+++ b/wger/exercises/templates/exercise/form_correct.html
@@ -1,6 +1,6 @@
{% load i18n %}
-{% if not perms.exercises %}
+{% if not user.userprofile.has_exercise_permission %}
<h4>{% translate "Correcting an exercise" %}</h4>
<p><strong>{% blocktranslate %}Thank you for correcting and improving this exercise.
This is much appreciated!{% endblocktranslate %}</strong></p>
diff --git a/wger/exercises/templates/exercise/view.html b/wger/exercises/templates/exercise/view.html
index 0f3151f63..4958dada3 100644
--- a/wger/exercises/templates/exercise/view.html
+++ b/wger/exercises/templates/exercise/view.html
@@ -92,7 +92,7 @@ $(document).ready(function() {
{# Images #}
{% with images=exercise.images.accepted %}
-{% if images or perms.exercises.change_exerciseimage %}
+{% if images or perms.exercises.change_exerciseimage or user.userprofile.is_trustworthy %}
<h5 class="mt-4">{% translate "Images" %}:</h5>
<div class="row row-cols-2 row-cols-md-3">
{% with other_images=images %}
@@ -131,7 +131,7 @@ $(document).ready(function() {
{% endwith %}
</div>
- {% if perms.exercises.change_exerciseimage %}
+ {% if perms.exercises.change_exerciseimage or perms.exercises.add_exerciseimage or user.userprofile.is_trustworthy %}
<p>
<a href="{% url 'exercise:image:add' exercise.id %}" >
{% translate "Add new image" %}
diff --git a/wger/nutrition/templates/ingredient/form.html b/wger/nutrition/templates/ingredient/form.html
index 79728ae06..442722f93 100644
--- a/wger/nutrition/templates/ingredient/form.html
+++ b/wger/nutrition/templates/ingredient/form.html
@@ -1,6 +1,6 @@
{% load i18n %}
-{% if not perms.exercises %}
+{% if not user.userprofile.has_exercise_permission %}
<h4>{% translate "Submitting an ingredient" %}</h4>
<p><strong>{% blocktranslate %}Thank you for submitting an ingredient. This is much
appreciated!{% endblocktranslate %}</strong></p>