Notizfunktion für Administrator hinzugefügt
Anzeige für Benutzernotizen im Administrationsbereich
This commit is contained in:
parent
d2bbf5b761
commit
7225cbe89c
81
admin.py
81
admin.py
@ -131,7 +131,7 @@ def page_admin():
|
|||||||
current_user = user(time_user.value)
|
current_user = user(time_user.value)
|
||||||
# Archivstatus
|
# Archivstatus
|
||||||
|
|
||||||
with ui.grid(columns='auto auto 1fr 1fr 1fr 1fr') as table_grid:
|
with ui.grid(columns='auto auto auto 1fr 1fr 1fr 1fr') as table_grid:
|
||||||
if int(select_month.value) > 1:
|
if int(select_month.value) > 1:
|
||||||
archive_status = current_user.get_archive_status(int(select_year.value),
|
archive_status = current_user.get_archive_status(int(select_year.value),
|
||||||
int(select_month.value))
|
int(select_month.value))
|
||||||
@ -169,6 +169,7 @@ def page_admin():
|
|||||||
# Überschriften
|
# Überschriften
|
||||||
ui.markdown("**Datum**")
|
ui.markdown("**Datum**")
|
||||||
ui.markdown("**Buchungen**")
|
ui.markdown("**Buchungen**")
|
||||||
|
ui.space()
|
||||||
ui.markdown("**Ist**")
|
ui.markdown("**Ist**")
|
||||||
ui.markdown("**Soll**")
|
ui.markdown("**Soll**")
|
||||||
ui.markdown("**Saldo**")
|
ui.markdown("**Saldo**")
|
||||||
@ -304,6 +305,22 @@ Dies kann nicht rückgängig gemacht werden!''')
|
|||||||
if archive_status:
|
if archive_status:
|
||||||
timestamp_button.disable()
|
timestamp_button.disable()
|
||||||
|
|
||||||
|
# Notizen anzeigen
|
||||||
|
days_notes = current_user.get_day_notes(select_year.value, select_month.value, day)
|
||||||
|
if days_notes != { }:
|
||||||
|
with ui.icon('o_description').classes('text-2xl'):
|
||||||
|
with ui.tooltip():
|
||||||
|
with ui.grid(columns='auto auto'):
|
||||||
|
for username, text in days_notes.items():
|
||||||
|
admins_name = load_adminsettings()["admin_user"]
|
||||||
|
if username == admins_name:
|
||||||
|
ui.markdown('Administrator:')
|
||||||
|
else:
|
||||||
|
ui.markdown(user(username).fullname)
|
||||||
|
ui.markdown(text)
|
||||||
|
else:
|
||||||
|
ui.space()
|
||||||
|
|
||||||
# Arbeitszeit Ist bestimmen
|
# Arbeitszeit Ist bestimmen
|
||||||
|
|
||||||
timestamps_of_this_day = []
|
timestamps_of_this_day = []
|
||||||
@ -477,12 +494,60 @@ Dies kann nicht rückgängig gemacht werden!''')
|
|||||||
dialog.open()
|
dialog.open()
|
||||||
dialog.move(calendar_card)
|
dialog.move(calendar_card)
|
||||||
|
|
||||||
|
def edit_notes(day):
|
||||||
|
notes = current_user.get_day_notes(select_year.value, select_month.value, day)
|
||||||
|
def del_note_entry(user):
|
||||||
|
del(notes[user])
|
||||||
|
username_labels[user].delete()
|
||||||
|
note_labels[user].delete()
|
||||||
|
del_buttons[user].delete()
|
||||||
|
|
||||||
|
def save_notes():
|
||||||
|
if not note_labels[admin_settings["admin_user"]].is_deleted:
|
||||||
|
notes[admin_settings["admin_user"]] = note_labels[admin_settings["admin_user"]].value
|
||||||
|
current_user.write_notes(select_year.value, select_month.value, day, notes)
|
||||||
|
timetable.refresh()
|
||||||
|
dialog.close()
|
||||||
|
|
||||||
|
with ui.dialog() as dialog, ui.card():
|
||||||
|
# Notizen
|
||||||
|
username_labels = { }
|
||||||
|
note_labels = { }
|
||||||
|
del_buttons = { }
|
||||||
|
|
||||||
|
ui.markdown(f'**Notizen für {day}.{current_month}.{current_year}**')
|
||||||
|
with ui.grid(columns='auto auto auto'):
|
||||||
|
admin_settings = load_adminsettings()
|
||||||
|
# Beschreibungsfeld für Admin
|
||||||
|
username_labels[admin_settings["admin_user"]] = ui.markdown("Administrator:")
|
||||||
|
# Textarea für Admin
|
||||||
|
note_labels[admin_settings["admin_user"]] = ui.textarea()
|
||||||
|
|
||||||
|
for name, text in notes.items():
|
||||||
|
if name != admin_settings["admin_user"]:
|
||||||
|
user_obj = user(name)
|
||||||
|
noteuser = user_obj.username
|
||||||
|
username_labels[noteuser] = ui.markdown(user_obj.fullname)
|
||||||
|
note_labels[noteuser] = ui.markdown(text)
|
||||||
|
else:
|
||||||
|
noteuser = admin_settings["admin_user"]
|
||||||
|
note_labels[noteuser].set_value(text)
|
||||||
|
del_buttons[noteuser] = ui.button(icon='remove', on_click=lambda user=noteuser: del_note_entry(user))
|
||||||
|
|
||||||
|
with ui.row():
|
||||||
|
ui.button("OK", on_click=save_notes)
|
||||||
|
ui.button("Abbrechen", on_click=dialog.close)
|
||||||
|
dialog.open()
|
||||||
|
dialog.move(calendar_card)
|
||||||
|
|
||||||
with ui.button(icon='menu'):
|
with ui.button(icon='menu'):
|
||||||
with ui.menu() as menu:
|
with ui.menu() as menu:
|
||||||
menu_item = ui.menu_item("Zeiteintrag hinzufügen", lambda day=day: add_entry(day))
|
menu_item = ui.menu_item("Zeiteintrag hinzufügen", lambda day=day: add_entry(day))
|
||||||
if archive_status:
|
if archive_status:
|
||||||
menu_item.disable()
|
menu_item.disable()
|
||||||
ui.separator()
|
ui.separator()
|
||||||
|
menu_item = ui.menu_item("Notizen bearbeiten", lambda day=day: edit_notes(day))
|
||||||
|
ui.separator()
|
||||||
for i in list(absence_entries):
|
for i in list(absence_entries):
|
||||||
menu_item = ui.menu_item(f"{absence_entries[i]['name']} eintragen", lambda absence_type=i, day=day: add_absence(absence_type, day))
|
menu_item = ui.menu_item(f"{absence_entries[i]['name']} eintragen", lambda absence_type=i, day=day: add_absence(absence_type, day))
|
||||||
if archive_status:
|
if archive_status:
|
||||||
@ -493,12 +558,12 @@ Dies kann nicht rückgängig gemacht werden!''')
|
|||||||
#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 Gesamtsaldo
|
#4x leer und dann Gesamtsaldo
|
||||||
ui.space().classes('col-span-4')
|
ui.space().classes('col-span-5')
|
||||||
ui.markdown(f"{convert_seconds_to_hours(general_saldo)}").classes('text-right')
|
ui.markdown(f"{convert_seconds_to_hours(general_saldo)}").classes('text-right')
|
||||||
ui.markdown("Stunden aus Vormonat").classes('col-span-4 text-right')
|
ui.markdown("Stunden aus Vormonat").classes('col-span-5 text-right')
|
||||||
last_months_overtime = current_user.get_last_months_overtime(select_year.value, select_month.value)
|
last_months_overtime = current_user.get_last_months_overtime(select_year.value, select_month.value)
|
||||||
ui.markdown(f"{convert_seconds_to_hours(last_months_overtime)}").classes('text-right')
|
ui.markdown(f"{convert_seconds_to_hours(last_months_overtime)}").classes('text-right')
|
||||||
ui.markdown("Gesamtsaldo").classes('col-span-4 text-right')
|
ui.markdown("Gesamtsaldo").classes('col-span-5 text-right')
|
||||||
ui.markdown(f"**<ins>{convert_seconds_to_hours(general_saldo + last_months_overtime)}</ins>**").classes('text-right')
|
ui.markdown(f"**<ins>{convert_seconds_to_hours(general_saldo + last_months_overtime)}</ins>**").classes('text-right')
|
||||||
|
|
||||||
table_grid.move(calendar_card)
|
table_grid.move(calendar_card)
|
||||||
@ -507,13 +572,14 @@ Dies kann nicht rückgängig gemacht werden!''')
|
|||||||
|
|
||||||
def clear_card():
|
def clear_card():
|
||||||
calendar_card.clear()
|
calendar_card.clear()
|
||||||
|
button_update.delete()
|
||||||
update_month_and_year()
|
update_month_and_year()
|
||||||
current_user = user(time_user.value)
|
current_user = user(time_user.value)
|
||||||
month_header.set_content(f"###Buchungen für **{current_user.fullname}** für **{calendar.month_name[int(select_month.value)]} {select_year.value}**")
|
month_header.set_content(f"###Buchungen für **{current_user.fullname}** für **{calendar.month_name[int(select_month.value)]} {select_year.value}**")
|
||||||
|
|
||||||
button_update = ui.button("Aktualisieren", on_click=clear_card)
|
|
||||||
button_update.move(timetable_header)
|
|
||||||
timetable()
|
timetable()
|
||||||
|
button_update = ui.button("Aktualisieren", on_click=timetable.refresh)
|
||||||
|
button_update.move(timetable_header)
|
||||||
|
|
||||||
with ui.tab_panel(settings):
|
with ui.tab_panel(settings):
|
||||||
with ui.card():
|
with ui.card():
|
||||||
@ -540,6 +606,7 @@ Dies kann nicht rückgängig gemacht werden!''')
|
|||||||
ui.notify("Einstellungen gespeichert")
|
ui.notify("Einstellungen gespeichert")
|
||||||
timetable.refresh()
|
timetable.refresh()
|
||||||
|
|
||||||
|
|
||||||
ui.markdown("Benutzername des Adminstrators")
|
ui.markdown("Benutzername des Adminstrators")
|
||||||
admin_user = ui.input()
|
admin_user = ui.input()
|
||||||
admin_user.value = data["admin_user"]
|
admin_user.value = data["admin_user"]
|
||||||
@ -933,7 +1000,7 @@ Dies kann nicht rückgängig gemacht werden!''')
|
|||||||
def dialog_new_user():
|
def dialog_new_user():
|
||||||
def create_new_user():
|
def create_new_user():
|
||||||
if user_name_input.validate():
|
if user_name_input.validate():
|
||||||
print(user_name_input.value)
|
|
||||||
new_user(user_name_input.value)
|
new_user(user_name_input.value)
|
||||||
update_userlist()
|
update_userlist()
|
||||||
time_user.set_options(userlist)
|
time_user.set_options(userlist)
|
||||||
|
21
users.py
21
users.py
@ -262,6 +262,24 @@ class user:
|
|||||||
except:
|
except:
|
||||||
return { }
|
return { }
|
||||||
|
|
||||||
|
def get_day_notes(self, year, month, day):
|
||||||
|
try:
|
||||||
|
with open(f"{self.userfolder}/{int(year)}-{int(month)}.json", "r") as json_file:
|
||||||
|
json_data = json.load(json_file)
|
||||||
|
day_note = json_data["notes"][str(day)]
|
||||||
|
return day_note
|
||||||
|
except:
|
||||||
|
return { }
|
||||||
|
|
||||||
|
def write_notes(self, year, month, day, note_dict):
|
||||||
|
with open(f"{self.userfolder}/{int(year)}-{int(month)}.json", "r") as json_file:
|
||||||
|
json_data = json.load(json_file)
|
||||||
|
json_data["notes"][str(day)] = note_dict
|
||||||
|
json_output = json.dumps(json_data, indent=4)
|
||||||
|
with open(f"{self.userfolder}/{int(year)}-{int(month)}.json", "w") as json_file:
|
||||||
|
json_file.write(json_output)
|
||||||
|
|
||||||
|
|
||||||
def update_absence(self, year, month, day, absence_type):
|
def update_absence(self, year, month, day, absence_type):
|
||||||
try:
|
try:
|
||||||
with open(f"{self.userfolder}/{int(year)}-{int(month)}.json", "r") as json_file:
|
with open(f"{self.userfolder}/{int(year)}-{int(month)}.json", "r") as json_file:
|
||||||
@ -375,9 +393,6 @@ class user:
|
|||||||
time_worked = todays_timestamps[i + 1] - todays_timestamps[i]
|
time_worked = todays_timestamps[i + 1] - todays_timestamps[i]
|
||||||
total_time += time_worked
|
total_time += time_worked
|
||||||
|
|
||||||
print(total_time)
|
|
||||||
print(in_time_stamp)
|
|
||||||
|
|
||||||
return [total_time, in_time_stamp]
|
return [total_time, in_time_stamp]
|
||||||
|
|
||||||
# Benutzer auflisten
|
# Benutzer auflisten
|
||||||
|
@ -4,5 +4,16 @@
|
|||||||
"absence": {
|
"absence": {
|
||||||
"14": "U",
|
"14": "U",
|
||||||
"2": "SO"
|
"2": "SO"
|
||||||
|
},
|
||||||
|
"notes": {
|
||||||
|
"5": {
|
||||||
|
"testuser1": "Jo, das ging echt ab.",
|
||||||
|
"admin": "Streik\n\nUnd anderes"
|
||||||
|
},
|
||||||
|
"4": {
|
||||||
|
"admin": "Testeintrag"
|
||||||
|
},
|
||||||
|
"2": {},
|
||||||
|
"1": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user