Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Initial layout of admin history

Tom Bowyer6de5d892cf85
diff --git a/requirements_dev.txt b/requirements_dev.txt
index 8721a1cbd..7a125d641 100644
--- a/requirements_dev.txt
+++ b/requirements_dev.txt
@@ -11,9 +11,6 @@ wheel==0.37.1
# for ingredient import script from OFF
pymongo==4.1.1
-# for ingredient import script from OFF
-pymongo==3.12.1
-
# Development packages
coverage==6.3.3
django-debug-toolbar==3.4.0
diff --git a/wger/core/templates/navigation.html b/wger/core/templates/navigation.html
index df19ba4f9..f749ae67f 100644
--- a/wger/core/templates/navigation.html
+++ b/wger/core/templates/navigation.html
@@ -70,6 +70,7 @@
<li class="dropdown-header">{% translate "Administration" %}</li>
<li><a class="dropdown-item" href="{% url 'exercise:history:overview' %}">{% translate "Exercise edit stream" %}</a></li>
<li><a class="dropdown-item" href="{% url 'exercise:history:overview-history' %}">{% translate "Exercise edit history" %}</a></li>
+ <li><a class="dropdown-item" href="{% url 'exercise:history:admin-control' %}">{% translate "Exercise history admin control" %}</a></li>
<li><a class="dropdown-item" href="{% url 'exercise:equipment:list' %}">{% translate "Equipment" %}</a></li>
<li><a class="dropdown-item" href="{% url 'exercise:muscle:admin-list' %}">{% translate "Muscles" %}</a></li>
<li><a class="dropdown-item" href="{% url 'exercise:category:list' %}">{% translate "Categories" %}</a></li>
diff --git a/wger/exercises/templates/history/list3.html b/wger/exercises/templates/history/list3.html
new file mode 100644
index 000000000..f9d4cd023
--- /dev/null
+++ b/wger/exercises/templates/history/list3.html
@@ -0,0 +1,40 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% load static %}
+{% load wger_extras %}
+{% load cache %}
+{% load thumbnail %}
+
+<!--
+ Title
+-->
+{% block title %}{% translate "Exercise admin history" %}{% endblock %}
+
+
+
+{% block header %}
+
+{% endblock %}
+
+
+<!--
+ Main Content
+-->
+{% block content %}
+<h1>TODO</h1>
+
+{% endblock %}
+
+
+<!--
+ Side bar
+-->
+{% block sidebar %}
+
+{% endblock %}
+
+
+
+{% block options %}
+
+{% endblock %}
diff --git a/wger/exercises/urls.py b/wger/exercises/urls.py
index bcab54bda..5137e5dc5 100644
--- a/wger/exercises/urls.py
+++ b/wger/exercises/urls.py
@@ -40,6 +40,7 @@ from wger.exercises.views import (
patterns_history = [
path('overview/', history.overview, name='overview'),
path('overview-history/', history.overview2, name='overview-history'),
+ path('admin-control/', history.control, name='admin-control'),
]
# sub patterns for muscles
diff --git a/wger/exercises/views/history.py b/wger/exercises/views/history.py
index 1fa22c81b..733534eb7 100644
--- a/wger/exercises/views/history.py
+++ b/wger/exercises/views/history.py
@@ -36,14 +36,7 @@ def overview(request):
"""
Generic view to list the history of the exercises
"""
-
- context = {
- 'stream': Action.objects.all(),
-
- # We can't pass the enum to the template, so we have to do this
- # https://stackoverflow.com/questions/35953132/
- 'modes': StreamVerbs.__members__
- }
+ context = fetch_exercise_stream()
return render(request, 'history/list.html', context)
@@ -53,9 +46,42 @@ def overview2(request):
"""
Generic view to list the history of the exercises
"""
- out = []
+ history = fetch_exercise_history()
+
+ return render(request, 'history/list2.html', {'history': history})
+
+
+@permission_required('exercises.change_exercise')
+def control(request):
+ """
+ Admin view of the history of the exercises
+ """
+ context = fetch_exercise_stream()
+ history = fetch_exercise_history()
+
+ print(history)
+ print(context)
+
+ return render(request, 'history/list3.html', {
+ 'context': context,
+ 'history': history,
+ })
+
+def fetch_exercise_history():
+ history = []
for entry in Exercise.history.all():
if entry.prev_record:
- out.append({'record': entry, 'delta': entry.diff_against(entry.prev_record)})
+ history.append(
+ {'record': entry, 'delta': entry.diff_against(entry.prev_record)})
+ return history
+
+
+def fetch_exercise_stream():
+ context = {
+ 'stream': Action.objects.all(),
- return render(request, 'history/list2.html', {'history': out})
+ # We can't pass the enum to the template, so we have to do this
+ # https://stackoverflow.com/questions/35953132/
+ 'modes': StreamVerbs.__members__
+ }
+ return context
diff --git a/yarn.lock b/yarn.lock
index b46eceff1..c2d80eec7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -14,7 +14,6 @@
Sortable@RubaXa/Sortable#1.15.0:
version "1.15.0"
- uid babf6ab85fdfc5e13be1027827cecfbba2fb0d1e
resolved "https://codeload.github.com/RubaXa/Sortable/tar.gz/babf6ab85fdfc5e13be1027827cecfbba2fb0d1e"
@@ -32,11 +31,6 @@ commander@7:
resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==
- version "5.9.0"
- resolved "https://registry.yarnpkg.com/components-font-awesome/-/components-font-awesome-5.9.0.tgz#02242f85946f0a6ab46870547f4c54d11e94ef75"
- integrity sha512-AjY5WwmKripvroQ1oYpCC4eK8efavSKUGN/ATgwcbyz/kRmojslH8l6Mrlxq071bdzBrZvCxi+RKgU5ao3bU+A==
-
d3-array@1, d3-array@^1.2.0:
version "1.2.4"
resolved "https://registry.yarnpkg.com/d3-array/-/d3-array-1.2.4.tgz#635ce4d5eea759f6f605863dbcfc30edc737f71f"