From f96226170b4abe84f0fda5bd3d2b7a5375a5ab8b Mon Sep 17 00:00:00 2001
From: "Adrian A. Baumann"
Date: Thu, 4 Dec 2025 13:17:35 +0100
Subject: [PATCH] Add staff-only all comments page and bump versions
- Add new "alle-kommentare" (all comments) view for staff users only
- Allows staff to view and manage all user comments across the system
- Grouped by document with user information displayed
- Staff can delete any comment via the dedicated delete button
- Restricts access via user_passes_test decorator
- Create all_comments.html template
- Based on user_comments template with added username field
- Shows comment author, creation time, and edit time
- Provides delete functionality for comment management
- Update navigation menu
- Add "Alle Kommentare" link in user dropdown menu
- Link only visible to staff members
- Add URL route for alle-kommentare page
- Path: /dokumente/alle-kommentare/
- URL name: all_comments
- Bump application versions
- Update footer version from 0.965 to 0.966
- Update K8s deployment version from 0.917 to 0.918
- ArgoCD deployment already at 0.966
All existing tests pass (148 tests total)
---
Dockerfile | 4 +-
VorgabenUI/settings.py | 2 +-
argocd/deployment.yaml | 2 +-
.../templates/standards/all_comments.html | 67 +++++++++++++++++++
dokumente/urls.py | 1 +
dokumente/views.py | 28 ++++++++
k8s/deployment.yaml | 4 +-
pages/templates/base.html | 31 +++++----
8 files changed, 119 insertions(+), 20 deletions(-)
create mode 100644 dokumente/templates/standards/all_comments.html
diff --git a/Dockerfile b/Dockerfile
index 307028d..399ed3d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -21,7 +21,7 @@ ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
USER appuser
EXPOSE 8000
-RUN rm -rf /app/Dockerfile* \
+RUN rm -rvf /app/Dockerfile* \
/app/README.md \
/app/argocd \
/app/k8s \
@@ -31,6 +31,6 @@ RUN rm -rf /app/Dockerfile* \
/app/node_modules \
/app/*.json \
/app/test_*.py && \
- python3 manage.py collectstatic
+ python3 /app/manage.py collectstatic --noinput
CMD ["gunicorn","--bind","0.0.0.0:8000","--workers","3","VorgabenUI.wsgi:application"]
diff --git a/VorgabenUI/settings.py b/VorgabenUI/settings.py
index b77e2cd..6fa33fa 100644
--- a/VorgabenUI/settings.py
+++ b/VorgabenUI/settings.py
@@ -127,7 +127,7 @@ USE_TZ = True
STATIC_URL = '/static/'
#STATIC_ROOT="/home/adebaumann/VorgabenUI/staticfiles/"
-STATIC_ROOT="/app/staticfiles/"
+STATIC_ROOT="staticfiles/"
STATICFILES_DIRS= (
os.path.join(BASE_DIR,"static"),
)
diff --git a/argocd/deployment.yaml b/argocd/deployment.yaml
index 3b22128..aeed948 100644
--- a/argocd/deployment.yaml
+++ b/argocd/deployment.yaml
@@ -25,7 +25,7 @@ spec:
mountPath: /data
containers:
- name: web
- image: git.baumann.gr/adebaumann/vui:0.965
+ image: git.baumann.gr/adebaumann/vui:0.966
imagePullPolicy: Always
ports:
- containerPort: 8000
diff --git a/dokumente/templates/standards/all_comments.html b/dokumente/templates/standards/all_comments.html
new file mode 100644
index 0000000..561680a
--- /dev/null
+++ b/dokumente/templates/standards/all_comments.html
@@ -0,0 +1,67 @@
+{% extends "base.html" %}
+
+{% block content %}
+Alle Kommentare
+
+{% if total_comments == 0 %}
+
+{% else %}
+ Insgesamt {{ total_comments }} Kommentar{{ total_comments|pluralize:"e" }}
+
+ {% for dokument, comments in comments_by_document.items %}
+
+
+
+
+ {{ comments|length }} Kommentar{{ comments|length|pluralize:"e" }}
+
+
+
+
+ {% for comment in comments %}
+
+
+
+
+
+ Benutzer: {{ comment.user.first_name }} {{ comment.user.last_name }}
+ Erstellt: {{ comment.created_at|date:"d.m.Y H:i" }}
+ {% if comment.updated_at != comment.created_at %}
+
+ Bearbeitet: {{ comment.updated_at|date:"d.m.Y H:i" }}
+ {% endif %}
+
+
+
+
+
+ {{ comment.text }}
+
+
+ {% endfor %}
+
+
+
+ {% endfor %}
+{% endif %}
+
+
+{% endblock %}
diff --git a/dokumente/urls.py b/dokumente/urls.py
index 9947ff0..d502946 100644
--- a/dokumente/urls.py
+++ b/dokumente/urls.py
@@ -5,6 +5,7 @@ urlpatterns = [
path('', views.standard_list, name='standard_list'),
path('unvollstaendig/', views.incomplete_vorgaben, name='incomplete_vorgaben'),
path('meine-kommentare/', views.user_comments, name='user_comments'),
+ path('alle-kommentare/', views.all_comments, name='all_comments'),
path('/', views.standard_detail, name='standard_detail'),
path('/history//', views.standard_detail),
path('/history/', views.standard_detail, {"check_date":"today"}, name='standard_history'),
diff --git a/dokumente/views.py b/dokumente/views.py
index 4a07c9f..0ff3b93 100644
--- a/dokumente/views.py
+++ b/dokumente/views.py
@@ -392,3 +392,31 @@ def user_comments(request):
'comments_by_document': comments_by_document,
'total_comments': user_comments.count(),
})
+
+
+@login_required
+@user_passes_test(is_staff_user)
+def all_comments(request):
+ """
+ Display all comments from all users, grouped by document.
+ Staff only.
+ """
+ # Get all comments
+ all_comments_qs = VorgabeComment.objects.select_related(
+ 'vorgabe', 'vorgabe__dokument', 'user'
+ ).order_by(
+ 'vorgabe__dokument__nummer', '-created_at'
+ )
+
+ # Group comments by document
+ comments_by_document = {}
+ for comment in all_comments_qs:
+ dokument = comment.vorgabe.dokument
+ if dokument not in comments_by_document:
+ comments_by_document[dokument] = []
+ comments_by_document[dokument].append(comment)
+
+ return render(request, 'standards/all_comments.html', {
+ 'comments_by_document': comments_by_document,
+ 'total_comments': all_comments_qs.count(),
+ })
diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml
index 3756c3f..2814e93 100644
--- a/k8s/deployment.yaml
+++ b/k8s/deployment.yaml
@@ -24,8 +24,8 @@ spec:
- name: data
mountPath: /data
containers:
- - name: web
- image: docker.io/adebaumann/vui:0.917
+ - name: web
+ image: docker.io/adebaumann/vui:0.918
imagePullPolicy: Always
ports:
- containerPort: 8000
diff --git a/pages/templates/base.html b/pages/templates/base.html
index d32decb..424c607 100644
--- a/pages/templates/base.html
+++ b/pages/templates/base.html
@@ -52,18 +52,21 @@
+ Meine Kommentare
+ {% if user.is_staff %}
+ Alle Kommentare
+ {% endif %}
+ Passwort ändern
+
+
+
+
+
{% else %}
@@ -216,8 +219,8 @@
-
Version {{ version|default:"0.965" }}
-
+ Version {{ version|default:"0.966" }}
+