Arbeitstage werden nicht mehr gelöscht aber markiert
This commit is contained in:
parent
02c940dd83
commit
f88c6cb716
Binary file not shown.
|
|
@ -24,8 +24,10 @@ from digitaleagentur.sec import *
|
|||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
# Nach zehn Stunden läuft der Cookie ab!
|
||||
# TASK: Zehn stunden auto-auslog einmal checken Sekunden!
|
||||
SESSION_COOKIE_AGE = 8*60*60
|
||||
|
||||
|
||||
CHANNELS_PRESENCE_MAX_AGE = 30
|
||||
|
||||
# FOR SUMMERNOTE ORIGIN
|
||||
|
|
|
|||
|
|
@ -60,9 +60,15 @@ def checkAbsenceWorkdayCollide(absence):
|
|||
if(getIsAbsenceStartEndHalf(absence)):
|
||||
workday.target = workday.target / 2
|
||||
workday.save()
|
||||
# Ganzer Tag vorhanden, Arbeitstag wird gelöscht
|
||||
# Ganzer Tag vorhanden, Arbeitstag wird als löschen markiert, aber nicht gelöscht
|
||||
else:
|
||||
workday.delete()
|
||||
workday.delflag = True
|
||||
workday.save()
|
||||
else:
|
||||
# Sollte der ganze Tag mal als zu löschen markiert worden sein, wird dies hier zurückgenommen
|
||||
if workday.delflag == True:
|
||||
workday.delflag = False
|
||||
workday.save()
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -390,7 +390,7 @@ def isUserInRep(task, area, user_id):
|
|||
# Check for active WorkDay
|
||||
@register.simple_tag
|
||||
def getactualworkingday(user):
|
||||
wd = Workday.objects.filter(user=user, agency=user.profile.agency, end=None)
|
||||
wd = Workday.objects.filter(user=user, agency=user.profile.agency, end=None, delflag = False)
|
||||
returnstat = 0
|
||||
|
||||
if(len(wd) > 0):
|
||||
|
|
@ -417,7 +417,7 @@ def loadmonthwork(nextmonth, user):
|
|||
if month == 0:
|
||||
month = 12
|
||||
|
||||
workdays = Workday.objects.filter(user=user, agency=user.profile.agency, start__month=month)
|
||||
workdays = Workday.objects.filter(user=user, agency=user.profile.agency, start__month=month, delflag = False)
|
||||
|
||||
finalsum = 0
|
||||
|
||||
|
|
@ -442,13 +442,13 @@ def loadmonthwork(nextmonth, user):
|
|||
# Return formatted Time-String
|
||||
@register.simple_tag
|
||||
def getformatedstarttime(user):
|
||||
wd = list(Workday.objects.filter(user=user, agency=user.profile.agency, end=None))[0]
|
||||
wd = list(Workday.objects.filter(user=user, agency=user.profile.agency, end=None, delflag = False))[0]
|
||||
return wd.start.strftime("%H:%M:%S")
|
||||
|
||||
@register.simple_tag
|
||||
def getformattetstarttime_last_start(user):
|
||||
today = date.today()
|
||||
wd = Workday.objects.filter(user=user, agency=user.profile.agency, start__day=today.day).order_by("start")
|
||||
wd = Workday.objects.filter(user=user, agency=user.profile.agency, start__day=today.day, delflag = False).order_by("start")
|
||||
|
||||
if(len(wd) == 0):
|
||||
return ("00:00:00")
|
||||
|
|
@ -458,7 +458,7 @@ def getformattetstarttime_last_start(user):
|
|||
@register.simple_tag
|
||||
def getformattetstarttime_last_end(user):
|
||||
today = date.today()
|
||||
wd = Workday.objects.filter(user=user, agency=user.profile.agency, end__day=today.day).order_by("end")
|
||||
wd = Workday.objects.filter(user=user, agency=user.profile.agency, end__day=today.day, delflag = False).order_by("end")
|
||||
|
||||
if(len(wd) == 0):
|
||||
return ("00:00:00")
|
||||
|
|
@ -467,7 +467,7 @@ def getformattetstarttime_last_end(user):
|
|||
|
||||
@register.simple_tag
|
||||
def getactualbreak(user):
|
||||
wd = Workday.objects.filter(user=user, agency=user.profile.agency, end=None)
|
||||
wd = Workday.objects.filter(user=user, agency=user.profile.agency, end=None, delflag = False)
|
||||
returnstat = 0
|
||||
# ACTIVE WORKING DAY
|
||||
if(len(wd) > 0):
|
||||
|
|
@ -486,7 +486,7 @@ def getactualbreak(user):
|
|||
|
||||
@register.simple_tag
|
||||
def getactualbreakcounter(user):
|
||||
wd = Workday.objects.filter(user=user, agency=user.profile.agency, end=None)
|
||||
wd = Workday.objects.filter(user=user, agency=user.profile.agency, end=None, delflag = False)
|
||||
returnstat = False
|
||||
# ACTIVE WORKING DAY
|
||||
if(len(wd) > 0):
|
||||
|
|
@ -503,7 +503,7 @@ def getactualbreakcounter(user):
|
|||
# GET ALL BREAK AS MILLISECOND-RESULT
|
||||
@register.simple_tag
|
||||
def getdailybreaktime(user):
|
||||
wd = list(Workday.objects.filter(user=user, agency=user.profile.agency, end=None))[0]
|
||||
wd = list(Workday.objects.filter(user=user, agency=user.profile.agency, end=None, delflag = False))[0]
|
||||
breaksum = 0
|
||||
for b in wd.breaks.all():
|
||||
if(b.end != None):
|
||||
|
|
@ -513,7 +513,7 @@ def getdailybreaktime(user):
|
|||
@register.simple_tag
|
||||
def getdailybreaktimetoday(user):
|
||||
today = date.today()
|
||||
wd = list(Workday.objects.filter(user=user, agency=user.profile.agency).order_by("start").exclude(end=None))[0]
|
||||
wd = list(Workday.objects.filter(user=user, agency=user.profile.agency, delflag = False).order_by("start").exclude(end=None))[0]
|
||||
breaksum = 0
|
||||
for b in wd.breaks.all():
|
||||
if(b.end != None):
|
||||
|
|
@ -739,7 +739,7 @@ def format_timedelta(td):
|
|||
def loadaccounttime(user):
|
||||
status = 0
|
||||
today = date.today()
|
||||
workdays = Workday.objects.filter(user=user, start__lt=today).exclude(end=None)
|
||||
workdays = Workday.objects.filter(user=user, start__lt=today, delflag = False).exclude(end=None)
|
||||
|
||||
finalaccounttimesum = datetime.timedelta(minutes=0) + datetime.timedelta(hours=UserTime.objects.get(user=user).startcount)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from simple_history.models import HistoricalRecords
|
|||
# Create your models here.
|
||||
class Workday(models.Model):
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
delflag = models.BooleanField(default=False)
|
||||
agency = models.ForeignKey(Agency, on_delete=models.CASCADE)
|
||||
breaks = models.ManyToManyField("Breaks", blank=True, related_name='breaks_at_day')
|
||||
start = models.DateTimeField(default=None, null=True, blank=True)
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ def TimeManagementTeamSingle(request, pk, activemonth=False, activeyear=False):
|
|||
prev_year = int(prev_year) - 1
|
||||
|
||||
# Initialprüfung, ob Arbeitstage vorliegen
|
||||
tempworkday = Workday.objects.filter(agency=request.user.profile.agency, user=user).order_by("start").exclude(end=None)[:1]
|
||||
tempworkday = Workday.objects.filter(agency=request.user.profile.agency, user=user, delflag = False).order_by("start").exclude(end=None)[:1]
|
||||
|
||||
user_has_workdays = False
|
||||
if len(tempworkday) == 1:
|
||||
|
|
@ -338,7 +338,7 @@ def TimeManagementTeamSingle(request, pk, activemonth=False, activeyear=False):
|
|||
"activemonth" : activemonth,
|
||||
"active_link" : "timemanagement",
|
||||
"days_this_month" : get_datetime_range(int(active_year), int(activemonth)),
|
||||
"workdays" : Workday.objects.filter(agency=request.user.profile.agency, user=user, start__month=activemonth, start__year=active_year).order_by("start").exclude(end=None),
|
||||
"workdays" : Workday.objects.filter(agency=request.user.profile.agency, user=user, start__month=activemonth, start__year=active_year, delflag = False).order_by("start").exclude(end=None),
|
||||
"userhasworkdays" : user_has_workdays,
|
||||
"user" : user
|
||||
}
|
||||
|
|
@ -384,7 +384,7 @@ def TimeManagement(request, activemonth=False, activeyear=False):
|
|||
prev_year = int(prev_year) - 1
|
||||
|
||||
# Initialprüfung, ob Arbeitstage vorliegen
|
||||
tempworkday = Workday.objects.filter(agency=request.user.profile.agency, user=request.user).order_by("start").exclude(end=None)[:1]
|
||||
tempworkday = Workday.objects.filter(agency=request.user.profile.agency, user=request.user, delflag = False).order_by("start").exclude(end=None)[:1]
|
||||
|
||||
user_has_workdays = False
|
||||
if len(tempworkday) == 1:
|
||||
|
|
@ -402,7 +402,7 @@ def TimeManagement(request, activemonth=False, activeyear=False):
|
|||
"activemonth" : activemonth,
|
||||
"active_link" : "timemanagement",
|
||||
"days_this_month" : get_datetime_range(int(active_year), int(activemonth)),
|
||||
"workdays" : Workday.objects.filter(agency=request.user.profile.agency, user=request.user, start__month=activemonth, start__year=active_year).order_by("start").exclude(end=None),
|
||||
"workdays" : Workday.objects.filter(agency=request.user.profile.agency, user=request.user, start__month=activemonth, start__year=active_year, delflag = False).order_by("start").exclude(end=None),
|
||||
"userhasworkdays" : user_has_workdays
|
||||
}
|
||||
if(request.user.has_perm("users.timemanager")):
|
||||
|
|
@ -597,7 +597,7 @@ def TimeAjax(request):
|
|||
targettime = targettime / 2
|
||||
|
||||
# Prpfung, ob bereits Arbeitstage an diesem Tag vorliegen
|
||||
tempworkday = Workday.objects.filter(agency=request.user.profile.agency, user=request.user, start__day=today.day, start__month=today.month, start__year=today.year)
|
||||
tempworkday = Workday.objects.filter(agency=request.user.profile.agency, user=request.user, start__day=today.day, start__month=today.month, start__year=today.year, delflag = False)
|
||||
|
||||
user_has_workdays = False
|
||||
if len(tempworkday) == 1:
|
||||
|
|
@ -617,7 +617,7 @@ def TimeAjax(request):
|
|||
}
|
||||
# END DAY
|
||||
elif request.GET["action"] == "end_day":
|
||||
wd = list(Workday.objects.filter(user=request.user, agency=request.user.profile.agency, end=None))[0]
|
||||
wd = list(Workday.objects.filter(user=request.user, agency=request.user.profile.agency, end=None, delflag = False))[0]
|
||||
# END ALL BREAKS
|
||||
for b in wd.breaks.all():
|
||||
if b.end == None:
|
||||
|
|
@ -638,7 +638,7 @@ def TimeAjax(request):
|
|||
}
|
||||
# START A BREAK
|
||||
elif request.GET["action"] == "start_break":
|
||||
wd = list(Workday.objects.filter(user=request.user, agency=request.user.profile.agency, end=None))[0]
|
||||
wd = list(Workday.objects.filter(user=request.user, agency=request.user.profile.agency, end=None, delflag = False))[0]
|
||||
newbreak = Breaks(workday=wd, user=request.user, agency=request.user.profile.agency, start=timezone.now())
|
||||
newbreak.save()
|
||||
wd.breaks.add(newbreak)
|
||||
|
|
@ -648,12 +648,12 @@ def TimeAjax(request):
|
|||
}
|
||||
# END BREAK
|
||||
elif request.GET["action"] == "end_break":
|
||||
wd = list(Workday.objects.filter(user=request.user, agency=request.user.profile.agency, end=None))[0]
|
||||
wd = list(Workday.objects.filter(user=request.user, agency=request.user.profile.agency, end=None, delflag = False))[0]
|
||||
toendbreak = list(wd.breaks.filter(end=None))[0]
|
||||
toendbreak.end = timezone.now()
|
||||
toendbreak.save()
|
||||
|
||||
wd = list(Workday.objects.filter(user=request.user, agency=request.user.profile.agency, end=None))[0]
|
||||
wd = list(Workday.objects.filter(user=request.user, agency=request.user.profile.agency, end=None, delflag = False))[0]
|
||||
breaksum = 0
|
||||
for b in wd.breaks.all():
|
||||
if(b.end != None):
|
||||
|
|
|
|||
|
|
@ -1012,7 +1012,7 @@ def getDataFromToDelUser(request, pk):
|
|||
status = "Abgelehnt"
|
||||
writer.writerow(['Abwesenheit', str(ab.start), str(ab.end), 'Grund: '+ab.reason.name, 'Status: '+status])
|
||||
|
||||
user_workdays = Workday.objects.filter(agency=request.user.profile.agency, user=user).order_by("-start")
|
||||
user_workdays = Workday.objects.filter(agency=request.user.profile.agency, user=user, delflag = False).order_by("-start")
|
||||
for wd in user_workdays:
|
||||
breaks = Breaks.objects.filter(agency=request.user.profile.agency, user=user, workday=wd)
|
||||
breaks_string = ""
|
||||
|
|
@ -1606,7 +1606,7 @@ def cronactionsdaily(request, code):
|
|||
# Arbeitstage beenden
|
||||
if(user.usertime.usetime):
|
||||
try:
|
||||
workdays = Workday.objects.filter(user=user, end=None)
|
||||
workdays = Workday.objects.filter(user=user, end=None, delflag = False)
|
||||
for wd in workdays:
|
||||
mailstatus += "\n WORKDAY AUTEND ID " + str(wd.pk)
|
||||
wd.end = datetime(wd.start.year, wd.start.month, wd.start.day, 23, 59)
|
||||
|
|
@ -1619,7 +1619,7 @@ def cronactionsdaily(request, code):
|
|||
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, delflag = False))
|
||||
|
||||
targettworktime = 0.0
|
||||
# Mitarbeiter hat für den gestrigen Tag keine Zeiten erfasst, daher automatisch auf null wenn KEINE Abwesenheit eingetragen wurde
|
||||
|
|
|
|||
Loading…
Reference in New Issue