asd
This commit is contained in:
parent
eee39eca75
commit
c7daf964e5
|
|
@ -28,5 +28,6 @@ urlpatterns = [
|
|||
path('uschanged/<str:uid>/<str:sid>', views.userChangedInNc, name="api-userchanged"),
|
||||
path('deletefile/<slug:fid>/<slug:secretkey>', views.deleteNCFile, name="api-deletencfile"),
|
||||
path('tm/startday/<slug:uid>/<slug:secretkey>', views.startWorkDay, name="api-startday"),
|
||||
path('tm/endday/<slug:uid>/<slug:secretkey>', views.endWorkDay, name="api-endday"),
|
||||
path('tm/gettime/<slug:uid>/<slug:secretkey>', views.getTime, name="api-gettime"),
|
||||
]
|
||||
103
api/views.py
103
api/views.py
|
|
@ -470,10 +470,52 @@ def deleteNCFile(request, fid, secretkey):
|
|||
# APIs for TIMEMANAGEMENT
|
||||
@api_view(['GET'], )
|
||||
def startWorkDay(request, uid, secretkey):
|
||||
print("kasjdkajhsdkjhasdjksha")
|
||||
if request.method == "GET" and secretkey == '87zuhjk87GHJ546tzgvhas76aaskbdhr45edfVHAKia87s6gbAVGFGSR3451627gBHAKJBN':
|
||||
print("START A DAY!")
|
||||
return HttpResponse(1)
|
||||
user = User.objects.filter(username=uid).first()
|
||||
today = date.today()
|
||||
targettime = 0.0
|
||||
if(today.isoweekday() == 1):
|
||||
targettime = user.usertime.wd_mo
|
||||
elif(today.isoweekday() == 2):
|
||||
targettime = user.usertime.wd_tu
|
||||
elif(today.isoweekday() == 3):
|
||||
targettime = user.usertime.wd_we
|
||||
elif(today.isoweekday() == 4):
|
||||
targettime = user.usertime.wd_th
|
||||
elif(today.isoweekday() == 5):
|
||||
targettime = user.usertime.wd_fr
|
||||
elif(today.isoweekday() == 6):
|
||||
targettime = user.usertime.wd_sa
|
||||
elif(today.isoweekday() == 7):
|
||||
targettime = user.usertime.wd_so
|
||||
|
||||
# Liegt eine halbe Abwesenheit vor, wird hier die Zielarbeitszeit halbiert
|
||||
if(getAbsenceForOneDay(user, today) != False):
|
||||
targettime = targettime / 2
|
||||
|
||||
# Prpfung, ob bereits Arbeitstage an diesem Tag vorliegen
|
||||
tempworkday = Workday.objects.filter(agency=user.profile.agency, user=user, start__day=today.day, start__month=today.month, start__year=today.year, delflag = False)
|
||||
|
||||
|
||||
user_has_workdays = False
|
||||
if len(tempworkday) == 0:
|
||||
# Noch kein Arbeitstag vorhanden, Zielarbeitszeit ganz normal
|
||||
user_has_workdays = True
|
||||
else:
|
||||
# Es ist bereits ein ARbeitstag vorhanden, daher wird die Zielarbeitszeit des zweiten Teils auf 0 gesetzt
|
||||
targettime=0.0
|
||||
|
||||
|
||||
wd = Workday(user=user, agency=user.profile.agency, start=timezone.now(), target=targettime)
|
||||
wd.save()
|
||||
|
||||
data = {
|
||||
"success" : True,
|
||||
"wd_starttime" : wd.start.strftime("%H:%M:%S"),
|
||||
"wd_starttime_complete" : wd.start
|
||||
}
|
||||
|
||||
return JsonResponse(data)
|
||||
else:
|
||||
return JsonResponse({"status" : "FALSE"})
|
||||
|
||||
|
|
@ -545,10 +587,61 @@ def loadaccounttime(user):
|
|||
return [final_info_data_neu, status]
|
||||
|
||||
|
||||
'''
|
||||
Gibt alle aktuellen Zeitdaten zurück:
|
||||
- Aktuelles Gleitzeitkonto
|
||||
- Ob ein aktueller Arbeitstag vorliegt (wenn ja, dann die entsprechenden Daten)
|
||||
|
||||
'''
|
||||
@api_view(['GET'], )
|
||||
def getTime(request, uid, secretkey):
|
||||
if request.method == "GET" and secretkey == '87zuhjk87GHJ546tzgvhas76aaskbdhr45edfVHAKia87s6gbAVGFGSR3451627gBHAKJBN':
|
||||
return HttpResponse(loadaccounttime(User.objects.filter(username=uid).first())[0])
|
||||
user = User.objects.filter(username=uid).first()
|
||||
wd = Workday.objects.filter(user=user, agency=user.profile.agency, end=None, delflag = False)
|
||||
workdaydata_workday = 0
|
||||
workdaydata_starttime = 0
|
||||
|
||||
if(len(wd) > 0):
|
||||
wd_second = list(Workday.objects.filter(user=user, agency=user.profile.agency, end=None, delflag = False))[0]
|
||||
workdaydata_workday = list(wd)[0].start
|
||||
workdaydata_starttime = wd_second.start.strftime("%H:%M:%S")
|
||||
return JsonResponse({'actualtime' : loadaccounttime(user)[0], 'workdaydata_workday' : workdaydata_workday, 'workdaydata_starttime' : workdaydata_starttime})
|
||||
|
||||
else:
|
||||
return JsonResponse({"status" : "FALSE"})
|
||||
return ({"status" : "FALSE"})
|
||||
|
||||
|
||||
# APIs for TIMEMANAGEMENT
|
||||
# End a WorkDay
|
||||
@api_view(['GET'], )
|
||||
def endWorkDay(request, uid, secretkey):
|
||||
if request.method == "GET" and secretkey == '87zuhjk87GHJ546tzgvhas76aaskbdhr45edfVHAKia87s6gbAVGFGSR3451627gBHAKJBN':
|
||||
user = User.objects.filter(username=uid).first()
|
||||
wd = list(Workday.objects.filter(user=user, agency=user.profile.agency, end=None, delflag = False))[0]
|
||||
# END ALL BREAKS
|
||||
for b in wd.breaks.all():
|
||||
if b.end == None:
|
||||
b.end = timezone.now()
|
||||
b.save()
|
||||
wd.end = timezone.now()
|
||||
wd.save()
|
||||
|
||||
breaksum = 0
|
||||
for b in wd.breaks.all():
|
||||
if(b.end != None):
|
||||
breaksum += (b.end - b.start).seconds
|
||||
|
||||
data = {
|
||||
"success" : True,
|
||||
"wd_endtime" : wd.end.strftime("%H:%M:%S"),
|
||||
"actualbreaktime" : breaksum*1000
|
||||
}
|
||||
|
||||
return JsonResponse(data)
|
||||
else:
|
||||
return JsonResponse({"status" : "FALSE"})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue