From 756937f7b016a0d13991ae84d40e5468579b2e1e Mon Sep 17 00:00:00 2001 From: "holger.trampe" Date: Sun, 28 Mar 2021 12:21:55 +0200 Subject: [PATCH] =?UTF-8?q?Nutzer=20l=C3=B6schen=20Standards=20usw.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- standards/urls.py | 2 +- standards/views.py | 30 +++++++ .../templates/users/user_confirm_delete.html | 78 ++++++++++++++++--- 3 files changed, 97 insertions(+), 13 deletions(-) diff --git a/standards/urls.py b/standards/urls.py index ebc3723..cff200a 100644 --- a/standards/urls.py +++ b/standards/urls.py @@ -25,6 +25,6 @@ urlpatterns = [ path('standardsagn/', views.StandardFromAgn, name="standard-agn"), path('standardcopy/', views.CopyStandard, name="standard-copyagn"), path('loadaggroupm/', views.LoadAGGroupMembers, name="standard-loadaggroupmembers"), - + path('standard/update/', views.UpdateStandardBeforeUserDel, name="standard-update-before-user-del") ] \ No newline at end of file diff --git a/standards/views.py b/standards/views.py index 1f317d0..7086a24 100644 --- a/standards/views.py +++ b/standards/views.py @@ -1019,4 +1019,34 @@ def updatesbyajax_agn(request, pk): return JsonResponse({"added" : added}) +@login_required +def UpdateStandardBeforeUserDel(request): + if(request.method == "GET"): + success = False + # Get Request-Data + newuser = User.objects.get(pk=request.GET["userid"]) + finalkind = request.GET["finalkind"] + standard = Standards.objects.get(pk=request.GET["standard"]) + useractor = User.objects.get(pk=request.GET["useractorid"]) + + if(newuser.profile.agency == useractor.profile.agency and standard.agency == useractor.profile.agency and useractor.has_perm('users.usermanager')): + # User is new creator + if(finalkind == "created"): + standard.created_standard_by = newuser + # User is new executor + elif(finalkind == "ex"): + standard.executor.add(newuser) + # User is new representator + elif(finalkind == "repr"): + standard.representative.add(newuser) + # User is new in auth + elif(finalkind == "auth"): + standard.authority.add(newuser) + + standard.save() + success = True + else: + success = False + + return JsonResponse({"success" : success}) diff --git a/users/templates/users/user_confirm_delete.html b/users/templates/users/user_confirm_delete.html index 4dab7bf..c4304e5 100644 --- a/users/templates/users/user_confirm_delete.html +++ b/users/templates/users/user_confirm_delete.html @@ -20,9 +20,28 @@ {% csrf_token %}

In folgenden Standards ist {{object.get_full_name}} involviert:

- Wählen Sie aus, wer anstelle von {{object.get_full_name}} eingesetzt werden soll.
+ Wählen Sie aus, wer anstelle von {{object.get_full_name}} eingesetzt werden soll. Bleibt das Feld frei, wird der Standard nicht verändert und der zu löschende Nutzer wird entfernt.
+
+
+ +
+ +
+ + {% for us in usersofagency %} + + {% endfor %} + +
+ + +
+
+ + + + - {% for s in standards_to_change %}
@@ -37,7 +56,7 @@ Ersteller ändern auf:  
- +
@@ -60,7 +79,7 @@ Vertretung übertragen auf:  
- +
@@ -83,7 +102,7 @@ Ausführung übertragen auf:  
- +
@@ -107,7 +126,7 @@
- +
@@ -192,26 +211,61 @@ } } //All data collected, to Ajaxrequest (buttonid for ending spinner!) + if(id.length > 0){ userid = id.split("_")[4]; finalkind = id.split("_")[1]; standard = id.split("_")[3]; - $("#" + buttonid).html('
Loading...
'); - } + saveNewData(userid, finalkind, standard, buttonid); + } } + //Copy to all + function updateAllStandard(){ + var value = $("#copyusertoallfield").val(); + inputfields = $(".inputfield"); + for(i = 0; i < inputfields.length; i++){ + inputfields[i].value = value; + } + } + + function saveNewData(userid, finalkind, standard, buttonid){ + $.ajax( + { + type: "GET", + url: "{% url 'standard-update-before-user-del' %}", + data:{ + userid : userid, + finalkind : finalkind, + standard : standard, + useractorid : {{request.user.pk}} + }, + beforeSend: function(){ + $("#" + buttonid).html('
Speichern...
'); + }, + success: function( data ) + { + if(data["success"]){ + $("#" + buttonid).html('Gespeichert'); + } + else{ + $("#" + buttonid).html('Fehler'); + } + } + }); + } + + //Save all Button function saveAll(){ buttons = $(".savebutton") - for(i = 0; i < buttons.length; i++){ buttons[i].click(); - console.log(buttons[i]); - console.log("CLICK " + i); } - } + + {% for s in standards_to_change %}