From cde4f61f10d04725fcda30b318be98bb2e8c613f Mon Sep 17 00:00:00 2001 From: Andreas Valder <andreasv@fsmpi.rwth-aachen.de> Date: Thu, 8 Sep 2016 19:56:41 +0200 Subject: [PATCH] =?UTF-8?q?made=20"n=C3=A4chste=20aufnahmen"=20show=20the?= =?UTF-8?q?=20next=20week=20only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 6 ++++-- templates/index.html | 32 ++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/server.py b/server.py index 0e8992d..1c2ab2d 100755 --- a/server.py +++ b/server.py @@ -127,12 +127,14 @@ def fixnl(s): @app.route('/') @register_navbar('Home', icon='home') def index(): + start = date.today() - timedelta(days=1) + end = start + timedelta(days=7) upcomming = query (''' SELECT lectures.*,courses.short, courses.title AS course_title FROM lectures JOIN courses ON (lectures.course_id = courses.id) - WHERE (time > ?) - ORDER BY time ASC LIMIT 7''',datetime.today()) + WHERE (time > ?) AND (time < ?) and lectures.visible and courses.visible and courses.listed + ORDER BY time ASC LIMIT 30''',start,end) for i in upcomming: i['date'] = i['time'].date() latestvideos=query(''' diff --git a/templates/index.html b/templates/index.html index 201abe4..abe3f37 100644 --- a/templates/index.html +++ b/templates/index.html @@ -69,21 +69,25 @@ <div class="panel-heading"> <h1 class="panel-title">Nächste Aufnahmen</h1"> </div> - <ul class="list-group"> - {% for g in upcomming|groupby('date') %} - <li class="list-group-item"> - <ul class="list-group" style="margin: 0px;"> - <strong>{{ g.grouper|date }}</strong> - {% for i in g.list %} - <li class="list-group-item list-group-item-condensed"> - {{i.time|time}} {{i.place}} <a href="{{url_for('course', id=i.course_id)}}">{{i.course_title}}</a>: <a href="{{url_for('course', id=i.course_id)}}#lecture-{{i.id}}">{{i.title}}</a> + {% if upcomming|length > 0 %} + <ul class="list-group"> + {% for g in upcomming|groupby('date') %} + <li class="list-group-item"> + <ul class="list-group" style="margin: 0px;"> + <strong>{{ g.grouper|date }}</strong> + {% for i in g.list %} + <li class="list-group-item list-group-item-condensed"> + {{i.time|time}} {{i.place}} <a href="{{url_for('course', id=i.course_id)}}">{{i.course_title}}</a>: <a href="{{url_for('course', id=i.course_id)}}#lecture-{{i.id}}">{{i.title}}</a> - </li> - {% endfor %} - </ul> - </li> - {% endfor %} - </ul> + </li> + {% endfor %} + </ul> + </li> + {% endfor %} + </ul> + {% else %} + <p>In den nächsten 7 Tagen wird noch nichts aufgenommen oder gestreamt.</p> + {% endif %} </div> <div class="panel panel-default"> <div class="panel-heading"> -- GitLab