JsonResponses raus

This commit is contained in:
holger.trampe 2021-01-29 17:49:18 +01:00
parent 2c70ff7e2d
commit 99ffe0afdd
1 changed files with 43 additions and 2 deletions

View File

@ -182,9 +182,50 @@ def getICSFileEx(request, code, ag):
return response
def getICSFileExAll(request, code, ag):
if(request.method == "GET"):
try:
#try:
agency = Agency.objects.get(pk=ag)
if agency != None and agency.agencycal_publicstatus == 1 and str(code) == str(agency.agencycalurl):
c = Calendar()
absencedays = Absence.objects.filter(agency=ag).exclude(confirm_status=2)
for ab in absencedays:
if ab.start != None and ab.end != None:
e = Event()
e.name = ab.user.first_name + " " + ab.user.last_name + " | " + ab.reason.name
e.uid = "da-ab-" + str(ab.pk)
if ab.start < ab.end:
e.begin = ab.start
e.end = ab.end
else:
e.begin = ab.start
e.end = ab.start + timedelta(minutes=1)
#e.allday = True
c.events.add(e)
return HttpResponse(c, content_type='text/calendar')
else:
realm = ""
response = HttpResponse()
response.status_code = 400
return response
#except:
# realm = ""
# response = HttpResponse()
# response.status_code = 403
# return response
else:
realm = ""
response = HttpResponse()
response.status_code = 404
return response
'''
def getICSFileExAll(request, code, ag):
if(request.method == "GET"):
#try:
agency = Agency.objects.get(pk=ag)
if agency != None and agency.agencycal_publicstatus == 1 and str(code) == str(agency.agencycalurl_all):
c = Calendar()
@ -218,7 +259,7 @@ def getICSFileExAll(request, code, ag):
response = HttpResponse()
response.status_code = 404
return response
'''
'''