From 411c4035784b0294794b8bb34dce974f799e0757 Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Mon, 24 Jul 2023 12:53:03 +0200 Subject: usercode with all personal data --- server/templates/server/debug_usercode.html | 14 ++++++++++++++ server/urls.py | 1 + server/views.py | 12 ++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 server/templates/server/debug_usercode.html (limited to 'server') diff --git a/server/templates/server/debug_usercode.html b/server/templates/server/debug_usercode.html new file mode 100644 index 0000000..68a338f --- /dev/null +++ b/server/templates/server/debug_usercode.html @@ -0,0 +1,14 @@ +{% extends 'registration/base_simple.html' %} + +{% block title %}Debug Usercode{% endblock %} + +{% block content %} + +
+{% for user in data %}
+[{{user.0.id}}] {{user.0.username}} {{user.0.first_name}} {{user.0.last_name}}
+  {% for uc in user.1 %} [{{uc.id}}] {{uc.code}} {{uc.first_name}} {{uc.last_name}} ({{uc.branca}}) {% endfor %}
+{% endfor %}
+
+ +{% endblock %} \ No newline at end of file diff --git a/server/urls.py b/server/urls.py index 9eced0f..33ba3d8 100644 --- a/server/urls.py +++ b/server/urls.py @@ -21,5 +21,6 @@ urlpatterns = [ path('approve', views.approve_direct, name='approve_direct'), path('progress', views.get_progress, name='progress'), path('request', views.data_request, name='request'), + path('debug-uc', views.debug_uc, name='debug-uc'), path('media///', views.media_request, name='media'), ] diff --git a/server/views.py b/server/views.py index 141c9f7..4bcdf53 100644 --- a/server/views.py +++ b/server/views.py @@ -1826,6 +1826,18 @@ def docpreview(request): return render(request, 'server/download_doc.html', context) +@staff_member_required +@user_passes_test(lambda u: u.is_superuser) +def debug_uc(request): + data = [] + users = User.objects.all() + for u in users: + data.append([u, UserCode.objects.filter(user=u)]) + + context = { + "data": data, + } + return render(request, 'server/debug_usercode.html', context) @user_passes_test(isStaff) def data_request(request): -- cgit v1.2.1