diff --git a/cloud/views.py b/cloud/views.py index d7f30d8..3ff9352 100644 --- a/cloud/views.py +++ b/cloud/views.py @@ -251,7 +251,7 @@ def adddirbyajax(request, parent): # VALIDATE FILE-TYPE file_ext_arr = request.FILES['uploadedfile'].name.split(".") file_ext = file_ext_arr[len(file_ext_arr)-1] - allowed_types = ["txt", "TXT", "png", "PNG", "jpeg", "JPEG", "jpg", "JPG", "PDF", "pdf", "csv", "CSV", "DOC", "doc", "DOCX", "docx", "ODT", "odt", "PPT", "ppt", "PPTX", "pptx", "XLS", "xls", "XLSX", "xlsx", "mov", "MOV", "SVG", "svg", "ZIP", "zip", "RAR", "rar", "EPS", "eps", "MP3", "mp3", "WAV", "wav", "avi", "AVI", "FLV", "flv", "MP4", "mp4", "PAGES", "pages", "NUMBERS", "numbers", "ics", "ICS"] + allowed_types = ["txt", "TXT", "png", "PNG", "jpeg", "JPEG", "jpg", "JPG", "PDF", "pdf", "csv", "CSV", "DOC", "doc", "DOCX", "docx", "ODT", "odt", "PPT", "ppt", "PPTX", "pptx", "XLS", "xls", "XLSX", "xlsx", "xlsm", "XLSM", "mov", "MOV", "SVG", "svg", "ZIP", "zip", "RAR", "rar", "EPS", "eps", "MP3", "mp3", "WAV", "wav", "avi", "AVI", "FLV", "flv", "MP4", "mp4", "PAGES", "pages", "NUMBERS", "numbers", "ics", "ICS"] file_ok = False for t in allowed_types: diff --git a/dump.rdb b/dump.rdb index 4794165..1e8d426 100644 Binary files a/dump.rdb and b/dump.rdb differ diff --git a/timemanagement/views.py b/timemanagement/views.py index bab1b07..fb03c10 100644 --- a/timemanagement/views.py +++ b/timemanagement/views.py @@ -40,7 +40,6 @@ def loadingFreeDays(plz): # CALCULATE FREEDAYS AS JSON year = today = date.today().year - URL = "https://feiertage-api.de/api/" PARAMS = {'jahr':year,'nur_land':land} r = requests.get(url = URL, params = PARAMS) diff --git a/users/templates/users/searchres.html b/users/templates/users/searchres.html index e078d21..ef32b65 100644 --- a/users/templates/users/searchres.html +++ b/users/templates/users/searchres.html @@ -54,10 +54,16 @@

Dateien

{% if res_files|length > 0 %} {% for s in res_files %} -   {{s.name}}

+   {{s.name}} | + {% if s.parent.is_root %} + Zum Heimatverzeichnis + {% else %} + Zum Ordner {{s.parent}} + {% endif %} +

{% endfor %} {% else %} -

Keine Ergebnisse bei Mitarbeitern

+

Keine Ergebnisse bei Dateien

{% endif %}
diff --git a/users/urls.py b/users/urls.py index 65302b3..04fa6c3 100644 --- a/users/urls.py +++ b/users/urls.py @@ -46,7 +46,7 @@ urlpatterns = [ path('icsall/', views.getICSFileAll, name="geticsall"), path('icspublic//', views.getICSFileEx, name="getics"), path('icspublicall//', views.getICSFileExAll, name="geticsall"), - + path('recalculateabsence/', views.recalculateAbsence, name="recalculateabsence"), ] diff --git a/users/views.py b/users/views.py index 727acde..b270a67 100644 --- a/users/views.py +++ b/users/views.py @@ -1286,6 +1286,14 @@ def support(request): else: messages.success(request, f'Supportanfrage erfolgreich! Ihre Ticketnummer ist '+ str(r.json()) +'!') + send_mail( + "Digitale Agentur: " + str(problemconc), + "Hallo " + name, ", wir haben Ihre Anfrage unter der Ticketnummer " + str(r.json()) + " aufgenommen. Vielen Dank. Ihr Team der Digitalen Agentur", + 'noreply@digitale-agentur.com', + [mail], + fail_silently=True + ) + return render(request, 'users/support_done.html', context) else: @@ -1460,23 +1468,31 @@ class landingPage(TemplateView): ''' def absencecheck(user, daytocheck): returnstat = False - print("ABSENCECHECK") absencedays = Absence.objects.filter(agency=user.profile.agency, user=user, confirm_status=0) & (Absence.objects.filter(agency=user.profile.agency, user=user, start=daytocheck) | (Absence.objects.filter(agency=user.profile.agency, user=user, start__lt=daytocheck) & Absence.objects.filter(agency=user.profile.agency, user=user, end__gt=daytocheck)) | Absence.objects.filter(agency=user.profile.agency, user=user, end=daytocheck)) if(len(absencedays) > 0): returnstat = True return returnstat + + + # CRONJOBS UM 00:05! def cronactionsdaily(request, code): data = {} + today = date.today() + mailstatus = "BEGIN CRONJOB DAILY" + str(today) + if(code == settings.CRONAPIKEY): allusers = User.objects.all() ''' Pro User gibt es das Feld loose_holiday in der UserTime-Info. Ist dieser Tag vorbei, muss die Differenz der days_inuse des VORJHARES in den Rest das AKTUELLEN JAHRES gespeichert werden! ''' - today = date.today() + for user in allusers: + + mailstatus += "\n USER: " + user.first_name + " " + user.last_name + " ID: (" + str(user.pk) + ")" + # REST URLAUB BERECHNUNG #try: usertimedata = UserTime.objects.get(user=user) @@ -1496,72 +1512,220 @@ def cronactionsdaily(request, code): day = day # Restetag erreicht, Reste ins nächste Jahr übertragen + ''' DAS IST UNNÖTIG ''' + ''' if(str(day_tocheck) == str(day) and str(month_tocheck) == str(month)): sourceyear = today.year this_year = list(UserYearAbsenceInfo.objects.filter(year=sourceyear, user=user))[0] next_year = list(UserYearAbsenceInfo.objects.filter(year=sourceyear+1, user=user))[0] next_year.restdays = this_year.days - this_year.days_inuse next_year.save() + ''' - if(user.usertime.usetime): - workdays = Workday.objects.filter(user=user, end=None) - for wd in workdays: - wd.end = datetime(wd.start.year, wd.start.month, wd.start.day, 23, 59) - wd.save() + # Arbeitstage beenden + try: + if(user.usertime.usetime): + try: + workdays = Workday.objects.filter(user=user, end=None) + for wd in workdays: + mailstatus += "\n WORKDAY AUTEND ID " + wd.pk + wd.end = datetime(wd.start.year, wd.start.month, wd.start.day, 23, 59) + wd.save() + except: + mailstatus += "ERROR WORKDAYS AUTO END" - yesterday = date.today() - timedelta(days=1) - weekday = yesterday.weekday() + # AUTO ARBEITSTAGE HINZUFÜGEN + try: + yesterday = date.today() - timedelta(days=1) + weekday = yesterday.weekday() - workdays_yesterday = len(Workday.objects.filter(user=user, start__day=yesterday.day, start__month=yesterday.month, start__year=yesterday.year)) + workdays_yesterday = len(Workday.objects.filter(user=user, start__day=yesterday.day, start__month=yesterday.month, start__year=yesterday.year)) - targettworktime = 0.0 - # Mitarbeiter hat für den gestrigen Tag keine Zeiten erfasst, daher automatisch auf null wenn KEINE Abwesenheit eingetragen wurde - if(weekday == 0): - targettworktime = user.usertime.wd_mo - if(weekday == 1): - targettworktime = user.usertime.wd_tu - if(weekday == 2): - targettworktime = user.usertime.wd_we - if(weekday == 3): - targettworktime = user.usertime.wd_th - if(weekday == 4): - targettworktime = user.usertime.wd_fr - if(weekday == 5): - targettworktime = user.usertime.wd_sa - if(weekday == 6): - targettworktime = user.usertime.wd_so + targettworktime = 0.0 + # Mitarbeiter hat für den gestrigen Tag keine Zeiten erfasst, daher automatisch auf null wenn KEINE Abwesenheit eingetragen wurde + if(weekday == 0): + targettworktime = user.usertime.wd_mo + if(weekday == 1): + targettworktime = user.usertime.wd_tu + if(weekday == 2): + targettworktime = user.usertime.wd_we + if(weekday == 3): + targettworktime = user.usertime.wd_th + if(weekday == 4): + targettworktime = user.usertime.wd_fr + if(weekday == 5): + targettworktime = user.usertime.wd_sa + if(weekday == 6): + targettworktime = user.usertime.wd_so - # Es wird nur ein Arbeitstag erstellt, wenn KEINE Abwesenheiten vorliegen und der Nutzer an diesem Tag arbeiten muss - if(workdays_yesterday == 0 and absencecheck(user, yesterday) == False and targettworktime > 0.0 and user.usertime.usetime_start <= today): - workdaytemp = Workday(user=user, agency=user.profile.agency, start=datetime(yesterday.year, yesterday.month, yesterday.day, 8, 0), end=datetime(yesterday.year, yesterday.month, yesterday.day, 8, 0), target=targettworktime) - workdaytemp.save() + # Es wird nur ein Arbeitstag erstellt, wenn KEINE Abwesenheiten vorliegen und der Nutzer an diesem Tag arbeiten muss + if(workdays_yesterday == 0 and absencecheck(user, yesterday) == False and targettworktime > 0.0 and user.usertime.usetime_start <= today): + workdaytemp = Workday(user=user, agency=user.profile.agency, start=datetime(yesterday.year, yesterday.month, yesterday.day, 8, 0), end=datetime(yesterday.year, yesterday.month, yesterday.day, 8, 0), target=targettworktime) + workdaytemp.save() + except: + mailstatus += "ERROR AUTO ADDING WORKDAYS" + try: + # Erinnerungsmails/Push bei Vertretung verschicken + one_week_later = date.today() + timedelta(days=7) + + repre_absence = Absence.objects.filter(representator=user, start=one_week_later, confirm_status=0) + + for r in repre_absence: + if(r.representator.usernotifications.absence_user_is_rep_reminder_mail): + sendMailNoti(" in einer Woche startet Ihre Vertretung für " + r.user.first_name + " " + r.user.last_name + "!", user) - # Erinnerungsmails/Push bei Vertretung verschicken - one_week_later = date.today() + timedelta(days=7) - - repre_absence = Absence.objects.filter(representator=user, start=one_week_later, confirm_status=0) - - for r in repre_absence: - if(r.representator.usernotifications.absence_user_is_rep_reminder_mail): - sendMailNoti(" in einer Woche startet Ihre Vertretung für " + r.user.first_name + " " + r.user.last_name + "!", user) + if(r.representator.usernotifications.absence_user_is_rep_reminder_push): + newnotification = UserNotification(touser=user, notificationtext="Erinnerung für Abwesenheitsvertretung!", notificationtype="", elementid=r.pk) + newnotification.save() - if(r.representator.usernotifications.absence_user_is_rep_reminder_push): - newnotification = UserNotification(touser=user, notificationtext="Erinnerung für Abwesenheitsvertretung!", notificationtype="", elementid=r.pk) - newnotification.save() - - channel_layer = channels.layers.get_channel_layer() - async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Abwesenheit | In einer Woche startet Ihre Vertretung für " + r.user.first_name + " " + r.user.last_name + "!"}) - - data.update({"status " + str(user.pk) : "ok"}) - #except ObjectDoesNotExist: - # data.update({"status" + str(user.pk) : "no usertime found for " + user.get_full_name()}) + channel_layer = channels.layers.get_channel_layer() + async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Abwesenheit | In einer Woche startet Ihre Vertretung für " + r.user.first_name + " " + r.user.last_name + "!"}) + except: + mailstatus += "ERROR REMINDER ABSENCEMAIL" + + data.update({"status " + str(user.pk) : "ok"}) + except ObjectDoesNotExist: + data.update({"status" + str(user.pk) : "no usertime found for " + user.get_full_name()}) + mailstatus += "USER HAS NO USERTIMEOBJECT USER-ID: " + str(user.pk) else: - print("API CODE FAILED") data.update({"status" : "failed"}) + + send_mail( + 'DAILYCRONJOB FEEDBACK', + mailstatus, + 'noreply@digitale-agentur.com', + ["htrampe@gmail.com", "info@digitale-agentur.com"], + fail_silently=True + ) + return JsonResponse(data) +#import datetime +from django.db.models.signals import post_save +from users.signals import save_newabsence +from timemanagement.models import Workday, Breaks, AbsenceReason, FreeDays, Absence + +def recalculateAbsence(request, code): + data = {} + calcstat = "BEGIN RECALCULATE ABSENCE" + today = date.today() + year = today.year + post_save.disconnect(save_newabsence, sender=Absence) + + if(code == settings.CRONAPIKEY): + + for user in User.objects.all(): + calcstat += "\n USER " + str(user.pk) + try: + abinfo_lastyear = UserYearAbsenceInfo.objects.get(user=user, year=str(int(year)-1)) + abinfo_thisyear = UserYearAbsenceInfo.objects.get(user=user, year=year) + + abinfo_thisyear.restdays = abinfo_lastyear.days - abinfo_lastyear.days_inuse + abinfo_thisyear.save() + + calcstat += " DAYS UPDATED - NEW RESTDAYS: " + str(abinfo_thisyear.restdays) + + for ab in Absence.objects.filter(user=user, start__year=year): + if(ab.reason.is_holiday): + calculateNewAbsenceDate(ab) + + daysinuse_thisyear = 0.0 + for ab in Absence.objects.filter(user=user, start__year=year): + daysinuse_thisyear += ab.holidays_normal + + calcstat += " NEW DAYSINUSE THIS YEAR " + str(daysinuse_thisyear) + + abinfo_thisyear.days_inuse = daysinuse_thisyear + abinfo_thisyear.save() + except: + calcstat += "ERROR LASTYEAR/THISYEAR USER " + str(user.pk) + + post_save.connect(save_newabsence, sender=Absence) + send_mail( + 'RECALCULATING ABSENCE YEAR INFO PROTOCOLL', + calcstat, + 'noreply@digitale-agentur.com', + ["info@digitale-agentur.com"], + #["htrampe@gmail.com"], + fail_silently=True + ) + return JsonResponse(data) + + + +def calculateNewAbsenceDate(instance): + + newdata = getFinalHolidayData(instance) + + abinfo = list(UserYearAbsenceInfo.objects.filter(user=instance.user, year=instance.start.year))[0] + abinfo_lastyear = "" + abinfo_nextyear = "" + + is_lastyear = False + + abinfo_lastyear = list(UserYearAbsenceInfo.objects.filter(user=instance.user, year=instance.start.year-1)) + if(len(abinfo_lastyear) > 0): + is_lastyear = True + abinfo_lastyear = abinfo_lastyear[0] + + is_nextyear = False + abinfo_nextyear = list(UserYearAbsenceInfo.objects.filter(user=instance.user, year=instance.start.year+1)) + if(len(abinfo_nextyear) > 0): + is_nextyear = True + abinfo_nextyear = abinfo_nextyear[0] + + multiple_info_needays = False + if(hasattr(newdata[3], "__len__")): + multiple_info_needays = True + + # Gleiches Jahr MIT Rest + if(multiple_info_needays and newdata[3][2] == False): + # Rest ist positiv, daher bleibt rest übrig, rest wird in absence gespeichert und vom rest des Jahres-Restes abgezogen + # Rest ist positiv, damit bleibt Rest übrig + if(newdata[3][0] > 0): + instance.holidays_rest = abinfo.restdays - newdata[3][0] + instance.save() + abinfo.restdays = newdata[3][0] + abinfo.save() + # Rest ist negativ + elif(newdata[3][0] < 0): + instance.holidays_rest = (abinfo.restdays - newdata[3][0]) - newdata[3][0]*(-1) + instance.holidays_normal = newdata[3][0]*(-1) + instance.save() + abinfo.restdays = 0 + abinfo.days_inuse = abinfo.days_inuse + newdata[3][0]*(-1) + abinfo.save() + # Rest ist Urlaubsdauer + else: + instance.holidays_rest = abinfo.restdays + instance.save() + #abinfo.days_inuse = abinfo.days_inuse + abinfo.restdays + abinfo.restdays = 0 + abinfo.save() + # Gleiches Jahr ohne Rest + elif(not multiple_info_needays): + abinfo.days_inuse = abinfo.days_inuse + newdata[3] + abinfo.save() + instance.holidays_normal = newdata[3] + instance.save() + # Mehrere Jahre + elif(multiple_info_needays and newdata[3][2] == True): + + abinfo.days_inuse = abinfo.days_inuse + newdata[3][0] + abinfo.save() + abinfo_nextyear.days_inuse = abinfo_nextyear.days_inuse + newdata[3][1] + abinfo_nextyear.restdays = abinfo_nextyear.restdays - newdata[3][3] + abinfo_nextyear.save() + + # Hier werden alle benötigten Tage von Vor- und Nächstem Jahr gespeichert + instance.holidays_normal = newdata[3][0] + instance.holidays_rest = 0 + instance.holidays_normal_next = newdata[3][1] + instance.holidays_rest_next = newdata[3][3] + instance.save() + ''' ABRECHNUNG CRON JOB @@ -1570,8 +1734,10 @@ def cronactionsdaily(request, code): from dateutil.relativedelta import * def cronactionsbill(request, code): data = {} + today = date.today() + mailstatus = "BEGIN CRONJOB BILL" + str(today) + if(code == settings.CRONAPIKEY): - today = date.today() # Check, ob Rechnungen bezahlt wurden unpaid_bills = AgencyBills.objects.all() @@ -1598,7 +1764,6 @@ def cronactionsbill(request, code): # Alle Rechnungen laden, deren Letzter Tag HEUTE ist und bei ausgewähltem Paymentplan 1 eine neue Rechnung erstellen, Mailverschicke, Nutzeraccouns zählen und neue Rechnung in der Agentur hinterlegen new_bills = AgencyBills.objects.filter(end=today) - for bill in new_bills: if bill.agency.paymentstatus == 0 and bill.agency.paymentplan == 1: @@ -1715,8 +1880,18 @@ def cronactionsbill(request, code): msg_html = render_to_string('users/newbill_mail.html', {}) send_mail('Digitale Agentur | Rechnung', 'Sehr geehrte Nutzer, es wurde eine Rechnung für Ihre Digitale Agentur erstellt. Diese können Sie unter Einstellungen, Abrechnung einsehen.','noreply@digitale-agentur.com',[mail_to_send],html_message=msg_html,fail_silently=True) data.update({"newBill_" + str(agency.pk) : newbill.lexid}) + mailstatus += "NEW BILL FOR AGENCY " + str(agency.pk) else: data.update({"status" : "failed"}) + + send_mail( + 'DAILYCRONJOB BILLS FEEDBACK', + mailstatus, + 'noreply@digitale-agentur.com', + ["htrampe@gmail.com", "info@digitale-agentur.com"], + fail_silently=True + ) + return JsonResponse(data) @@ -1736,3 +1911,162 @@ def sendMailNoti(notificationtext, user_touched, linktarget=""): def isAlive(request): return JsonResponse({"status" : True}) + +''' AB HIER WIEDER RAUSNEHMEN ''' +def getFinalHolidayData(abscence): + user = abscence.user + usertimedata = UserTime.objects.get(user=user) + today = date.today() + start_day_obj = abscence.start + end_day_obj = abscence.end + + try: + holidayloose_date = datetime.date(start_day_obj.year, int(usertimedata.loose_holidedate.split(".")[1]), int(usertimedata.loose_holidedate.split(".")[0])) + except: + holidayloose_date = datetime.date(2020, int(usertimedata.loose_holidedate.split(".")[1]), int(usertimedata.loose_holidedate.split(".")[0])) + + #start_half = abscence.start_ishalf + #end_half = abscence.end_ishalf + + start_half = False + if abscence.startday_info == "1" or abscence.startday_info == "2": + start_half = True + + end_half = False + if abscence.endday_info == "1" or abscence.endday_info == "2": + end_half = True + + choosenyear = abscence.start.year + yeardata = list(UserYearAbsenceInfo.objects.filter(user=user, agency=user.profile.agency, year=choosenyear))[0] + + holiday_thisyear = 0 + holiday_lastyear = yeardata.restdays + holiday_nextyear = 0 + + try: + holiday_nextyear = list(UserYearAbsenceInfo.objects.filter(user=user, agency=user.profile.agency, + year=choosenyear+1))[0].days - list(UserYearAbsenceInfo.objects.filter(user=user, agency=user.profile.agency, + year=choosenyear+1))[0].days_inuse + holiday_nextyear_rest = list(UserYearAbsenceInfo.objects.filter(user=user, agency=user.profile.agency, + year=choosenyear+1))[0].restdays + except: + holiday_nextyear = yeardata.days + + # Urlaub innerhalb eines Jahres inkl. Prüfung auf Resturlaubsanspruch + if(end_day_obj.year == start_day_obj.year): + # Startt des Urlaubs NACH Verfallsdatum - nur aktuelles JAhr und die Zahl interessiert + if(start_day_obj > holidayloose_date): + need_days = (calculateHolidays(user, start_day_obj, end_day_obj, start_half, end_half))*(-1) + holiday_thisyear = yeardata.days - yeardata.days_inuse - need_days + else: + need_days = (calculateHolidays(user, start_day_obj, end_day_obj, start_half, end_half))*(-1) + # Kein Resturlaub + if(yeardata.restdays == 0.0): + holiday_thisyear = yeardata.days - yeardata.days_inuse - need_days + # Resturlaub vorhanden, berechne mit Resturlaub + else: + holiday_lastyear = yeardata.restdays + holiday_thisyear = yeardata.days - yeardata.days_inuse + temp_holiday = holiday_lastyear - need_days + if(temp_holiday < 0): + holiday_lastyear = 0 + holiday_thisyear = yeardata.days - yeardata.days_inuse + temp_holiday + need_days = [temp_holiday, holiday_thisyear, False] + else: + holiday_lastyear = yeardata.restdays - need_days + need_days = [temp_holiday, holiday_lastyear, False] + # Urlaub geht über das nächstes Jahr hinweg + else: + two_years = True + holiday_lastyear = yeardata.restdays + date_splitter = datetime.date(end_day_obj.year, 1, 1) + + need_days_this = (calculateHolidays(user, start_day_obj, date_splitter, start_half, False))*(-1) + + need_days_next = (calculateHolidays(user, date_splitter, end_day_obj, False, end_half))*(-1) + + need_days = (calculateHolidays(user, start_day_obj, date_splitter, start_half, False))*(-1) + (calculateHolidays(user, date_splitter, end_day_obj, False, end_half))*(-1) + holiday_thisyear = yeardata.days - yeardata.days_inuse - need_days_this + days_nextyear_normal = 0 + days_nextyear_rest = 0 + # Urlaub nächstes Jahr MIT und OHNE Rest + if(holiday_nextyear_rest == 0.0): + holiday_nextyear = holiday_nextyear - (calculateHolidays(user, date_splitter, end_day_obj, False, end_half))*(-1) + else: + temprest = holiday_nextyear_rest - need_days_next + # Rest reicht! + if(temprest >= 0): + holiday_nextyear_rest = temprest + days_nextyear_normal = 0 + days_nextyear_rest = need_days_next + # Rest reicht nicht + else: + holiday_nextyear_rest = 0 + holiday_nextyear += temprest + days_nextyear_rest = need_days_next + temprest + days_nextyear_normal = temprest * -1 + + # TAGE NORMAL, TAGE NEXT NORMAL, TRUE für 2jahre, TAGE NEXT REST + need_days = [need_days_this, days_nextyear_normal, True, days_nextyear_rest] + + data = [ holiday_thisyear, holiday_lastyear, holiday_nextyear, need_days ] + return data + + +def calculateHolidays(user, start, end, start_half, end_half): + restdays = 0 + allfreedays = FreeDays.objects.filter(agency=user.profile.agency) + if(end == start): + if(start_half): + return restdays - 0.5 + else: + return restdays - 1 + else: + if(end < start): + return False + else: + counter = 0 + if(start_half): + counter -= 0.5 + if(end_half): + counter -= 0.5 + + weekdays = [] + freedaycounter = 0 + for dt in daterange(start, end): + day_found = False + if dt.isoweekday() not in weekdays: + counter += 1 + for freeday in allfreedays.all(): + if(dt == freeday.day): + freedaycounter += 1 + day_found = True + if day_found == False: + if(dt.isoweekday() == 1): + if user.usertime.wd_mo == 0.0: + freedaycounter += 1 + elif(dt.isoweekday() == 2): + if user.usertime.wd_tu == 0.0: + freedaycounter += 1 + elif(dt.isoweekday() == 3): + if user.usertime.wd_we == 0.0: + freedaycounter += 1 + elif(dt.isoweekday() == 4): + if user.usertime.wd_th == 0.0: + freedaycounter += 1 + elif(dt.isoweekday() == 5): + if user.usertime.wd_fr == 0.0: + freedaycounter += 1 + elif(dt.isoweekday() == 6): + if user.usertime.wd_sa == 0.0: + freedaycounter += 1 + elif(dt.isoweekday() == 7): + if user.usertime.wd_so == 0.0: + freedaycounter += 1 + + return restdays - counter + freedaycounter + +# Gibt die Woche als Wochentage zurück +def daterange(date1, date2): + for n in range(int ((date2 - date1).days)+1): + yield date1 + timedelta(n)