tilføj mulighed for at ændre i detaljer om holdets time
This commit is contained in:
parent
c522bbfb4c
commit
24124ac837
81
klandr.py
81
klandr.py
|
@ -4,14 +4,20 @@ from dialog import Dialog
|
|||
import json
|
||||
from pymongo import MongoClient
|
||||
|
||||
|
||||
|
||||
|
||||
# Settings
|
||||
mongo = True
|
||||
file_storage = False
|
||||
d = Dialog(dialog="dialog")
|
||||
d.set_background_title("Klandr")
|
||||
|
||||
# Initialization
|
||||
holdets_time = None
|
||||
klandringer = None
|
||||
date = None
|
||||
|
||||
mongo = True
|
||||
file_storage = False
|
||||
|
||||
client = MongoClient()
|
||||
db = client["dat3holdetstime"]
|
||||
|
@ -32,6 +38,7 @@ if file_storage == True:
|
|||
|
||||
def menu_select_date():
|
||||
global klandringer
|
||||
global holdets_time
|
||||
global date
|
||||
date_entries = [()]
|
||||
if file_storage == True:
|
||||
|
@ -39,7 +46,7 @@ def menu_select_date():
|
|||
date_entries = [(k,"") for k in complete_klandringer]
|
||||
if mongo == True:
|
||||
for entry in collection.find():
|
||||
date_entries.append((entry["date"],""))
|
||||
date_entries.append((entry["date"],entry["time"] + " - " + entry["place"]))
|
||||
date_entries.append(("Ny","Opret en ny dato"))
|
||||
code, tag = d.menu("Vælg den dato du vil ændre",
|
||||
title="Vælg dato",
|
||||
|
@ -52,13 +59,15 @@ def menu_select_date():
|
|||
if file_storage == True:
|
||||
klandringer = complete_klandringer[date]
|
||||
if mongo == True:
|
||||
klandringer = collection.find({"date":date})[0]["data"]
|
||||
holdets_time = collection.find({"date":date})[0]
|
||||
klandringer = holdets_time["data"]
|
||||
menu_main()
|
||||
|
||||
def menu_main():
|
||||
code, tag = d.menu("Vælg punkt på dagsordenen",
|
||||
title="Hovedmenu",
|
||||
choices=[("Indledende", "Indledende bemærkninger"),
|
||||
choices=[("Timen", "Ændr i beskrivelsen af denne time"),
|
||||
("Indledende", "Indledende bemærkninger"),
|
||||
("Klandringer", "Så mange klandringer"),
|
||||
("Afsluttende", "Afsluttende bemærkninger")])
|
||||
|
||||
|
@ -69,6 +78,8 @@ def menu_main():
|
|||
menu_klandringer()
|
||||
elif tag == "Afsluttende":
|
||||
menu_afsluttende()
|
||||
elif tag == "Timen":
|
||||
menu_holdets_time()
|
||||
else:
|
||||
quit()
|
||||
|
||||
|
@ -201,12 +212,68 @@ def save():
|
|||
with open("klandringer.json","w") as jsonfile:
|
||||
jsonfile.write(json.dumps(complete_klandringer))
|
||||
if mongo == True:
|
||||
collection.update_one({"date":date},{"$set": {"data":klandringer}})
|
||||
#collection.update_one({"date":date},{"$set": {"data":klandringer}})
|
||||
collection.update_one({"date":date},{"$set": holdets_time})
|
||||
|
||||
###################
|
||||
# End klandringer #
|
||||
###################
|
||||
|
||||
######################
|
||||
# Start holdets time #
|
||||
######################
|
||||
|
||||
def menu_holdets_time():
|
||||
code, tag = d.menu("Hvad du vil ændre ved holdets time?",
|
||||
title="Holdets time",
|
||||
choices=[("Tid", "Ændre tidspunktet"),
|
||||
("Sted", "Ændre stedet"),
|
||||
("Undertitel", "Give en undertitel")])
|
||||
|
||||
if code == d.CANCEL:
|
||||
menu_main()
|
||||
elif code == d.OK:
|
||||
if tag == "Tid":
|
||||
change_time()
|
||||
elif tag == "Sted":
|
||||
change_place()
|
||||
elif tag == "Undertitel":
|
||||
change_subtitle()
|
||||
|
||||
menu_holdets_time()
|
||||
|
||||
def change_time():
|
||||
code, time = d.timebox("Vælg det tidspunkt hvor holdets time blev afholdt")
|
||||
if code == d.OK:
|
||||
strtime = str(time[0]).zfill(2) + ":" + str(time[1]).zfill(2)
|
||||
holdets_time["time"] = strtime
|
||||
save()
|
||||
|
||||
menu_holdets_time()
|
||||
|
||||
def change_place():
|
||||
code, string = d.inputbox("Vælg det sted hvor holdets time blev afholdt",0,0,
|
||||
holdets_time["place"])
|
||||
if code == d.OK:
|
||||
holdets_time["place"] = string
|
||||
save()
|
||||
|
||||
menu_holdets_time()
|
||||
|
||||
def change_subtitle():
|
||||
code, string = d.inputbox("Vælg en undertitel til denne holdets time",0,0,
|
||||
holdets_time["subtitle"])
|
||||
if code == d.OK:
|
||||
holdets_time["subtitle"] = string
|
||||
save()
|
||||
|
||||
menu_holdets_time()
|
||||
|
||||
####################
|
||||
# End holdets time #
|
||||
####################
|
||||
|
||||
|
||||
def new_date():
|
||||
code, pickdate = d.calendar("Vælg en dato")
|
||||
|
||||
|
@ -215,7 +282,7 @@ def new_date():
|
|||
if file_storage == True:
|
||||
complete_klandringer[date] = []
|
||||
if mongo == True:
|
||||
collection.insert({"date":date,"data":[]})
|
||||
collection.insert({"date":date,"time":"","place":"","subtitle":"","data":[]})
|
||||
return date
|
||||
else:
|
||||
menu_select_date()
|
||||
|
|
Loading…
Reference in New Issue
Block a user