From 95429898985005f6be64d1ff912e2a0794b213bd Mon Sep 17 00:00:00 2001 From: "holger.trampe" Date: Fri, 20 Aug 2021 11:05:29 +0200 Subject: [PATCH] Fehlerbehandlung Standard Zuweisen --- adm/templates/adm/adm_import_flow.html | 3 ++- api/views.py | 7 +++++-- users/admin.py | 5 +++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/adm/templates/adm/adm_import_flow.html b/adm/templates/adm/adm_import_flow.html index bcabb0e..53deb42 100644 --- a/adm/templates/adm/adm_import_flow.html +++ b/adm/templates/adm/adm_import_flow.html @@ -225,11 +225,12 @@ 'agencyid' : {{agency.pk}}, }, success: function(data){ - if(data['status'] == true){ + if(data['status'] == "OK"){ $("#migfinished").show(); } else{ $("#cloud_process_standards_error").show(); + $("#cloud_process_standards_error").html("FEHLER BEI STANDARD " + data['status']); } }, error: function(e){ diff --git a/api/views.py b/api/views.py index fb06bd5..46754b6 100644 --- a/api/views.py +++ b/api/views.py @@ -420,21 +420,24 @@ def getFileIdFromXML(xmlresponse): ''' Standardateien neu zuweisen + + Alle Standards werden nacheinander durchgegangen. Pro Datei in addedfiles wird ein neues NCFile-Objekt erstellt und in addedfiles_nc gespeichert. In den Ansichten der Standards werden dann nur noch die addedfiles_nc-Elemente gesehen und verändert. ''' @api_view(['GET'], ) def NCSwitchStandardFiles(request): if request.method == "GET": agency = Agency.objects.get(pk=request.GET.get('agencyid')) standards = Standards.objects.filter(agency=agency) - + response_status = "OK" for s in standards: for f in s.addedfiles.all(): filesearchdata = '/files/' + settings.NEXTCLOUD_USER_API + '/Agenturdaten_' + str(agency.pk) + 'infinity' + f.name + '' r = requests.request("SEARCH", settings.NEXTCLOUD_URL + "remote.php/dav", data=filesearchdata, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API), headers={'Content-Type' : 'text/xml'}) fileid = getFileIdFromXML(r.text) if(fileid == None): - pass + response_status += " FEHLER BEI STANDARD " + str(s.id) + " " else: ncfile = NCFile.objects.create(agency=s.agency, nc_id=fileid, file_id=f) s.addedfiles_nc.add(ncfile) + return JsonResponse({"status" : response_status}) return JsonResponse({"status" : "NO AUTH"}) \ No newline at end of file diff --git a/users/admin.py b/users/admin.py index bc7360e..dd29574 100644 --- a/users/admin.py +++ b/users/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin from .models import Profile, Agency, AgencyGroup, AgencyJob, AgencyNetwork, AgencyNetworkPreperation, UserTime, UserYearAbsenceInfo, UserNotifications, AgencyBills, RegNotfallhilfe from .priomodel import Prio -from standards.models import StandardCommentRate, StandardComments +from standards.models import StandardCommentRate, StandardComments, NCFile from django.contrib.auth.models import Permission from message.models import Message from cloud.models import DataFile, DataDir @@ -44,4 +44,5 @@ admin.site.register(RDContact) admin.site.register(RecoverDirSetting) admin.site.register(MainStatistic) admin.site.register(RegNotfallhilfe) -admin.site.register(AGBLog) \ No newline at end of file +admin.site.register(AGBLog) +admin.site.register(NCFile) \ No newline at end of file