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 @@
Es werden {{files|length}} Dateien und {{dirs|length}} Ordner angelegt und mit Zugriffsrechten gesetzt.
Gruppenordner wird angelegt
- Standarddateien werden neu zugewiesen...
+ Standarddateien von {{standard_pk|length}} Standards werden neu zugewiesen...
Standarddateien konnten nicht zugewiesen werden. Bitte manuell prüfen.
Migration vollständig. Bitte diese Seite ausdrucken oder Speichern. Ein erneuter Import ist nicht möglich!
@@ -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 0f425a6..a3356be 100644
Binary files a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc and b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc differ
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("/")