Routinen für Standardwerte eingefügt
This commit is contained in:
parent
5d684ee9ef
commit
f15ec8e809
11
admin.py
11
admin.py
@ -68,8 +68,10 @@ def page_admin():
|
|||||||
def update_user():
|
def update_user():
|
||||||
current_user = user(time_user.value)
|
current_user = user(time_user.value)
|
||||||
available_years = current_user.get_years()
|
available_years = current_user.get_years()
|
||||||
|
try:
|
||||||
select_year.clear()
|
select_year.clear()
|
||||||
select_year.set_options(available_years)
|
select_year.set_options(available_years)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
select_year.value = str(datetime.datetime.now().year)
|
select_year.value = str(datetime.datetime.now().year)
|
||||||
except:
|
except:
|
||||||
@ -78,11 +80,12 @@ def page_admin():
|
|||||||
select_month.value = datetime.datetime.now().month
|
select_month.value = datetime.datetime.now().month
|
||||||
except:
|
except:
|
||||||
select_month.value = list(available_months)[0]
|
select_month.value = list(available_months)[0]
|
||||||
|
except NameError:
|
||||||
|
pass
|
||||||
|
|
||||||
userlist = list_users()
|
userlist = list_users()
|
||||||
ui.markdown("Benutzer:")
|
ui.markdown("Benutzer:")
|
||||||
|
|
||||||
|
|
||||||
time_user = ui.select(options=userlist, on_change=update_user)
|
time_user = ui.select(options=userlist, on_change=update_user)
|
||||||
time_user.value = userlist[0]
|
time_user.value = userlist[0]
|
||||||
user_to_select_for_start = userlist[0]
|
user_to_select_for_start = userlist[0]
|
||||||
@ -148,11 +151,13 @@ def page_admin():
|
|||||||
ui.button("Nein", on_click=dialog.close)
|
ui.button("Nein", on_click=dialog.close)
|
||||||
dialog.open()
|
dialog.open()
|
||||||
|
|
||||||
if archive_status:
|
if archive_status == True:
|
||||||
with ui.row().classes('text-right col-span-6 justify-center'):
|
with ui.row().classes('text-right col-span-6 justify-center'):
|
||||||
ui.button("Archiviert", on_click=revoke_archive_status).classes('bg-transparent text-black')
|
ui.button("Archiviert", on_click=revoke_archive_status).classes('bg-transparent text-black')
|
||||||
ui.separator()
|
ui.separator()
|
||||||
calendar_card.classes('bg-yellow')
|
calendar_card.classes('bg-yellow')
|
||||||
|
else:
|
||||||
|
calendar_card.classes('bg-white')
|
||||||
# Überschriften
|
# Überschriften
|
||||||
ui.markdown("**Datum**")
|
ui.markdown("**Datum**")
|
||||||
ui.markdown("**Buchungen**")
|
ui.markdown("**Buchungen**")
|
||||||
@ -330,6 +335,8 @@ def page_admin():
|
|||||||
hours_to_work = int(current_user.get_day_workhours(select_year.value, select_month.value, day))
|
hours_to_work = int(current_user.get_day_workhours(select_year.value, select_month.value, day))
|
||||||
if hours_to_work < 0:
|
if hours_to_work < 0:
|
||||||
ui.space()
|
ui.space()
|
||||||
|
day_type.content="Kein Arbeitsverhältnis"
|
||||||
|
day_type.set_visibility(True)
|
||||||
else:
|
else:
|
||||||
ui.markdown(f"{convert_seconds_to_hours(int(hours_to_work) * 3600)}").classes('text-right')
|
ui.markdown(f"{convert_seconds_to_hours(int(hours_to_work) * 3600)}").classes('text-right')
|
||||||
if int(hours_to_work) == 0:
|
if int(hours_to_work) == 0:
|
||||||
|
@ -20,6 +20,24 @@ photofilename = "photo.jpg"
|
|||||||
status_in = "eingestempelt"
|
status_in = "eingestempelt"
|
||||||
status_out = "ausgestempelt"
|
status_out = "ausgestempelt"
|
||||||
|
|
||||||
|
# Standardadmin Settings:
|
||||||
|
|
||||||
|
standard_adminsettings = { "admin_user": "admin",
|
||||||
|
"admin_password": "8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918",
|
||||||
|
"port": "8090",
|
||||||
|
"secret": "ftgzuhjikg,mt5jn46uzer8sfi9okrmtzjhndfierko5zltjhdgise",
|
||||||
|
"holidays": { }
|
||||||
|
}
|
||||||
|
|
||||||
|
# Standard User Settings:
|
||||||
|
|
||||||
|
standard_usersettings = {
|
||||||
|
"username": "default",
|
||||||
|
"fullname": "Standardbenutzer",
|
||||||
|
"password": "37a8eec1ce19687d132fe29051dca629d164e2c4958ba141d5f4133a33f0688f",
|
||||||
|
"workhours": { }
|
||||||
|
}
|
||||||
|
|
||||||
# Abesenheiten
|
# Abesenheiten
|
||||||
|
|
||||||
absence_entries = {"U": { "name": "Urlaub",
|
absence_entries = {"U": { "name": "Urlaub",
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
{
|
{
|
||||||
"admin_user": "admin",
|
"admin_user": "admin",
|
||||||
"admin_password": "8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92",
|
"admin_password": "8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918",
|
||||||
"port": "8090",
|
"port": "8090",
|
||||||
"secret": "ftgzuhjikg,mt5jn46uzer8sfi9okrmtzjhndfierko5zltjhdgise",
|
"secret": "ftgzuhjikg,mt5jn46uzer8sfi9okrmtzjhndfierko5zltjhdgise",
|
||||||
"holidays": {
|
"holidays": {}
|
||||||
"2024-05-01": "Tag der Arbeit",
|
|
||||||
"2024-12-25": "1. Weihnachtsfeiertag",
|
|
||||||
"2025-01-01": "Neujahr",
|
|
||||||
"2025-05-01": "Tag der Arbeit"
|
|
||||||
}
|
|
||||||
}
|
}
|
12
settings.json_bak
Normal file
12
settings.json_bak
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"admin_user": "admin",
|
||||||
|
"admin_password": "8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92",
|
||||||
|
"port": "8090",
|
||||||
|
"secret": "ftgzuhjikg,mt5jn46uzer8sfi9okrmtzjhndfierko5zltjhdgise",
|
||||||
|
"holidays": {
|
||||||
|
"2024-05-01": "Tag der Arbeit",
|
||||||
|
"2024-12-25": "1. Weihnachtsfeiertag",
|
||||||
|
"2025-01-01": "Neujahr",
|
||||||
|
"2025-05-01": "Tag der Arbeit"
|
||||||
|
}
|
||||||
|
}
|
29
users.py
29
users.py
@ -9,7 +9,7 @@ import json
|
|||||||
import shutil
|
import shutil
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from definitions import userfolder, scriptpath, usersettingsfilename, photofilename, status_in, status_out
|
from definitions import userfolder, scriptpath, usersettingsfilename, photofilename, status_in, status_out, standard_adminsettings, standard_usersettings
|
||||||
|
|
||||||
# Benutzerklasse
|
# Benutzerklasse
|
||||||
|
|
||||||
@ -384,17 +384,40 @@ def list_users():
|
|||||||
os.makedirs(userfolder)
|
os.makedirs(userfolder)
|
||||||
|
|
||||||
users = [d for d in os.listdir(userfolder) if os.path.isdir(os.path.join(userfolder, d))]
|
users = [d for d in os.listdir(userfolder) if os.path.isdir(os.path.join(userfolder, d))]
|
||||||
|
if len(users) == 0:
|
||||||
|
new_user("default")
|
||||||
|
users = [d for d in os.listdir(userfolder) if os.path.isdir(os.path.join(userfolder, d))]
|
||||||
|
|
||||||
users.sort()
|
users.sort()
|
||||||
return users
|
return users
|
||||||
|
|
||||||
|
def new_user(username):
|
||||||
|
if not os.path.exists(userfolder):
|
||||||
|
os.makedirs(userfolder)
|
||||||
|
if not os.path.exists(f"{userfolder}/{username}"):
|
||||||
|
os.makedirs(f"{userfolder}/{username}")
|
||||||
|
start_date_dt = datetime.datetime.now()
|
||||||
|
start_date = start_date_dt.strftime("%Y-%m-%d")
|
||||||
|
settings_to_write = standard_usersettings
|
||||||
|
settings_to_write["workhours"][start_date] = { }
|
||||||
|
for i in range(1, 8):
|
||||||
|
settings_to_write["workhours"][start_date][str(i)] = 0
|
||||||
|
settings_to_write["workhours"][start_date]["vacation"] = 0
|
||||||
|
with open(f"{userfolder}/{username}/{usersettingsfilename}", 'w') as json_file:
|
||||||
|
json_dict = json.dumps(standard_usersettings, indent=4)
|
||||||
|
json_file.write(json_dict)
|
||||||
|
|
||||||
# Admineinstellungen auslesen
|
# Admineinstellungen auslesen
|
||||||
def load_adminsettings():
|
def load_adminsettings():
|
||||||
# Settingsdatei einlesen
|
# Settingsdatei einlesen
|
||||||
|
settings_filename = f"{scriptpath}/{usersettingsfilename}"
|
||||||
|
if not os.path.exists(settings_filename):
|
||||||
|
with open(settings_filename, 'w') as json_file:
|
||||||
|
json_dict = json.dumps(standard_adminsettings, indent=4)
|
||||||
|
json_file.write(json_dict)
|
||||||
try:
|
try:
|
||||||
with open(f"{scriptpath}/{usersettingsfilename}") as json_file:
|
with open(settings_filename) as json_file:
|
||||||
data = json.load(json_file)
|
data = json.load(json_file)
|
||||||
json_file.close()
|
|
||||||
return data
|
return data
|
||||||
except:
|
except:
|
||||||
return -1
|
return -1
|
Loading…
x
Reference in New Issue
Block a user