Fehlerbehandlung Standard Zuweisen

This commit is contained in:
holger.trampe 2021-08-20 11:05:29 +02:00
parent 9490831e7f
commit 9542989898
3 changed files with 10 additions and 5 deletions

View File

@ -225,11 +225,12 @@
'agencyid' : {{agency.pk}}, 'agencyid' : {{agency.pk}},
}, },
success: function(data){ success: function(data){
if(data['status'] == true){ if(data['status'] == "OK"){
$("#migfinished").show(); $("#migfinished").show();
} }
else{ else{
$("#cloud_process_standards_error").show(); $("#cloud_process_standards_error").show();
$("#cloud_process_standards_error").html("FEHLER BEI STANDARD " + data['status']);
} }
}, },
error: function(e){ error: function(e){

View File

@ -420,21 +420,24 @@ def getFileIdFromXML(xmlresponse):
''' '''
Standardateien neu zuweisen Standardateien neu zuweisen
Alle Standards werden nacheinander durchgegangen. Pro Datei in addedfiles wird ein neues NCFile-Objekt erstellt und in addedfiles_nc gespeichert. In den Ansichten der Standards werden dann nur noch die addedfiles_nc-Elemente gesehen und verändert.
''' '''
@api_view(['GET'], ) @api_view(['GET'], )
def NCSwitchStandardFiles(request): def NCSwitchStandardFiles(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'))
standards = Standards.objects.filter(agency=agency) standards = Standards.objects.filter(agency=agency)
response_status = "OK"
for s in standards: for s in standards:
for f in s.addedfiles.all(): for f in s.addedfiles.all():
filesearchdata = '<?xml version="1.0" encoding="UTF-8"?><d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:basicsearch><d:select><d:prop><oc:fileid/><d:displayname/></d:prop></d:select><d:from><d:scope><d:href>/files/' + settings.NEXTCLOUD_USER_API + '/Agenturdaten_' + str(agency.pk) + '</d:href><d:depth>infinity</d:depth></d:scope></d:from><d:where><d:like><d:prop><d:displayname/></d:prop><d:literal>' + f.name + '</d:literal></d:like></d:where></d:basicsearch></d:searchrequest>' filesearchdata = '<?xml version="1.0" encoding="UTF-8"?><d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:basicsearch><d:select><d:prop><oc:fileid/><d:displayname/></d:prop></d:select><d:from><d:scope><d:href>/files/' + settings.NEXTCLOUD_USER_API + '/Agenturdaten_' + str(agency.pk) + '</d:href><d:depth>infinity</d:depth></d:scope></d:from><d:where><d:like><d:prop><d:displayname/></d:prop><d:literal>' + f.name + '</d:literal></d:like></d:where></d:basicsearch></d:searchrequest>'
r = requests.request("SEARCH", settings.NEXTCLOUD_URL + "remote.php/dav", data=filesearchdata, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API), headers={'Content-Type' : 'text/xml'}) r = requests.request("SEARCH", settings.NEXTCLOUD_URL + "remote.php/dav", data=filesearchdata, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API), headers={'Content-Type' : 'text/xml'})
fileid = getFileIdFromXML(r.text) fileid = getFileIdFromXML(r.text)
if(fileid == None): if(fileid == None):
pass response_status += " FEHLER BEI STANDARD " + str(s.id) + " "
else: else:
ncfile = NCFile.objects.create(agency=s.agency, nc_id=fileid, file_id=f) ncfile = NCFile.objects.create(agency=s.agency, nc_id=fileid, file_id=f)
s.addedfiles_nc.add(ncfile) s.addedfiles_nc.add(ncfile)
return JsonResponse({"status" : response_status})
return JsonResponse({"status" : "NO AUTH"}) return JsonResponse({"status" : "NO AUTH"})

View File

@ -1,7 +1,7 @@
from django.contrib import admin from django.contrib import admin
from .models import Profile, Agency, AgencyGroup, AgencyJob, AgencyNetwork, AgencyNetworkPreperation, UserTime, UserYearAbsenceInfo, UserNotifications, AgencyBills, RegNotfallhilfe from .models import Profile, Agency, AgencyGroup, AgencyJob, AgencyNetwork, AgencyNetworkPreperation, UserTime, UserYearAbsenceInfo, UserNotifications, AgencyBills, RegNotfallhilfe
from .priomodel import Prio from .priomodel import Prio
from standards.models import StandardCommentRate, StandardComments from standards.models import StandardCommentRate, StandardComments, NCFile
from django.contrib.auth.models import Permission from django.contrib.auth.models import Permission
from message.models import Message from message.models import Message
from cloud.models import DataFile, DataDir from cloud.models import DataFile, DataDir
@ -44,4 +44,5 @@ admin.site.register(RDContact)
admin.site.register(RecoverDirSetting) admin.site.register(RecoverDirSetting)
admin.site.register(MainStatistic) admin.site.register(MainStatistic)
admin.site.register(RegNotfallhilfe) admin.site.register(RegNotfallhilfe)
admin.site.register(AGBLog) admin.site.register(AGBLog)
admin.site.register(NCFile)