Feiertage bearbeitet
Beschreibung hinzugefügt Eingabemaske hinzugefügt Löschfunktion hinzugefügt
This commit is contained in:
parent
b24c7912c4
commit
aed20556ec
59
admin.py
59
admin.py
@ -38,7 +38,7 @@ def page_admin():
|
|||||||
settings = ui.tab('Einstellungen')
|
settings = ui.tab('Einstellungen')
|
||||||
users = ui.tab('Benutzer')
|
users = ui.tab('Benutzer')
|
||||||
|
|
||||||
with ((ui.tab_panels(tabs, value=time_overview))):
|
with (((ui.tab_panels(tabs, value=time_overview)))):
|
||||||
|
|
||||||
with ui.tab_panel(time_overview):
|
with ui.tab_panel(time_overview):
|
||||||
ui.markdown("##Übersichten")
|
ui.markdown("##Übersichten")
|
||||||
@ -291,7 +291,8 @@ Dies kann nicht rückgägig gemacht werden!''')
|
|||||||
day_type.content = "**Kein Arbeitstag**"
|
day_type.content = "**Kein Arbeitstag**"
|
||||||
day_type.set_visibility(True)
|
day_type.set_visibility(True)
|
||||||
|
|
||||||
|
if day_in_list.strftime("%Y-%m-%d") in data["holidays"]:
|
||||||
|
day_type.content = f'**{data["holidays"][day_in_list.strftime("%Y-%m-%d")]}**'
|
||||||
|
|
||||||
# Saldo für den Tag berechnen
|
# Saldo für den Tag berechnen
|
||||||
|
|
||||||
@ -461,10 +462,11 @@ Dies kann nicht rückgägig gemacht werden!''')
|
|||||||
output_dict["admin_password"] = data["admin_password"]
|
output_dict["admin_password"] = data["admin_password"]
|
||||||
output_dict["port"] = port.value
|
output_dict["port"] = port.value
|
||||||
output_dict["secret"] = secret
|
output_dict["secret"] = secret
|
||||||
|
output_dict["holidays"] = data["holidays"]
|
||||||
json_dict = json.dumps(output_dict, indent=4)
|
json_dict = json.dumps(output_dict, indent=4)
|
||||||
with open(f"{scriptpath}/{usersettingsfilename}", "w") as outputfile:
|
with open(f"{scriptpath}/{usersettingsfilename}", "w") as outputfile:
|
||||||
outputfile.write(json_dict)
|
outputfile.write(json_dict)
|
||||||
if old_port != int(port.value):
|
if int(old_port) != int(port.value):
|
||||||
with ui.dialog() as dialog, ui.card():
|
with ui.dialog() as dialog, ui.card():
|
||||||
ui.markdown("Damit die Porteinstellungen wirksam werden, muss der Server neu gestartet werden.")
|
ui.markdown("Damit die Porteinstellungen wirksam werden, muss der Server neu gestartet werden.")
|
||||||
ui.button("OK", on_click=lambda: dialog.close())
|
ui.button("OK", on_click=lambda: dialog.close())
|
||||||
@ -488,14 +490,40 @@ Dies kann nicht rückgägig gemacht werden!''')
|
|||||||
old_port = data["port"]
|
old_port = data["port"]
|
||||||
port.value = old_port
|
port.value = old_port
|
||||||
|
|
||||||
@ui.refreshable
|
|
||||||
def holiday_section():
|
def holiday_section():
|
||||||
with ui.card():
|
with ui.card():
|
||||||
ui.markdown('**Feiertage:**')
|
ui.markdown('**Feiertage:**')
|
||||||
holidays = data["holidays"]
|
|
||||||
|
def new_holiday_entry():
|
||||||
|
def add_holiday_to_dict():
|
||||||
|
year_from_picker = int(datepicker.value.split("-")[0])
|
||||||
|
month_from_picker = int(datepicker.value.split("-")[1])
|
||||||
|
day_from_picker = int(datepicker.value.split("-")[2])
|
||||||
|
for i in range(0, int(repetition.value)):
|
||||||
|
repetition_date_dt = datetime.datetime(year_from_picker + i, month_from_picker, day_from_picker)
|
||||||
|
date_entry = repetition_date_dt.strftime('%Y-%m-%d')
|
||||||
|
data["holidays"][date_entry] = description.value
|
||||||
|
print(data['holidays'])
|
||||||
|
holiday_buttons_grid.refresh()
|
||||||
|
dialog.close()
|
||||||
|
|
||||||
|
with ui.dialog() as dialog, ui.card():
|
||||||
|
with ui.grid(columns='auto auto'):
|
||||||
|
ui.markdown('Geben Sie den neuen Feiertag ein:').classes('col-span-2')
|
||||||
|
datepicker = ui.date(value=datetime.datetime.now().strftime('%Y-%m-%d')).classes('col-span-2')
|
||||||
|
description = ui.input('Beschreibung').classes('col-span-2')
|
||||||
|
repetition = ui.number('Für Jahre wiederholen', value=1, min=1, precision=0).classes('col-span-2')
|
||||||
|
ui.button("OK", on_click=add_holiday_to_dict)
|
||||||
|
ui.button('Abbrechen', on_click=dialog.close)
|
||||||
|
dialog.open()
|
||||||
|
|
||||||
|
@ui.refreshable
|
||||||
|
def holiday_buttons_grid():
|
||||||
|
|
||||||
|
holidays = list(data["holidays"])
|
||||||
holidays.sort()
|
holidays.sort()
|
||||||
|
|
||||||
year_list = [ ]
|
year_list = []
|
||||||
|
|
||||||
# Jahresliste erzeugen
|
# Jahresliste erzeugen
|
||||||
for i in holidays:
|
for i in holidays:
|
||||||
@ -504,11 +532,11 @@ Dies kann nicht rückgägig gemacht werden!''')
|
|||||||
year_list.append(year)
|
year_list.append(year)
|
||||||
|
|
||||||
year_list = list(set(year_list))
|
year_list = list(set(year_list))
|
||||||
year_dict = { }
|
year_dict = {}
|
||||||
|
|
||||||
# Jahresdictionary konstruieren
|
# Jahresdictionary konstruieren
|
||||||
for i in year_list:
|
for i in year_list:
|
||||||
year_dict[i] = [ ]
|
year_dict[i] = []
|
||||||
|
|
||||||
for i in holidays:
|
for i in holidays:
|
||||||
i_split = i.split("-")
|
i_split = i.split("-")
|
||||||
@ -518,12 +546,23 @@ Dies kann nicht rückgägig gemacht werden!''')
|
|||||||
date_dt = datetime.datetime(year, month, day)
|
date_dt = datetime.datetime(year, month, day)
|
||||||
year_dict[year].append(date_dt)
|
year_dict[year].append(date_dt)
|
||||||
|
|
||||||
for year_entry in year_list:
|
def del_holiday_entry(entry):
|
||||||
|
del(data['holidays'][entry.strftime('%Y-%m-%d')])
|
||||||
|
holiday_buttons_grid.refresh()
|
||||||
|
|
||||||
|
with ui.grid(columns='auto auto'):
|
||||||
|
ui.space()
|
||||||
with ui.row():
|
with ui.row():
|
||||||
|
ui.button("Neuer Eintrag", on_click=new_holiday_entry)
|
||||||
|
|
||||||
|
for year_entry in year_list:
|
||||||
ui.markdown(f"{str(year_entry)}:")
|
ui.markdown(f"{str(year_entry)}:")
|
||||||
|
with ui.row():
|
||||||
for entry in year_dict[year_entry]:
|
for entry in year_dict[year_entry]:
|
||||||
date_label = entry.strftime("%d.%m.%Y")
|
date_label = entry.strftime("%d.%m.%Y")
|
||||||
ui.button(date_label)
|
ui.button(f"{data['holidays'][entry.strftime('%Y-%m-%d')]} ({date_label})", on_click=lambda entry=entry: del_holiday_entry(entry)).classes('bg-blue')
|
||||||
|
holiday_buttons_grid()
|
||||||
|
|
||||||
holiday_section()
|
holiday_section()
|
||||||
|
|
||||||
ui.button("Speichern", on_click=save_admin_settings)
|
ui.button("Speichern", on_click=save_admin_settings)
|
||||||
|
@ -3,5 +3,10 @@
|
|||||||
"admin_password": "8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92",
|
"admin_password": "8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92",
|
||||||
"port": "8090",
|
"port": "8090",
|
||||||
"secret": "ftgzuhjikg,mt5jn46uzer8sfi9okrmtzjhndfierko5zltjhdgise",
|
"secret": "ftgzuhjikg,mt5jn46uzer8sfi9okrmtzjhndfierko5zltjhdgise",
|
||||||
"holidays": [ "2024-01-01", "2024-12-25", "2025-01-01", "2025-05-01"]
|
"holidays": {
|
||||||
|
"2024-01-01": "Tag der Arbeit",
|
||||||
|
"2024-12-25": "1. Weihnachtsfeiertag",
|
||||||
|
"2025-01-01": "Neujahr",
|
||||||
|
"2025-05-01": "Tag der Arbeit"
|
||||||
|
}
|
||||||
}
|
}
|
2
users.py
2
users.py
@ -297,7 +297,7 @@ class user:
|
|||||||
|
|
||||||
# Fertage prüfen
|
# Fertage prüfen
|
||||||
settings = load_adminsettings()
|
settings = load_adminsettings()
|
||||||
holidays = settings["holidays"]
|
holidays = list(settings["holidays"])
|
||||||
|
|
||||||
today_dt = datetime.datetime(int(year), int(month), int(day))
|
today_dt = datetime.datetime(int(year), int(month), int(day))
|
||||||
check_date_list = [ ]
|
check_date_list = [ ]
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
1746090493
|
|
||||||
1746090500
|
|
Loading…
x
Reference in New Issue
Block a user