From 932b7baf4bbe9a03b4469f2352ae46a3a29217de Mon Sep 17 00:00:00 2001 From: Holger Trampe Date: Thu, 16 Sep 2021 15:20:22 +0200 Subject: [PATCH] Upload verbessert --- standards/templates/standards/standards_add.html | 3 ++- standards/views.py | 7 ++++--- users/templates/users/nclog.html | 12 +----------- users/views.py | 9 +++++++++ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/standards/templates/standards/standards_add.html b/standards/templates/standards/standards_add.html index 1869892..e3f2d5f 100644 --- a/standards/templates/standards/standards_add.html +++ b/standards/templates/standards/standards_add.html @@ -1182,6 +1182,7 @@ function replaceFileDirectChoice(filetodo, choice){ doUploadAction(filetodo_ex, choice); } + function uploadAction(filetodo){ filetodo_ex = filetodo; @@ -1189,7 +1190,7 @@ function uploadAction(filetodo){ $.ajax( { type: "GET", - url: "{% url 'cloud-adddir' parentid %}", + url: "{% url 'cloud-adddir' 0 %}", data:{ action : "check_doublefile", name : filetodo.name diff --git a/standards/views.py b/standards/views.py index bc8d987..c5325b4 100644 --- a/standards/views.py +++ b/standards/views.py @@ -315,7 +315,7 @@ def StandardAdd(request, id=False): 'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency), 'usersofagency' : User.objects.filter(profile__agency=request.user.profile.agency), 'files' : possibleFilesByVisible, - 'parentid' : list(DataDir.objects.filter(agency=request.user.profile.agency, is_root=True))[0].pk, + #'parentid' : list(DataDir.objects.filter(agency=request.user.profile.agency, is_root=True))[0].pk, 'standards' : Standards.objects.filter(agency=request.user.profile.agency, public=True), 'quicklinks' : QuickLinks.objects.filter(agency=request.user.profile.agency), 'contacts' : AGContacts.objects.filter(agency=request.user.profile.agency), @@ -728,7 +728,8 @@ def StandardAdd(request, id=False): 'possible_contacts' : possible_contacts, 'agencynetworks' : agencynetworks, 'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency), - 'parentid' : list(DataDir.objects.filter(agency=request.user.profile.agency, is_root=True))[0].pk, + #'parentid' : list(DataDir.objects.filter(agency=request.user.profile.agency, is_root=True))[0].pk, + 'parentid' : 0, 'active_link' : 'standards', 'update' : True, 'aggroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency) @@ -887,7 +888,7 @@ def CopyStandard(request, pk): new_standard.save() - datadir_parentid = list(DataDir.objects.filter(is_defaultstandard=True, agency__pk=request.user.profile.agency.pk))[0] + #datadir_parentid = list(DataDir.objects.filter(is_defaultstandard=True, agency__pk=request.user.profile.agency.pk))[0] for f in sc.addedfiles_nc.all(): tempdatafile = NCFile(agency=request.user.profile.agency, nc_id=f.nc_id) tempdatafile.save() diff --git a/users/templates/users/nclog.html b/users/templates/users/nclog.html index d90c566..9a3dcd3 100644 --- a/users/templates/users/nclog.html +++ b/users/templates/users/nclog.html @@ -1,11 +1 @@ -

{{error}}

- - \ No newline at end of file +

{{error}}

\ No newline at end of file diff --git a/users/views.py b/users/views.py index 7dd5288..eb4fc35 100644 --- a/users/views.py +++ b/users/views.py @@ -209,6 +209,15 @@ def ncLogin(request, uid): try: user = User.objects.get(username=uid) if(getNCLoggedUserBySession(user.profile.nc_sid) == uid): + # Checking, if all necessary folders are created + #r = requests.request("MKCOL", settings.NEXTCLOUD_URL + "remote.php/dav/files/" + user.username + '/Agenturdaten/Standards Uploadbereich/', auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API)) + + headers = { + 'Authorization': 'Bearer ' + user.profile.nc_sid + } + # Groupfolder for Standards + r = requests.request("MKCOL", settings.NEXTCLOUD_URL + "remote.php/dav/files/" + user.username + '/Agenturdaten/Standards Uploadbereich/', headers=headers) + login(request, user) return redirect('users-dashboard') return render(request, 'users/nclog.html',{'error' : "Die Agenturdaten wurden aktualisiert. Bitte melden Sie sich ab und wieder an. Sollten Sie diese Meldung weiterhin sehen, kontaktieren Sie den Support."})