diff options
author | Andrea Lepori <aleporia@gmail.com> | 2023-07-24 12:53:03 +0200 |
---|---|---|
committer | Andrea Lepori <aleporia@gmail.com> | 2023-07-24 12:53:03 +0200 |
commit | 411c4035784b0294794b8bb34dce974f799e0757 (patch) | |
tree | e50829cdf1dc27e4a2c6fca3ed54c071c36e58cc | |
parent | add doc table link (diff) | |
download | scout-subs-411c4035784b0294794b8bb34dce974f799e0757.tar.gz scout-subs-411c4035784b0294794b8bb34dce974f799e0757.zip |
usercode with all personal data
Diffstat (limited to '')
-rw-r--r-- | client/migrations/0016_usercode_branca_usercode_email_usercode_first_name_and_more.py | 35 | ||||
-rw-r--r-- | client/models.py | 4 | ||||
-rw-r--r-- | client/views.py | 10 | ||||
-rw-r--r-- | server/templates/server/debug_usercode.html | 14 | ||||
-rw-r--r-- | server/urls.py | 1 | ||||
-rw-r--r-- | server/views.py | 12 | ||||
-rw-r--r-- | version.txt | 2 |
7 files changed, 77 insertions, 1 deletions
diff --git a/client/migrations/0016_usercode_branca_usercode_email_usercode_first_name_and_more.py b/client/migrations/0016_usercode_branca_usercode_email_usercode_first_name_and_more.py new file mode 100644 index 0000000..9e31cf3 --- /dev/null +++ b/client/migrations/0016_usercode_branca_usercode_email_usercode_first_name_and_more.py @@ -0,0 +1,35 @@ +# Generated by Django 4.1.5 on 2023-07-24 10:14 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('auth', '0012_alter_user_first_name_max_length'), + ('client', '0015_hidegroup'), + ] + + operations = [ + migrations.AddField( + model_name='usercode', + name='branca', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.PROTECT, to='auth.group'), + ), + migrations.AddField( + model_name='usercode', + name='email', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='usercode', + name='first_name', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='usercode', + name='last_name', + field=models.CharField(default='', max_length=250), + ), + ] diff --git a/client/models.py b/client/models.py index 20c8fa1..c9fe42f 100644 --- a/client/models.py +++ b/client/models.py @@ -108,6 +108,10 @@ class UserCode(models.Model): user = models.ForeignKey(User, default=None, on_delete=models.CASCADE)
medic = models.ForeignKey(MedicalData, default=None, on_delete=models.PROTECT)
code = models.IntegerField(default=0)
+ branca = models.ForeignKey(Group, default=0, on_delete=models.PROTECT)
+ first_name = models.CharField(default="", max_length=250)
+ last_name = models.CharField(default="", max_length=250)
+ email = models.CharField(default="", max_length=250)
parent_name = models.CharField(default="", max_length=250)
via = models.CharField(default="", max_length=250)
cap = models.CharField(default="", max_length=250)
diff --git a/client/views.py b/client/views.py index d4e9709..79783f1 100644 --- a/client/views.py +++ b/client/views.py @@ -15,6 +15,16 @@ from datetime import datetime import pytz from random import randint +def migration_usercode(void): + usercodes = UserCode.objects.all() + for uc in usercodes: + user = uc.user + uc.first_name = user.first_name + uc.last_name = user.last_name + uc.email = user.email + uc.branca = user.groups.all()[0] + uc.save() + @login_required() def index(request): context = {} 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 %} + +<pre> +{% 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 %} +</pre> + +{% 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/<int:id>/<str:t>/<str:flag>', 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):
diff --git a/version.txt b/version.txt index ce1fe73..acc2e26 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.6 -rev=23 +rev=24 |