diff --git a/standards/templates/standards/standards_single.html b/standards/templates/standards/standards_single.html index 1f53759..74d64fe 100644 --- a/standards/templates/standards/standards_single.html +++ b/standards/templates/standards/standards_single.html @@ -136,15 +136,19 @@
Dateien

- {% for files in standard.addedfiles_nc.all %} - - TODO: HIER DOWNLOAD ERMÖGLICH: {{files.nc_id}} + {% for file in standard.addedfiles_nc.all %} + {% getNCFileInfos request file.nc_id as filename %} + {% getNCFileInfosURL request file.nc_id as filelink %} + {% getNextcloudURL as nc_url %} + {{filename|truncatechars:30}}
{% endfor %}

{% endif %} + + {% if standard.addedquicklinks.all|length > 0 %}
diff --git a/standards/templates/standards/standards_single_agn.html b/standards/templates/standards/standards_single_agn.html index 016cb57..e5e6aa9 100644 --- a/standards/templates/standards/standards_single_agn.html +++ b/standards/templates/standards/standards_single_agn.html @@ -72,13 +72,14 @@ - {% if standard.addedfiles.all|length > 0 %} + {% if standard.addedfiles_nc.all|length > 0 %}
Dateien

- {% for files in standard.addedfiles.all %} - {{files.name|truncatechars:30}}
+ {% for files in standard.addedfiles_nc.all %} + {% getNCFileInfos request files.nc_id as filename %} + {{filename|truncatechars:30}}
{% endfor %}

diff --git a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc index 43c023f..c73c812 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 12b367c..ba88977 100644 --- a/standards/templatetags/counter_tag.py +++ b/standards/templatetags/counter_tag.py @@ -1132,5 +1132,22 @@ def getNCFileInfos(request, ncid): except: return "FAIL_TO_LOAD_NC_FILE_DATA" +@register.simple_tag +def getNextcloudURL(): + return settings.NEXTCLOUD_URL + +@register.simple_tag +def getNCFileInfosURL(request, ncid): + try: + 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(r.text) + split_response = r.text.split("") + split_fileele = split_response[1].split("") + # Return file-link except first slash in string + return split_fileele[0][1:] + #return urllib.parse.unquote(split_filenameclear) + except: + return "" diff --git a/standards/urls.py b/standards/urls.py index 041839c..f56c659 100644 --- a/standards/urls.py +++ b/standards/urls.py @@ -26,6 +26,7 @@ urlpatterns = [ path('standardsagn/', views.StandardFromAgn, name="standard-agn"), path('standardcopy/', views.CopyStandard, name="standard-copyagn"), path('loadaggroupm/', views.LoadAGGroupMembers, name="standard-loadaggroupmembers"), - path('standard/update/', views.UpdateStandardBeforeUserDel, name="standard-update-before-user-del") + path('standard/update/', views.UpdateStandardBeforeUserDel, name="standard-update-before-user-del"), + path('standard/download/', views.getFileFromStandard, name="standard-loadfile") ] \ No newline at end of file diff --git a/standards/views.py b/standards/views.py index 80dcc62..ab84bd2 100644 --- a/standards/views.py +++ b/standards/views.py @@ -77,6 +77,11 @@ class StandardsManagement(LoginRequiredMixin, ListView): return context +@login_required +def getFileFromStandard(request, nc_id): + print(nc_id) + return JsonResponse({}) + @login_required def checkUserDirRights(request, startdir, userid): @@ -389,22 +394,16 @@ def StandardAdd(request, id=False): standard.linked_standards.add(Standards.objects.get(pk=s)) # ADD FILES - print("FILES IDS") - print(normalForm.cleaned_data['added_files']) files = normalForm.cleaned_data['added_files'].split(",") for f in files: - print(f) if(f.isdigit()): - print("PRÜFUNG") ncfile = NCFile.objects.filter(nc_id=f).first() # Wenn die NC-File in Django nicht existiert, dann neu erstellen und hinzufügen. Trifft für Dateien zu, die zwar in den Dateien waren, aber noch nicht in der NC! if(ncfile == None): - print("NICHT GEFUNDEN - HINZUFÜGEN") new_nc_file = NCFile(nc_id=f, agency=standard.agency) new_nc_file.save() standard.addedfiles_nc.add(new_nc_file) else: - print("GEFUNDEN - HINZU") standard.addedfiles_nc.add(ncfile) # ADD QUICKLINKS