From 52d4066f667b2d5272afe0f03a5a66e38b390238 Mon Sep 17 00:00:00 2001 From: Holger Trampe Date: Wed, 1 Sep 2021 09:41:33 +0200 Subject: [PATCH] Standard Migration stabilder Standard aufgeteilt --- adm/templates/adm/adm_import_flow.html | 44 +++++++++++++----- adm/views.py | 9 +++- api/views.py | 25 +++++----- .../__pycache__/counter_tag.cpython-38.pyc | Bin 25914 -> 25945 bytes standards/templatetags/counter_tag.py | 4 +- 5 files changed, 54 insertions(+), 28 deletions(-) diff --git a/adm/templates/adm/adm_import_flow.html b/adm/templates/adm/adm_import_flow.html index 53deb42..86ce99c 100644 --- a/adm/templates/adm/adm_import_flow.html +++ b/adm/templates/adm/adm_import_flow.html @@ -13,7 +13,7 @@ - + @@ -22,15 +22,16 @@ var groupids = [{% for g in groups %} "{{g.name}}" {% if forloop.counter < groups|length %}, {% endif %} {% endfor %}]; var files = [{% for f in files %} "{{f.pk}}" {% if forloop.counter < files|length %}, {% endif %} {% endfor %}]; - var standard_files = [{% for f in standard_files %} "{{f.pk}}" {% if forloop.counter < files|length %}, {% endif %} {% endfor %}]; + var standard_files = [{% for f in standard_files %} "{{f.pk}}" {% if forloop.counter < standard_files|length %}, {% endif %} {% endfor %}]; + var standards = [{% for s in standard_pk %} "{{s}}" {% if forloop.counter < standard_pk|length %}, {% endif %} {% endfor %}]; var dirids = [{% for d in dirs %} "{{d.pk}}" {% if forloop.counter < dirs|length %}, {% endif %} {% endfor %}]; $(document).ready(function(){ // FIRST CALL GROUPS, When Groups finished User will call by Groups - //createAgencyGroups(groupids[0]); + createAgencyGroups(groupids[0]); //DEV - rebuildingStandards(); + //rebuildingStandards(standards[0]); //addGroupFolder(); //addDirs(dirids[0]); }) @@ -204,8 +205,12 @@ addDirs(dirids[dircounter]); } else { - rebuildingStandards(); - + if(standards[0] != undefined){ + rebuildingStandards(standards[0]); + } + else{ + $("#migfinished").show(); + } } } }, @@ -214,23 +219,38 @@ } }); } - + standardcounter = 0; //Anlegen der Standarddateien - function rebuildingStandards(){ + function rebuildingStandards(id){ $("#cloud_process_standards").show(); $.ajax({ url: "{% url 'api:apiswitchstandards' %}", dataType: 'json', data: { - 'agencyid' : {{agency.pk}}, + 'standardid' : id, }, success: function(data){ if(data['status'] == "OK"){ - $("#migfinished").show(); + standardcounter += 1; + if(standardcounter < standards.length){ + console.log("STANDARD " + id + " OK"); + rebuildingStandards(standards[standardcounter]); + } + else{ + console.log("STANDARD " + id + " OK"); + $("#migfinished").show(); + } } else{ - $("#cloud_process_standards_error").show(); - $("#cloud_process_standards_error").html("FEHLER BEI STANDARD " + data['status']); + standardcounter += 1; + console.log("FEHLER BEI STANDARD " + data['status'] + " ID " + id); + if(standardcounter < standards.length){ + rebuildingStandards(standards[standardcounter]); + } + else{ + console.log("FEHLER BEI STANDARD " + data['status'] + " ID " + id); + $("#migfinished").show(); + } } }, error: function(e){ diff --git a/adm/views.py b/adm/views.py index f2f32d9..f64da45 100644 --- a/adm/views.py +++ b/adm/views.py @@ -737,10 +737,15 @@ class AdmImportFlow(TemplateView): for f in s.addedfiles.all(): if(f.parent.name == "Standards Uploadbereich"): standard_files.append(f) - - context.update({'standard_files' : standard_files}) + # Loading Standard-PKs + standard_pk = [] + for s in standards: + standard_pk.append(str(s.pk)) + context.update({'standard_pk' : standard_pk}) + + # LINK TO THE NC-INSTANCE context.update({'nclink' : settings.NEXTCLOUD_URL}) context.update({'ncid' : self.request.user.profile.nc_sid}) diff --git a/api/views.py b/api/views.py index 46754b6..6000778 100644 --- a/api/views.py +++ b/api/views.py @@ -421,23 +421,22 @@ 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. + 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) + #agency = Agency.objects.get(pk=request.GET.get('agencyid')) + standard = Standards.objects.get(pk=request.GET.get('standardid')) 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): - 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) + for f in standard.addedfiles.all(): + filesearchdata = '/files/' + settings.NEXTCLOUD_USER_API + '/Agenturdaten_' + str(standard.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): + response_status += " FEHLER BEI STANDARD " + str(standard.pk) + " " + else: + ncfile = NCFile.objects.create(agency=standard.agency, nc_id=fileid, file_id=f) + standard.addedfiles_nc.add(ncfile) return JsonResponse({"status" : response_status}) return JsonResponse({"status" : "NO AUTH"}) \ No newline at end of file diff --git a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc index 0f425a67ada3a8b5d74a94d90efe3893981fa242..a3356be84db70f2665fbf151b00881963cb117b5 100644 GIT binary patch delta 154 zcmdmWit*+tM&3|fUM>b8c&4MD=(3PEmT}%>zF7B=63!B)8pdWIWMnAetYOaL0?OQed<*zD rPmbkcVicG>FW#B8sDY7zVe-THO}s)N+nHn-H5hpqxi-&9n8yMD+CwG1 delta 122 zcmcb4igDK|M&3|fUM>b8NNJEyR9VOy%h)lQFV@|zhB=FK0apswLdIH_8kQ7pNd_Q~ z2gqZsVNKx$^Z0-~wi>n)?i#jc#uRP|21$lm_7a{f-UWP{SH^NNG4fB|67M|uPy8lM RK9CJeGK?CVcPGqa0RXZVAPN8g diff --git a/standards/templatetags/counter_tag.py b/standards/templatetags/counter_tag.py index 2b1f830..aeeabd0 100644 --- a/standards/templatetags/counter_tag.py +++ b/standards/templatetags/counter_tag.py @@ -1122,7 +1122,9 @@ import urllib.parse def getNCFileInfos(request, ncid): filesearchdata = '/files/' + request.user.username + 'infinity' + str(ncid) + '' r = requests.request("SEARCH", settings.NEXTCLOUD_URL + "remote.php/dav/", data=filesearchdata, headers={'Content-Type' : 'text/xml', 'Authorization' : "Bearer " + request.user.profile.nc_sid}) - + print(str(ncid)) + print(r.text) + split_response = r.text.split("") split_fileele = split_response[1].split("") split_filename = split_fileele[0].split("/")