Merge branch 'docker'
This commit is contained in:
commit
4515f3e29a
@ -17,7 +17,6 @@ ENV LANGUAGE de_DE:de
|
||||
ENV LC_ALL de_DE.UTF-8
|
||||
|
||||
COPY main.py /app/main.py
|
||||
COPY favicon.svg /app/favicon.svg
|
||||
COPY lib /app/lib/
|
||||
EXPOSE 8090
|
||||
ENTRYPOINT ["/.venv/bin/python", "/app/main.py"]
|
||||
|
@ -4,8 +4,11 @@ services:
|
||||
restart: always
|
||||
ports:
|
||||
- 8090:8090
|
||||
environment:
|
||||
- PYTHONUNBUFFERED=1
|
||||
volumes:
|
||||
#- /home/alexander/Dokumente/Python/Zeiterfassung:/app
|
||||
#- /home/alexander/Dokumente/Python/Zeiterfassung/lib:/app/lib
|
||||
#- /home/alexander/Dokumente/Python/Zeiterfassung/main.py:/app/main.py
|
||||
- /home/alexander/Dokumente/Python/Zeiterfassung/docker-work/users:/users
|
||||
- /home/alexander/Dokumente/Python/Zeiterfassung/docker-work/backup:/backup
|
||||
- /home/alexander/Dokumente/Python/Zeiterfassung/docker-work/settings:/settings
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
@ -170,7 +170,6 @@ def homepage():
|
||||
note_dict["user"] = daynote.value
|
||||
nonlocal last_selection
|
||||
last_selection = day_selector.value
|
||||
print(f"Last selection from save: {last_selection}")
|
||||
if day_selector.value == 0:
|
||||
day_to_write = today.day
|
||||
else:
|
||||
|
24
lib/users.py
24
lib/users.py
@ -136,10 +136,15 @@ class user:
|
||||
outputfile.write(json_dict)
|
||||
|
||||
pathcheck = self.userfolder
|
||||
if not is_docker():
|
||||
pathcheck = pathcheck.removeprefix(os.path.join(scriptpath, userfolder))
|
||||
|
||||
if pathcheck != self.username:
|
||||
os.rename(self.userfolder, os.path.join(scriptpath, userfolder, self.username))
|
||||
else:
|
||||
pathcheck = pathcheck.removeprefix("/users")
|
||||
if pathcheck != self.username:
|
||||
os.rename(self.userfolder, os.path.join(userfolder, self.username))
|
||||
|
||||
|
||||
def del_user(self):
|
||||
shutil.rmtree(self.userfolder)
|
||||
@ -304,10 +309,27 @@ class user:
|
||||
return { }
|
||||
|
||||
def write_notes(self, year, month, day, note_dict):
|
||||
try:
|
||||
with open(os.path.join(self.userfolder, f"{int(year)}-{int(month)}.json"), "r") as json_file:
|
||||
json_data = json.load(json_file)
|
||||
except FileNotFoundError:
|
||||
dict = {}
|
||||
dict["archived"] = 0
|
||||
dict["total_hours"] = 0
|
||||
dict["notes"] = { }
|
||||
|
||||
json_dict = json.dumps(dict, indent=4)
|
||||
with open(os.path.join(self.userfolder, f"{int(year)}-{int(month)}.json"), 'w') as json_file:
|
||||
json_file.write(json_dict)
|
||||
|
||||
json_data = dict
|
||||
|
||||
if len(note_dict) == 1:
|
||||
user_info = list(note_dict)[0]
|
||||
try:
|
||||
json_data["notes"]
|
||||
except KeyError:
|
||||
json_data["notes"] = { }
|
||||
json_data["notes"][str(day)] = { }
|
||||
json_data["notes"][str(day)][user_info] = note_dict[user_info]
|
||||
if json_data["notes"][str(day)][user_info] == "":
|
||||
|
6
main.py
6
main.py
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# Zeiterfassung
|
||||
import os.path
|
||||
|
||||
from lib.web_ui import *
|
||||
from lib.admin import *
|
||||
@ -172,8 +173,11 @@ def main():
|
||||
</svg
|
||||
>
|
||||
'''
|
||||
if not os.path.exists(os.path.join(scriptpath, "favicon.svg")):
|
||||
with open(os.path.join(scriptpath, "favicon.svg"), 'w') as favicon_file:
|
||||
favicon_file.write(favicon)
|
||||
|
||||
ui.run(favicon=favicon, port=port, storage_secret=secret, language='de-DE', show_welcome_message=False)
|
||||
ui.run(favicon=os.path.join(scriptpath, "favicon.svg"), port=port, storage_secret=secret, language='de-DE', show_welcome_message=False)
|
||||
|
||||
if __name__ in ("__main__", "__mp_main__"):
|
||||
parser = argparse.ArgumentParser(description=f'{app_title} {app_version}')
|
||||
|
Loading…
x
Reference in New Issue
Block a user