API Tabelle vervollständigt
This commit is contained in:
parent
2b9bad6ad3
commit
df81a05a7f
76
api.py
76
api.py
@ -57,7 +57,7 @@ def page(username: str, year: int, month: int):
|
|||||||
# Gehe jeden einzelnen Tag des Dictionaries für die Timestamps durch
|
# Gehe jeden einzelnen Tag des Dictionaries für die Timestamps durch
|
||||||
for day in list(timestamps_dict):
|
for day in list(timestamps_dict):
|
||||||
booking_text = ""
|
booking_text = ""
|
||||||
current_day_date = f"{day}.{month}.{year}"
|
current_day_date = f"{datetime(year, month, day).strftime('%a')}, {day}.{month}.{year}"
|
||||||
|
|
||||||
# Abwesenheitseinträge
|
# Abwesenheitseinträge
|
||||||
try:
|
try:
|
||||||
@ -65,6 +65,9 @@ def page(username: str, year: int, month: int):
|
|||||||
for i in list(user_absent):
|
for i in list(user_absent):
|
||||||
if int(i) == day:
|
if int(i) == day:
|
||||||
booking_text += absence_entries[user_absent[i]]["name"] + " "
|
booking_text += absence_entries[user_absent[i]]["name"] + " "
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
pass
|
||||||
|
|
||||||
# Buchungen behandeln
|
# Buchungen behandeln
|
||||||
for i in range(len(timestamps_dict[day])):
|
for i in range(len(timestamps_dict[day])):
|
||||||
@ -76,11 +79,73 @@ def page(username: str, year: int, month: int):
|
|||||||
if len(timestamps_dict[day]) % 2 != 0:
|
if len(timestamps_dict[day]) % 2 != 0:
|
||||||
booking_text += datetime.fromtimestamp(int(timestamps_dict[day][i])).strftime('%H:%M')
|
booking_text += datetime.fromtimestamp(int(timestamps_dict[day][i])).strftime('%H:%M')
|
||||||
|
|
||||||
except Exception as e:
|
# Ist-Zeiten berechnen
|
||||||
print(e)
|
timestamps_of_this_day = []
|
||||||
|
|
||||||
|
# Suche mir alle timestamps für diesen Tag
|
||||||
|
for i in timestamps:
|
||||||
|
actual_timestamp = datetime.fromtimestamp(int(i))
|
||||||
|
timestamp_day = actual_timestamp.strftime('%-d')
|
||||||
|
|
||||||
|
if int(timestamp_day) == int(day):
|
||||||
|
timestamps_of_this_day.append(i)
|
||||||
|
|
||||||
|
timestamps_of_this_day.sort()
|
||||||
|
time_sum = 0
|
||||||
|
if len(timestamps_of_this_day) > 1:
|
||||||
|
|
||||||
|
if len(timestamps_of_this_day) % 2 == 0:
|
||||||
|
for i in range(0, len(timestamps_of_this_day), 2):
|
||||||
|
time_delta = int(
|
||||||
|
timestamps_of_this_day[i + 1]) - int(
|
||||||
|
timestamps_of_this_day[i])
|
||||||
|
time_sum = time_sum + time_delta
|
||||||
|
else:
|
||||||
|
for i in range(0, len(timestamps_of_this_day) - 1, 2):
|
||||||
|
time_delta = int(
|
||||||
|
timestamps_of_this_day[i + 1]) - int(
|
||||||
|
timestamps_of_this_day[i])
|
||||||
|
time_sum = time_sum + time_delta
|
||||||
|
|
||||||
|
is_time = convert_seconds_to_hours(time_sum) + " h"
|
||||||
|
else:
|
||||||
|
is_time = "Kein"
|
||||||
|
|
||||||
|
# Sollzeit bestimmen
|
||||||
|
|
||||||
|
hours_to_work = int(current_user.get_day_workhours(year, month, day))
|
||||||
|
|
||||||
|
if hours_to_work < 0:
|
||||||
|
target_time = ""
|
||||||
|
else:
|
||||||
|
target_time = f"{convert_seconds_to_hours(int(hours_to_work) * 3600)} h"
|
||||||
|
if int(hours_to_work) == 0:
|
||||||
|
booking_text = "Kein Arbeitstag"
|
||||||
|
|
||||||
|
# Saldo für den Tag berechnen
|
||||||
|
day_in_list = datetime(year, month, day)
|
||||||
|
if time.time() > day_in_list.timestamp():
|
||||||
|
|
||||||
|
time_duty = int(current_user.get_day_workhours(year, month, day)) * 3600
|
||||||
|
if time_duty < 0:
|
||||||
|
saldo = 0
|
||||||
|
total = ""
|
||||||
|
else:
|
||||||
|
saldo = int(time_sum) - int(time_duty)
|
||||||
|
# Nach Abwesenheitseinträgen suchen
|
||||||
|
try:
|
||||||
|
for i in list(user_absent):
|
||||||
|
if int(i) == day and user_absent[i] != "UU":
|
||||||
|
saldo = 0
|
||||||
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
rows.append({'date': current_day_date, 'bookings': booking_text, 'is_time': 0, 'target_time': 0, 'total': 0})
|
general_saldo = general_saldo + saldo
|
||||||
|
total = f"{convert_seconds_to_hours(saldo)} h"
|
||||||
|
else:
|
||||||
|
total = "-"
|
||||||
|
|
||||||
|
rows.append({'date': current_day_date, 'bookings': booking_text, 'is_time': is_time, 'target_time': target_time, 'total': total})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -90,8 +155,7 @@ def page(username: str, year: int, month: int):
|
|||||||
#]
|
#]
|
||||||
|
|
||||||
overview_table = ui.table(columns=columns, rows=rows).classes('w-120')
|
overview_table = ui.table(columns=columns, rows=rows).classes('w-120')
|
||||||
|
# Zeilenumbruch umsetzen
|
||||||
|
|
||||||
overview_table.add_slot('body-cell', r'''
|
overview_table.add_slot('body-cell', r'''
|
||||||
<td :props="props" :style="{'white-space':'pre-line'}">{{ props.value }}</td>
|
<td :props="props" :style="{'white-space':'pre-line'}">{{ props.value }}</td>
|
||||||
''')
|
''')
|
||||||
|
2
users.py
2
users.py
@ -276,8 +276,10 @@ class user:
|
|||||||
day_to_check = datetime.datetime(int(year), int(month), int(day))
|
day_to_check = datetime.datetime(int(year), int(month), int(day))
|
||||||
|
|
||||||
for entry in reversed(workhour_entries):
|
for entry in reversed(workhour_entries):
|
||||||
|
|
||||||
entry_split = entry.split("-")
|
entry_split = entry.split("-")
|
||||||
entry_dt = datetime.datetime(int(entry_split[0]), int(entry_split[1]), int(entry_split[2]))
|
entry_dt = datetime.datetime(int(entry_split[0]), int(entry_split[1]), int(entry_split[2]))
|
||||||
|
|
||||||
if entry_dt <= day_to_check:
|
if entry_dt <= day_to_check:
|
||||||
weekday = day_to_check.strftime("%w")
|
weekday = day_to_check.strftime("%w")
|
||||||
if int(weekday) == 0:
|
if int(weekday) == 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user