From 3dd8f12df29e37bcc57fba225db2cce95c20985a Mon Sep 17 00:00:00 2001 From: boyska Date: Fri, 9 Jun 2017 11:42:08 +0200 Subject: [PATCH] descrizione talk ordinata per orario --- plugins/talks.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/talks.py b/plugins/talks.py index 8339033..3e37d3e 100644 --- a/plugins/talks.py +++ b/plugins/talks.py @@ -180,11 +180,24 @@ class TalkListDirective(Directive): def run(self): lang = self.options.get('lang', 'C') tmpl = jinja_env().get_template('talk.html') + + def _sort_date(name): + ''' + This function is a helper to sort talks by start date + + When no date is available, put at the beginning + ''' + d = get_talk_data(name) + if 'time' in d: + return d['time'] + return datetime.datetime(1, 1, 1) + return [ nodes.raw('', tmpl.render(lang=lang, **get_talk_data(n)), format='html') - for n in get_talk_names() - ] + for n in sorted(get_talk_names(), + key=_sort_date) + ] class TalkDirective(Directive):