From 1bbc1e701340a13f9958572b9fd41c609984f8e3 Mon Sep 17 00:00:00 2001 From: Holger Trampe Date: Sat, 23 Oct 2021 12:14:02 +0200 Subject: [PATCH] LAdezeit Standard verbessert --- .../templates/standards/standards_add.html | 5 +- standards/views.py | 52 ++++++++++++------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/standards/templates/standards/standards_add.html b/standards/templates/standards/standards_add.html index 35babec..29af36d 100644 --- a/standards/templates/standards/standards_add.html +++ b/standards/templates/standards/standards_add.html @@ -145,10 +145,7 @@ {% for f in files %} - {% getNCFileInfos request f as filename %} - {% if filename != "FAIL_TO_LOAD_NC_FILE_DATA" %} - - {% endif %} + {% endfor %} diff --git a/standards/views.py b/standards/views.py index 8dd7100..b712bbe 100644 --- a/standards/views.py +++ b/standards/views.py @@ -603,27 +603,39 @@ def StandardAdd(request, id=False): #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}) # IDs filtern aus XML-Response - try: - split_response = r.text.split("") - - # Header des XML-Response entfernen - split_response.pop(0) - - # IDs from the User - for ele in split_response: - new_id = ele.split("")[0] - - file_free = True - # Prüfen, dass diese IDs nicht im aktuellen Standard sind - for sf in standard.addedfiles_nc.all(): - if str(sf.nc_id) == str(new_id): - file_free = False - - if file_free == True: - possibleFilesByVisible.append(new_id) - except: - pass + + + + 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, filename]) + + + + # IDs from the User + for ele in final_nc_files: + + file_free = True + # Prüfen, dass diese IDs nicht im aktuellen Standard sind + for sf in standard.addedfiles_nc.all(): + if str(sf.nc_id) == str(ele[0]): + file_free = False + + if file_free == True: + possibleFilesByVisible.append([ele[0], ele[1]]) + + # STANDARDS possible_standards = []