diff --git a/adm/templates/adm/adm_import_flow.html b/adm/templates/adm/adm_import_flow.html
index 09f5740..fae2dbd 100644
--- a/adm/templates/adm/adm_import_flow.html
+++ b/adm/templates/adm/adm_import_flow.html
@@ -241,6 +241,7 @@
var ncfiledata = [];
//Anlegen der Standarddateien
function rebuildingStandards(id){
+ /*
ncfiledata.splice(0, ncfiledata.length);
$("#cloud_process_standards").show();
ncfiledata[0] = ['standardid', id];
@@ -295,6 +296,42 @@
});
}
});
+ */
+ $.ajax({
+ url: "{% url 'api:apiswitchstandards' %}",
+ dataType: 'json',
+ data: {
+ 'standardid' : id,
+ },
+ success: function(data){
+ if(data['status'] == "OK"){
+ standardcounter += 1;
+ if(standardcounter < standards.length){
+ console.log("STANDARD " + id + " OK");
+ rebuildingStandards(standards[standardcounter]);
+ }
+ else{
+ console.log("STANDARD " + id + " OK");
+ $("#migfinished").show();
+ }
+ }
+ else{
+ 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){
+ console.log(e);
+ }
+ });
+
}
diff --git a/api/views.py b/api/views.py
index 2d879b5..bbf0b1d 100644
--- a/api/views.py
+++ b/api/views.py
@@ -437,12 +437,59 @@ def getFileIdFromXML(xmlresponse):
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.
'''
import re, json
-@api_view(['POST'], )
+from urllib.parse import unquote
+@api_view(['GET'], )
def NCSwitchStandardFiles(request):
- if request.method == "POST":
+ if request.method == "GET":
+ standard = Standards.objects.get(pk=request.GET.get('standardid'))
+ response_status = "OK"
+ # Dateien aus NC laden
+ # TODO: HIER WIEDER DEN USER EINTRAGEN vhdarootadmin_2cdme7ckw
+ filesearchdata = '/files/vhdarootadmin_2cdme7ckw' + '/Agenturdaten_' + str(standard.agency.pk) + '/infinity1'
+
+ #filesearchdata = 'infinity'
+ 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(r.text)
+ # IDs filtern aus XML-Response
+ #print(r.text)
+ ncfileids = [str(s) for s in re.findall('(.+?)', r.text)]
+ final_nc_files = []
+ # IDs from the User
+ for ele in ncfileids:
+ nc_filename_with_path = [str(s) for s in re.findall('(.+?)', ele)][0]
+ nc_filename_with_path = nc_filename_with_path.split("/")
+
+ filename = nc_filename_with_path[len(nc_filename_with_path)-1]
+
+ nc_file_id = [str(s) for s in re.findall('(.+?)', ele)][0]
+
+ if(len(filename) > 0):
+ final_nc_files.append([nc_file_id, unquote(filename, errors="strict")])
+
+ # Reset der NC-Files
+ for nc_standard_file in standard.addedfiles_nc.all():
+ nc_standard_file.delete()
+
+ standard.addedfiles_nc.clear()
+ standard.save()
+
+ for f in standard.addedfiles.all():
+ for nc_file_ele in final_nc_files:
+ print(f.name + " NAME " + nc_file_ele[1])
+ if(f.name == nc_file_ele[1]):
+ ncfile = NCFile.objects.create(agency=standard.agency, nc_id=nc_file_ele[0], file_id=f)
+ standard.addedfiles_nc.add(ncfile)
+ response_status += " DATEI " + f.name + " ZU STANDARD " + str(standard.pk) + " zugeordnet. - NC FILE ID " + str(nc_file_ele[0])
+ print("ZUGEORDNET!")
+ return JsonResponse({"status" : response_status})
+
+ return JsonResponse({"status" : "NO AUTH"})
+ '''
+ if request.method == "GET":
#agency = Agency.objects.get(pk=request.GET.get('agencyid'))
- jsonresponse = json.dumps(request.POST)
+
+ jsonresponse = json.dumps(request.GET)
json_final = json.loads(jsonresponse)
standardid = False
ncfiledata = False
@@ -474,6 +521,7 @@ def NCSwitchStandardFiles(request):
return JsonResponse({"status" : response_status})
return JsonResponse({"status" : "NO AUTH"})
+ '''
@api_view(['GET'], )
def NCGetFilesForStandardSwitch(request):