Routinen für Standardwerte eingefügt
This commit is contained in:
parent
5d684ee9ef
commit
f15ec8e809
29
admin.py
29
admin.py
@ -68,21 +68,24 @@ def page_admin():
|
||||
def update_user():
|
||||
current_user = user(time_user.value)
|
||||
available_years = current_user.get_years()
|
||||
select_year.clear()
|
||||
select_year.set_options(available_years)
|
||||
try:
|
||||
select_year.value = str(datetime.datetime.now().year)
|
||||
except:
|
||||
select_year.value = list(available_years)[0]
|
||||
try:
|
||||
select_month.value = datetime.datetime.now().month
|
||||
except:
|
||||
select_month.value = list(available_months)[0]
|
||||
select_year.clear()
|
||||
select_year.set_options(available_years)
|
||||
|
||||
try:
|
||||
select_year.value = str(datetime.datetime.now().year)
|
||||
except:
|
||||
select_year.value = list(available_years)[0]
|
||||
try:
|
||||
select_month.value = datetime.datetime.now().month
|
||||
except:
|
||||
select_month.value = list(available_months)[0]
|
||||
except NameError:
|
||||
pass
|
||||
|
||||
userlist = list_users()
|
||||
ui.markdown("Benutzer:")
|
||||
|
||||
|
||||
time_user = ui.select(options=userlist, on_change=update_user)
|
||||
time_user.value = userlist[0]
|
||||
user_to_select_for_start = userlist[0]
|
||||
@ -148,11 +151,13 @@ def page_admin():
|
||||
ui.button("Nein", on_click=dialog.close)
|
||||
dialog.open()
|
||||
|
||||
if archive_status:
|
||||
if archive_status == True:
|
||||
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.separator()
|
||||
calendar_card.classes('bg-yellow')
|
||||
else:
|
||||
calendar_card.classes('bg-white')
|
||||
# Überschriften
|
||||
ui.markdown("**Datum**")
|
||||
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))
|
||||
if hours_to_work < 0:
|
||||
ui.space()
|
||||
day_type.content="Kein Arbeitsverhältnis"
|
||||
day_type.set_visibility(True)
|
||||
else:
|
||||
ui.markdown(f"{convert_seconds_to_hours(int(hours_to_work) * 3600)}").classes('text-right')
|
||||
if int(hours_to_work) == 0:
|
||||
|
@ -20,6 +20,24 @@ photofilename = "photo.jpg"
|
||||
status_in = "eingestempelt"
|
||||
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
|
||||
|
||||
absence_entries = {"U": { "name": "Urlaub",
|
||||
|
@ -1,12 +1,7 @@
|
||||
{
|
||||
"admin_user": "admin",
|
||||
"admin_password": "8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92",
|
||||
"admin_password": "8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918",
|
||||
"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"
|
||||
}
|
||||
"holidays": {}
|
||||
}
|
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"
|
||||
}
|
||||
}
|
31
users.py
31
users.py
@ -9,7 +9,7 @@ import json
|
||||
import shutil
|
||||
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
|
||||
|
||||
@ -384,17 +384,40 @@ def list_users():
|
||||
os.makedirs(userfolder)
|
||||
|
||||
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()
|
||||
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
|
||||
def load_adminsettings():
|
||||
# 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:
|
||||
with open(f"{scriptpath}/{usersettingsfilename}") as json_file:
|
||||
with open(settings_filename) as json_file:
|
||||
data = json.load(json_file)
|
||||
json_file.close()
|
||||
return data
|
||||
except:
|
||||
return -1
|
||||
return -1
|
||||
|
Loading…
x
Reference in New Issue
Block a user