This commit is contained in:
Holger Trampe 2021-10-23 20:11:49 +02:00
parent 1fad0664ce
commit 3ddc8e14ef
2 changed files with 16 additions and 12 deletions

View File

@ -28,8 +28,8 @@
$(document).ready(function(){ $(document).ready(function(){
// FIRST CALL GROUPS, When Groups finished User will call by Groups // FIRST CALL GROUPS, When Groups finished User will call by Groups
createAgencyGroups(groupids[0]); //createAgencyGroups(groupids[0]);
//addFiles(files[0]); addFiles(files[0]);
//DEV //DEV
//rebuildingStandards(standards[0]); //rebuildingStandards(standards[0]);
//addGroupFolder(); //addGroupFolder();

View File

@ -353,17 +353,21 @@ def NCAddFiles(request):
def NCAddStandardFiles(request): def NCAddStandardFiles(request):
if request.method == "GET": if request.method == "GET":
agency = Agency.objects.get(pk=request.GET.get('agencyid')) agency = Agency.objects.get(pk=request.GET.get('agencyid'))
file_to_load = DataFile.objects.get(pk=request.GET.get('fileid')) if(DataFile.objects.filter(pk=request.GET.get('fileid')).exists()):
file_to_load = DataFile.objects.get(pk=request.GET.get('fileid'))
# Uplod the file! # Uplod the file!
final_file_path = settings.NEXTCLOUD_URL + "remote.php/dav/files/vhdadjangoapi_8fjz47epc6/Agenturdaten_"+ str(agency.pk) + "/Standards Uploadbereich/" + file_to_load.name final_file_path = settings.NEXTCLOUD_URL + "remote.php/dav/files/vhdadjangoapi_8fjz47epc6/Agenturdaten_"+ str(agency.pk) + "/Standards Uploadbereich/" + file_to_load.name
with open(file_to_load.file.path, 'rb') as f: with open(file_to_load.file.path, 'rb') as f:
r = requests.put(final_file_path, data=f, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API)) r = requests.put(final_file_path, data=f, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API))
if(len(r.text) == 0):
return JsonResponse({'status' : True, 'message': 'Datei ' + file_to_load.name + ' angelegt.'})
else:
return JsonResponse({'status' : True, 'message': 'Datei ' + file_to_load.name + ' konnte nicht angelegt. Bitte manuell prüfen!'})
else:
return JsonResponse({'status' : True, 'message': 'Datei ID nicht gefunden'})
if(len(r.text) == 0):
return JsonResponse({'status' : True, 'message': 'Datei ' + file_to_load.name + ' angelegt.'})
else:
return JsonResponse({'status' : True, 'message': 'Datei ' + file_to_load.name + ' konnte nicht angelegt. Bitte manuell prüfen!'})
return JsonResponse({"status" : "NO AUTH"}) return JsonResponse({"status" : "NO AUTH"})