From fc35ce24acf15c7b17766bcee2214aaebcd2df05 Mon Sep 17 00:00:00 2001 From: Holger Trampe Date: Wed, 1 Sep 2021 11:28:02 +0200 Subject: [PATCH] Standard File Download rdy --- .../templates/standards/standards_single.html | 10 +++++++--- .../standards/standards_single_agn.html | 7 ++++--- .../__pycache__/counter_tag.cpython-38.pyc | Bin 25969 -> 26526 bytes standards/templatetags/counter_tag.py | 17 +++++++++++++++++ standards/urls.py | 3 ++- standards/views.py | 11 +++++------ 6 files changed, 35 insertions(+), 13 deletions(-) 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 43c023f33409671ca4cb53df56caed4092a47b1d..c73c812a540f0111cd35e013867487a65c3047c1 100644 GIT binary patch delta 628 zcmXYuTWb?R6vxk*ZnAN6!}cKrg4KZFQZPPC2x7zwNFEHODzxd+nHWRjmf5Y8l3p;4 zH$-h$1uson-})#4uiwB2eebKEz&P7NuvYD5k08RL&|V8I zcS%lPyXqPMo}dB{x{m-0Bh5JtUdp5>Q+Q7aD=Wdo?1gpzNN22RbrFH*-MF;&aMkD- zGM)v>5|l+c5t+<_j7#W=EX+U^aP-^&nX1BdkmT6uitf^;dXv#(+-E#sJY+m#JZ3y$ zJY(eBbQ1lXB?agV!A|G`>n(OAD~GYo>Hps+HO1Zw_BI$V8HzkR`mgde8*dnOu6)bt zU9elsoT-#A-fpQYcj~T3P4l>E<5U7dU=B~Ag$YcFaS=s5ppWeJ;jj5aar6~0u*2Zi e(ks4#bgbBRb8uyoW>+SY;HYrr8xK0qw1tyeob_W5?vEg!ycf85tNfYd8N( c`ozT617sIXp3LYYFinfinity' + 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