Vorbereitung Monatsarchivierung
This commit is contained in:
parent
1cbfe0cfa4
commit
cb757ac6b6
27
users.py
27
users.py
@ -35,14 +35,13 @@ class user:
|
|||||||
def get_stamp_file(self):
|
def get_stamp_file(self):
|
||||||
year = str(datetime.datetime.now().year)
|
year = str(datetime.datetime.now().year)
|
||||||
month = str(datetime.datetime.now().month)
|
month = str(datetime.datetime.now().month)
|
||||||
completepath = f"{self.userfolder}/{year}-{month}.txt"
|
completepath = f"{self.userfolder}/{year}-{month}"
|
||||||
return completepath
|
return completepath
|
||||||
|
|
||||||
def timestamp(self, stamptime=-1):
|
def timestamp(self, stamptime=-1):
|
||||||
filename = self.get_stamp_file()
|
filename = f"{self.get_stamp_file()}.txt"
|
||||||
if stamptime == -1:
|
if stamptime == -1:
|
||||||
stamptime = time.time()
|
stamptime = time.time()
|
||||||
print(stamptime)
|
|
||||||
timestamp = int(stamptime)
|
timestamp = int(stamptime)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -57,10 +56,24 @@ class user:
|
|||||||
os.makedirs(folder_path, exist_ok=True)
|
os.makedirs(folder_path, exist_ok=True)
|
||||||
self.timestamp()
|
self.timestamp()
|
||||||
|
|
||||||
|
# Nach zugehörigem JSON-File suchen und bei Bedarf anlegen
|
||||||
|
try:
|
||||||
|
json_filename = f"{self.get_stamp_file()}.json"
|
||||||
|
with open(json_filename, 'r') as json_file:
|
||||||
|
pass
|
||||||
|
except:
|
||||||
|
dict = { }
|
||||||
|
dict["archived"] = 0
|
||||||
|
dict["total_hours"] = 0
|
||||||
|
|
||||||
|
json_dict = json.dumps(dict, indent=4)
|
||||||
|
with open(json_filename, 'w') as json_file:
|
||||||
|
json_file.write(json_dict)
|
||||||
|
|
||||||
def stamp_status(self):
|
def stamp_status(self):
|
||||||
try:
|
try:
|
||||||
# Öffne die Datei im Lese-Modus ('r')
|
# Öffne die Datei im Lese-Modus ('r')
|
||||||
with open(self.get_stamp_file(), 'r') as file:
|
with open(f"{self.get_stamp_file()}.txt", 'r') as file:
|
||||||
# Zähle die Zeilen
|
# Zähle die Zeilen
|
||||||
lines = file.readlines()
|
lines = file.readlines()
|
||||||
file.close()
|
file.close()
|
||||||
@ -75,7 +88,7 @@ class user:
|
|||||||
|
|
||||||
def last_2_timestmaps(self):
|
def last_2_timestmaps(self):
|
||||||
|
|
||||||
with open(self.get_stamp_file(), 'r') as file:
|
with open(f"{self.get_stamp_file()}.txt", 'r') as file:
|
||||||
lines = file.readlines()
|
lines = file.readlines()
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
@ -145,6 +158,10 @@ class user:
|
|||||||
with open(f"{self.userfolder}/{year}-{month}.txt", "w") as file:
|
with open(f"{self.userfolder}/{year}-{month}.txt", "w") as file:
|
||||||
file.write(''.join(timestamps))
|
file.write(''.join(timestamps))
|
||||||
|
|
||||||
|
def archive_hours(self, year, month):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Benutzer auflisten
|
# Benutzer auflisten
|
||||||
def list_users():
|
def list_users():
|
||||||
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))]
|
||||||
|
4
users/testuser1/2025-3.json
Normal file
4
users/testuser1/2025-3.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"archived": 1,
|
||||||
|
"total_hours": 28
|
||||||
|
}
|
@ -1,10 +1,11 @@
|
|||||||
|
1743562800
|
||||||
|
1743566400
|
||||||
|
1743584340
|
||||||
|
1743606000
|
||||||
1743652800
|
1743652800
|
||||||
|
1743660240
|
||||||
1743667140
|
1743667140
|
||||||
1743923400
|
1743685200
|
||||||
1743965819
|
|
||||||
1743965909
|
|
||||||
1743966045
|
|
||||||
1743967800
|
|
||||||
1744889948
|
1744889948
|
||||||
1744889966
|
1744889966
|
||||||
1744989797
|
1744989797
|
||||||
@ -33,5 +34,3 @@
|
|||||||
1745391056
|
1745391056
|
||||||
1745391058
|
1745391058
|
||||||
1745391059
|
1745391059
|
||||||
1743660240
|
|
||||||
1743685200
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"password": "123456789",
|
"password": "123456789",
|
||||||
"workhours": {
|
"workhours": {
|
||||||
"2024-04-01": {
|
"2024-04-01": {
|
||||||
"1": "8",
|
"1": "4",
|
||||||
"2": "8",
|
"2": "8",
|
||||||
"3": "8",
|
"3": "8",
|
||||||
"4": "8",
|
"4": "8",
|
||||||
|
4
users/testuser10/2025-4.json
Normal file
4
users/testuser10/2025-4.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"archived": 0,
|
||||||
|
"total_hours": 0
|
||||||
|
}
|
14
users/testuser10/2025-4.txt
Normal file
14
users/testuser10/2025-4.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
1744989835
|
||||||
|
1744989837
|
||||||
|
1744989913
|
||||||
|
1744989917
|
||||||
|
1744991287
|
||||||
|
1744991291
|
||||||
|
1744991475
|
||||||
|
1744991478
|
||||||
|
1744991773
|
||||||
|
1744991776
|
||||||
|
1744991910
|
||||||
|
1744991912
|
||||||
|
1745411021
|
||||||
|
1745411025
|
Before Width: | Height: | Size: 550 KiB After Width: | Height: | Size: 550 KiB |
17
users/testuser10/settings.json
Normal file
17
users/testuser10/settings.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"username": "testuser10",
|
||||||
|
"fullname": "Diego Dieci",
|
||||||
|
"password": "123456789",
|
||||||
|
"workhours": {
|
||||||
|
"2024-04-01": {
|
||||||
|
"1": "1",
|
||||||
|
"2": "2",
|
||||||
|
"3": "3",
|
||||||
|
"4": "4",
|
||||||
|
"5": "5",
|
||||||
|
"6": "6",
|
||||||
|
"7": "7",
|
||||||
|
"vacation": "30"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,24 +4,14 @@
|
|||||||
"password": "123456789",
|
"password": "123456789",
|
||||||
"workhours": {
|
"workhours": {
|
||||||
"2024-04-01": {
|
"2024-04-01": {
|
||||||
"1": "0",
|
"1": "4",
|
||||||
"2": "8",
|
"2": "4",
|
||||||
"3": "8",
|
"3": "4",
|
||||||
"4": "8",
|
"4": "8",
|
||||||
"5": "8",
|
"5": "8",
|
||||||
"6": "8",
|
"6": "0",
|
||||||
"7": "0",
|
"7": "0",
|
||||||
"vacation": "30"
|
"vacation": "30"
|
||||||
},
|
|
||||||
"2024-04-07": {
|
|
||||||
"1": "0",
|
|
||||||
"2": "6",
|
|
||||||
"3": "6",
|
|
||||||
"4": "6",
|
|
||||||
"5": "8",
|
|
||||||
"6": "6",
|
|
||||||
"7": "0",
|
|
||||||
"vacation": "28"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +0,0 @@
|
|||||||
1743966330
|
|
||||||
1743966416
|
|
||||||
1744989832
|
|
||||||
1744989834
|
|
||||||
1744989905
|
|
||||||
1744989907
|
|
||||||
1744989915
|
|
||||||
1744989916
|
|
||||||
1744991290
|
|
||||||
1744991291
|
|
||||||
1745004502
|
|
||||||
1745004504
|
|
@ -1,37 +0,0 @@
|
|||||||
{
|
|
||||||
"username": "testuser5",
|
|
||||||
"fullname": "Peter Pan",
|
|
||||||
"password": "123456789",
|
|
||||||
"workhours": {
|
|
||||||
"2025-04-01": {
|
|
||||||
"1": "0",
|
|
||||||
"2": "8",
|
|
||||||
"3": "8",
|
|
||||||
"4": "8",
|
|
||||||
"5": "8",
|
|
||||||
"6": "8",
|
|
||||||
"7": "0",
|
|
||||||
"vacation": "30"
|
|
||||||
},
|
|
||||||
"2025-04-07": {
|
|
||||||
"1": "5",
|
|
||||||
"2": "6",
|
|
||||||
"3": "6",
|
|
||||||
"4": "6",
|
|
||||||
"5": "8",
|
|
||||||
"6": "6",
|
|
||||||
"7": "0",
|
|
||||||
"vacation": "28"
|
|
||||||
},
|
|
||||||
"2025-03-16": {
|
|
||||||
"1": 0,
|
|
||||||
"2": 0,
|
|
||||||
"3": 0,
|
|
||||||
"4": 0,
|
|
||||||
"5": 0,
|
|
||||||
"6": 0,
|
|
||||||
"7": 0,
|
|
||||||
"vacation": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
53
web_ui.py
53
web_ui.py
@ -20,6 +20,10 @@ class pageheader:
|
|||||||
ui.markdown(f"##{app_title} {app_version}")
|
ui.markdown(f"##{app_title} {app_version}")
|
||||||
ui.markdown(f"###{self.heading}")
|
ui.markdown(f"###{self.heading}")
|
||||||
|
|
||||||
|
class ValueBinder:
|
||||||
|
def __init__(self):
|
||||||
|
self.value_to_bind = ""
|
||||||
|
|
||||||
def cookie_hash(user, password):
|
def cookie_hash(user, password):
|
||||||
return hashlib.sha256(b"{user}{app.storage.user['id']}{password}").hexdigest()
|
return hashlib.sha256(b"{user}{app.storage.user['id']}{password}").hexdigest()
|
||||||
|
|
||||||
@ -125,21 +129,25 @@ def page_admin():
|
|||||||
with ui.card():
|
with ui.card():
|
||||||
|
|
||||||
with ui.row() as timetable_header:
|
with ui.row() as timetable_header:
|
||||||
|
year_binder = ValueBinder()
|
||||||
|
month_binder = ValueBinder()
|
||||||
|
|
||||||
def update_months():
|
def update_months():
|
||||||
|
try:
|
||||||
current_user = user(time_user.value)
|
current_user = user(time_user.value)
|
||||||
available_months = current_user.get_months(select_year.value)
|
available_months = current_user.get_months(year_binder.value_to_bind)
|
||||||
|
available_months_dict = {}
|
||||||
available_months_dict = {}
|
for element in available_months:
|
||||||
for element in available_months:
|
available_months_dict[element] = calendar.month_name[int(element)]
|
||||||
available_months_dict[element] = calendar.month_name[int(element)]
|
select_month.clear()
|
||||||
select_month.clear()
|
select_month.set_options(available_months_dict)
|
||||||
select_month.set_options(available_months_dict)
|
select_month.value = list(available_months)[0]
|
||||||
select_month.value = list(available_months)[0]
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
userlist = list_users()
|
userlist = list_users()
|
||||||
ui.markdown("Benutzer:")
|
ui.markdown("Benutzer:")
|
||||||
time_user = ui.select(options=userlist)
|
time_user = ui.select(options=userlist, on_change=update_months)
|
||||||
|
|
||||||
time_user.value = userlist[0]
|
time_user.value = userlist[0]
|
||||||
current_year = datetime.datetime.now().year
|
current_year = datetime.datetime.now().year
|
||||||
@ -153,9 +161,9 @@ def page_admin():
|
|||||||
for element in available_months:
|
for element in available_months:
|
||||||
available_months_dict[element] = calendar.month_name[int(element)]
|
available_months_dict[element] = calendar.month_name[int(element)]
|
||||||
|
|
||||||
select_month = ui.select(options=available_months_dict)
|
select_month = ui.select(options=available_months_dict).bind_value(month_binder, 'value_to_bind')
|
||||||
|
|
||||||
select_year = ui.select(options=available_years, on_change=update_months)
|
select_year = ui.select(options=available_years, on_change=update_months).bind_value(year_binder, 'value_to_bind')
|
||||||
try:
|
try:
|
||||||
select_year.value = str(current_year)
|
select_year.value = str(current_year)
|
||||||
except:
|
except:
|
||||||
@ -171,7 +179,7 @@ def page_admin():
|
|||||||
with ui.card() as calendar_card:
|
with ui.card() as calendar_card:
|
||||||
def update_month_and_year():
|
def update_month_and_year():
|
||||||
|
|
||||||
with ui.grid(columns=6) as table_grid:
|
with ui.grid(columns='auto auto 1fr 1fr 1fr 1fr') as table_grid:
|
||||||
ui.markdown("**Datum**")
|
ui.markdown("**Datum**")
|
||||||
ui.markdown("**Buchungen**")
|
ui.markdown("**Buchungen**")
|
||||||
ui.markdown("**Soll**")
|
ui.markdown("**Soll**")
|
||||||
@ -189,7 +197,7 @@ def page_admin():
|
|||||||
|
|
||||||
ui.markdown(f"{day_in_list.strftime('%a')}., {day}. {calendar.month_name[int(select_month.value)]}")
|
ui.markdown(f"{day_in_list.strftime('%a')}., {day}. {calendar.month_name[int(select_month.value)]}")
|
||||||
|
|
||||||
# ---> Hier die Schleife für die Buchungen
|
# Buchungen
|
||||||
|
|
||||||
with ui.row():
|
with ui.row():
|
||||||
counter = 0
|
counter = 0
|
||||||
@ -242,10 +250,10 @@ def page_admin():
|
|||||||
counter += 1
|
counter += 1
|
||||||
|
|
||||||
ui.button(actual_timestamp.strftime('%H:%M'), on_click=lambda t_stamp=i, day=day: edit_entry(t_stamp, day))
|
ui.button(actual_timestamp.strftime('%H:%M'), on_click=lambda t_stamp=i, day=day: edit_entry(t_stamp, day))
|
||||||
#if counter % 2 == 0:
|
if counter % 2 != 0:
|
||||||
# current_button.props('color=red')
|
ui.markdown("-")
|
||||||
#else:
|
else:
|
||||||
# current_button.props('color=green')
|
ui.markdown("|")
|
||||||
|
|
||||||
# Arbeitszeitsoll bestimmen
|
# Arbeitszeitsoll bestimmen
|
||||||
workhour_entries = list(current_user.workhours)
|
workhour_entries = list(current_user.workhours)
|
||||||
@ -323,9 +331,10 @@ def page_admin():
|
|||||||
update_month_and_year()
|
update_month_and_year()
|
||||||
add_dialog.close()
|
add_dialog.close()
|
||||||
ui.notify("Eintrag hinzugefügt")
|
ui.notify("Eintrag hinzugefügt")
|
||||||
|
with ui.grid(columns=3):
|
||||||
ui.button("Speichern", on_click=add_entry_save)
|
ui.button("Speichern", on_click=add_entry_save)
|
||||||
ui.button("Abbrechen", on_click=add_dialog.close)
|
ui.space()
|
||||||
|
ui.button("Abbrechen", on_click=add_dialog.close)
|
||||||
add_dialog.open()
|
add_dialog.open()
|
||||||
ui.button("Eintrag hinzufügen", on_click=lambda day=day: add_entry(day))
|
ui.button("Eintrag hinzufügen", on_click=lambda day=day: add_entry(day))
|
||||||
#4x leer und dann Gesamtsald
|
#4x leer und dann Gesamtsald
|
||||||
|
Loading…
x
Reference in New Issue
Block a user