From 12d4de29d31eb4daa003c67e475204f304af4438 Mon Sep 17 00:00:00 2001 From: Holger Trampe Date: Wed, 1 Sep 2021 11:04:43 +0200 Subject: [PATCH] Standrad Update Files add and remove --- .../templates/standards/standards_add.html | 1 + .../templates/standards/standards_single.html | 11 ++++++----- .../__pycache__/counter_tag.cpython-38.pyc | Bin 25984 -> 25969 bytes standards/templatetags/counter_tag.py | 1 - standards/views.py | 17 +++++++++++++++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/standards/templates/standards/standards_add.html b/standards/templates/standards/standards_add.html index a6be5e2..90bb9d3 100644 --- a/standards/templates/standards/standards_add.html +++ b/standards/templates/standards/standards_add.html @@ -1105,6 +1105,7 @@ function remEle(type, id, name){ index_to_rem = actualFiles.indexOf(id); actualFiles.splice(index_to_rem,1); $("#id_added_" + type).val(actualFiles); + } else if(type == 'quicklinks'){ index_to_rem = actualQuicklinks.indexOf(id); diff --git a/standards/templates/standards/standards_single.html b/standards/templates/standards/standards_single.html index d5ffc01..1f53759 100644 --- a/standards/templates/standards/standards_single.html +++ b/standards/templates/standards/standards_single.html @@ -27,7 +27,7 @@
- {% if standard.addedfiles.all|length > 0 or standard.linked_standards.all|length > 0 or standard.authority.count > 0 or standard.executor.count > 0 or standard.representative.count > 0 or standard.addedfiles.all|length > 0 or standard.linked_standards.all|length > 0 or standard.freefield_title|length > 0 or standard.addedcontacts.all|length > 0 or standard.addedpasswords.all|length > 0 or standard.addedquicklinks.all|length > 0 or standard.authority_group.count > 0 or standard.executor_group.count > 0 or standard.representative_group.count > 0 %} + {% if standard.addedfiles_nc.all|length > 0 or standard.linked_standards.all|length > 0 or standard.authority.count > 0 or standard.executor.count > 0 or standard.representative.count > 0 or standard.addedfiles_nc.all|length > 0 or standard.linked_standards.all|length > 0 or standard.freefield_title|length > 0 or standard.addedcontacts.all|length > 0 or standard.addedpasswords.all|length > 0 or standard.addedquicklinks.all|length > 0 or standard.authority_group.count > 0 or standard.executor_group.count > 0 or standard.representative_group.count > 0 %}
{% else %}
@@ -42,7 +42,7 @@
- {% if standard.addedfiles.all|length > 0 or standard.linked_standards.all|length > 0 or standard.authority.count > 0 or standard.executor.count > 0 or standard.representative.count > 0 or standard.addedfiles.all|length > 0 or standard.linked_standards.all|length > 0 or standard.freefield_title|length > 0 or standard.addedcontacts.all|length > 0 or standard.addedpasswords.all|length > 0 or standard.addedquicklinks.all|length > 0 or standard.authority_group.count > 0 or standard.executor_group.count > 0 or standard.representative_group.count > 0 %} + {% if standard.addedfiles_nc.all|length > 0 or standard.linked_standards.all|length > 0 or standard.authority.count > 0 or standard.executor.count > 0 or standard.representative.count > 0 or standard.addedfiles_nc.all|length > 0 or standard.linked_standards.all|length > 0 or standard.freefield_title|length > 0 or standard.addedcontacts.all|length > 0 or standard.addedpasswords.all|length > 0 or standard.addedquicklinks.all|length > 0 or standard.authority_group.count > 0 or standard.executor_group.count > 0 or standard.representative_group.count > 0 %}
@@ -131,13 +131,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 %} + + TODO: HIER DOWNLOAD ERMÖGLICH: {{files.nc_id}} {% endfor %}

diff --git a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc index 1d330fb4a48ad4af02f5985f990dc04e1261d186..43c023f33409671ca4cb53df56caed4092a47b1d 100644 GIT binary patch delta 185 zcmW;GD-Oay7zE&d-+e6@lBK6WS8@ns!y~_1y^8Dxk~$I;7D#KjKyLvzAY1~0XWLQp zB_rneBHt&`E3Gq#sg{fFuG9759Pa(nW*|_2fa{g83ZE6oPVv)$OFe)fFYv Q%V+&lv*9A8{d@D^e_CoQb^rhX delta 200 zcmW;GI}XAy3o7cMS$>L?ASvP_Ycit@g&$-ChQkX|8_#`LIoP-fNHA_(=B{>ve11;68 bnfK3f!^GlTA;9Ca|3$0uU&b)(heOBzw`(om diff --git a/standards/templatetags/counter_tag.py b/standards/templatetags/counter_tag.py index 0d81ed1..12b367c 100644 --- a/standards/templatetags/counter_tag.py +++ b/standards/templatetags/counter_tag.py @@ -1121,7 +1121,6 @@ import urllib.parse @register.simple_tag def getNCFileInfos(request, ncid): try: - print(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}) diff --git a/standards/views.py b/standards/views.py index 1e5ee2d..80dcc62 100644 --- a/standards/views.py +++ b/standards/views.py @@ -333,7 +333,7 @@ def StandardAdd(request, id=False): standard.visibleby.clear() standard.linked_standards.clear() - standard.addedfiles.clear() + standard.addedfiles_nc.clear() standard.addedquicklinks.clear() standard.addedpasswords.clear() standard.addedcontacts.clear() @@ -389,10 +389,23 @@ 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()): - standard.addedfiles.add(DataFile.objects.get(pk=f)) + 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 quicklinks = normalForm.cleaned_data['added_quicklinks'].split(",")