mirror of
https://github.com/wger-project/wger.git
synced 2026-02-18 00:17:51 +01:00
Add admin trophy overview.
This is mainly to check that the descriptions, images, etc. are correct without having to earn them. Adding this as an API endpoint would be a bit more work, specially for things like the times a trophy has been earned.
This commit is contained in:
@@ -287,6 +287,21 @@
|
||||
"delete_weightunit",
|
||||
"nutrition",
|
||||
"weightunit"
|
||||
],
|
||||
[
|
||||
"add_trophy",
|
||||
"trophies",
|
||||
"trophy"
|
||||
],
|
||||
[
|
||||
"change_trophy",
|
||||
"trophies",
|
||||
"trophy"
|
||||
],
|
||||
[
|
||||
"delete_trophy",
|
||||
"trophies",
|
||||
"trophy"
|
||||
]
|
||||
]
|
||||
},
|
||||
|
||||
@@ -395,6 +395,16 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if perms.trophies.change_trophy %}
|
||||
<li>
|
||||
<a class="dropdown-item"
|
||||
href="{% url 'trophies:admin-overview' %}">
|
||||
{% translate "Trophies" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
53
wger/trophies/templates/trophies/overview.html
Normal file
53
wger/trophies/templates/trophies/overview.html
Normal file
@@ -0,0 +1,53 @@
|
||||
{% extends "base_wide.html" %}
|
||||
{% load i18n static wger_extras %}
|
||||
|
||||
{# #}
|
||||
{# Title #}
|
||||
{# #}
|
||||
{% block title %}{% translate "Trophies" %}{% endblock %}
|
||||
|
||||
|
||||
{# #}
|
||||
{# Content #}
|
||||
{# #}
|
||||
{% block content %}
|
||||
<p>All trophies currently in the system</p>
|
||||
|
||||
<div class="row row-cols-sm-2 row-cols-md-4 row-cols-lg-6 g-4">
|
||||
{% for trophy in trophy_list %}
|
||||
<div class="col">
|
||||
<div class="card h-100" style="min-width: 12rem;">
|
||||
<img src="{% static trophy.image_rel_path %}" class="card-img-top" alt="..." style="padding: 1rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
{% if not trophy.is_active %}<s>{% endif %}
|
||||
{{ trophy.name }}
|
||||
{% if not trophy.is_active %}</s>{% endif %}
|
||||
</h5>
|
||||
<p class="card-text">
|
||||
{% if not trophy.is_active %}<s>{% endif %}
|
||||
{{ trophy.description }}
|
||||
{% if not trophy.is_active %}</s>{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">Type: {{ trophy.trophy_type }}</li>
|
||||
<li class="list-group-item">Hidden: {{ trophy.is_hidden }}</li>
|
||||
<li class="list-group-item">Progressive: {{ trophy.is_progressive }}</li>
|
||||
</ul>
|
||||
<div class="card-footer text-body-secondary">
|
||||
Awarded {{ trophy.user_trophies.count }} times
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{# #}
|
||||
{# Options #}
|
||||
{# #}
|
||||
{% block options %}
|
||||
{% endblock %}
|
||||
45
wger/trophies/tests/test_overview.py
Normal file
45
wger/trophies/tests/test_overview.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# This file is part of wger Workout Manager.
|
||||
#
|
||||
# wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# wger Workout Manager is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
|
||||
# Standard Library
|
||||
import logging
|
||||
|
||||
# wger
|
||||
from wger.core.tests.base_testcase import WgerAccessTestCase
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TrophiesOverviewTestCase(WgerAccessTestCase):
|
||||
"""
|
||||
Test case for the trophies overview page
|
||||
"""
|
||||
url = 'trophies:admin-overview'
|
||||
anonymous_fail = True
|
||||
user_success = 'admin'
|
||||
user_fail = (
|
||||
'manager1',
|
||||
'manager2',
|
||||
'general_manager1',
|
||||
'manager3',
|
||||
'manager4',
|
||||
'test',
|
||||
'member1',
|
||||
'member2',
|
||||
'member3',
|
||||
'member4',
|
||||
'member5',
|
||||
)
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ from django.urls import re_path
|
||||
# wger
|
||||
from wger.core.views.react import ReactView
|
||||
|
||||
# Local
|
||||
from .views import TrophiesOverview
|
||||
|
||||
urlpatterns = [
|
||||
re_path(
|
||||
@@ -26,4 +28,9 @@ urlpatterns = [
|
||||
ReactView.as_view(),
|
||||
name='overview',
|
||||
),
|
||||
re_path(
|
||||
'admin/overview/',
|
||||
TrophiesOverview.as_view(),
|
||||
name='admin-overview',
|
||||
),
|
||||
]
|
||||
|
||||
47
wger/trophies/views.py
Normal file
47
wger/trophies/views.py
Normal file
@@ -0,0 +1,47 @@
|
||||
# This file is part of wger Workout Manager.
|
||||
#
|
||||
# wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# wger Workout Manager is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
|
||||
# Standard Library
|
||||
import logging
|
||||
|
||||
# Django
|
||||
from django.contrib.auth.mixins import (
|
||||
LoginRequiredMixin,
|
||||
PermissionRequiredMixin,
|
||||
)
|
||||
from django.views.generic import ListView
|
||||
|
||||
# wger
|
||||
from wger.trophies.models import Trophy
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TrophiesOverview(LoginRequiredMixin, PermissionRequiredMixin, ListView):
|
||||
"""
|
||||
All available trophies (even hidden ones).
|
||||
|
||||
This is mainly to check that the descriptions, images, etc. are correct without having
|
||||
to earn them.
|
||||
"""
|
||||
|
||||
model = Trophy
|
||||
template_name = 'trophies/overview.html'
|
||||
permission_required = 'trophies.change_trophy'
|
||||
|
||||
def get_queryset(self):
|
||||
"""
|
||||
Return only the weight entries for the current user
|
||||
"""
|
||||
return Trophy.objects.all()
|
||||
Reference in New Issue
Block a user