From 3aa1566828e21ea56999d02bab88a208ff82a526 Mon Sep 17 00:00:00 2001 From: "holger.trampe" Date: Fri, 29 Jan 2021 17:42:51 +0100 Subject: [PATCH] JsonResponses raus --- users/views.py | 56 ++++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/users/views.py b/users/views.py index 124a515..6df2903 100644 --- a/users/views.py +++ b/users/views.py @@ -130,7 +130,7 @@ def getICSFileAll(request, ag): 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') @@ -147,40 +147,28 @@ def getICSFileEx(request, code, ag): #try: agency = Agency.objects.get(pk=ag) - print("AG CODE: " + str(agency.agencycalurl)) - print("CODE REQUEST: " + str(code)) - print(str(code) == str(agency.agencycalurl)) + 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 + " abwesend " + e.uid = "da-ab-" + str(ab.pk) - if agency != None: - if agency.agencycal_publicstatus == 1: - if 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 + " abwesend " - 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: - return JsonResponse({"err" : "WRONG CODE"}) - else: - return JsonResponse({"err" : "AGENCY NOT PUBLIC"}) - else: - return JsonResponse({"err" : "AGENCY NOT FOUND"}) - #realm = "" - #response = HttpResponse() - #response.status_code = 400 - #return response + 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) + else: + realm = "" + response = HttpResponse() + response.status_code = 400 + return response #except: # realm = "" # response = HttpResponse()