plugin talks: ordinamento stanze
This commit is contained in:
parent
a359b518ed
commit
815dc2275f
2 changed files with 28 additions and 8 deletions
|
@ -100,6 +100,10 @@ def get_global_data():
|
||||||
data["startdate"] = datetime.datetime.now()
|
data["startdate"] = datetime.datetime.now()
|
||||||
if "rooms" not in data:
|
if "rooms" not in data:
|
||||||
data["rooms"] = {}
|
data["rooms"] = {}
|
||||||
|
if "names" not in data["rooms"]:
|
||||||
|
data["rooms"]["names"] = {}
|
||||||
|
if "order" not in data["rooms"]:
|
||||||
|
data["rooms"]["order"] = []
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,8 +173,8 @@ def get_talk_data(talkname):
|
||||||
if "room" not in data:
|
if "room" not in data:
|
||||||
logging.warn("Talk <{}> has no `room` field".format(talkname))
|
logging.warn("Talk <{}> has no `room` field".format(talkname))
|
||||||
else:
|
else:
|
||||||
if data["room"] in get_global_data()["rooms"]:
|
if data["room"] in get_global_data()["rooms"]["names"]:
|
||||||
data["room"] = get_global_data()["rooms"][data["room"]]
|
data["room"] = get_global_data()["rooms"]["names"][data["room"]]
|
||||||
if "time" not in data or "day" not in data:
|
if "time" not in data or "day" not in data:
|
||||||
logging.warn("Talk <{}> has no `time` or `day`".format(talkname))
|
logging.warn("Talk <{}> has no `time` or `day`".format(talkname))
|
||||||
if "time" in data:
|
if "time" in data:
|
||||||
|
@ -371,8 +375,22 @@ class TalkGridDirective(Directive):
|
||||||
rooms.add(r)
|
rooms.add(r)
|
||||||
else:
|
else:
|
||||||
rooms.add(t["room"])
|
rooms.add(t["room"])
|
||||||
# TODO: ordina in base a qualcosa nel meta.yaml globale
|
|
||||||
rooms = list(sorted(rooms))
|
def _room_sort_key(r):
|
||||||
|
order = get_global_data()["rooms"]["order"]
|
||||||
|
base = None
|
||||||
|
for k, v in get_global_data()["rooms"]["names"].items():
|
||||||
|
if v == r:
|
||||||
|
base = k
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
if type(r) is str:
|
||||||
|
return ord(r[0])
|
||||||
|
# int?
|
||||||
|
return r
|
||||||
|
return order.index(base)
|
||||||
|
|
||||||
|
rooms = list(sorted(rooms, key=_room_sort_key))
|
||||||
|
|
||||||
# room=* is not a real room.
|
# room=* is not a real room.
|
||||||
# Remove it unless that day only has special rooms
|
# Remove it unless that day only has special rooms
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
startdate: 2019-05-30
|
startdate: 2019-05-30
|
||||||
rooms:
|
rooms:
|
||||||
A: Bistrot
|
names:
|
||||||
B: Sala Biliardo (grande)
|
A: Bistrot
|
||||||
C: Hangar
|
B: Sala Biliardo (grande)
|
||||||
D: Sala concerti
|
C: Hangar
|
||||||
|
D: Sala concerti
|
||||||
|
order: [A,B,C,D]
|
||||||
|
|
Loading…
Reference in a new issue