Browse Source

fixing display of events and blog posts on front page

jeremiewcz 1 year ago
parent
commit
c1b2173087
1 changed files with 9 additions and 5 deletions
  1. 9
    5
      app/main/views.py

+ 9
- 5
app/main/views.py View File

@@ -4,7 +4,8 @@ import json
4 4
 from glob import glob
5 5
 from config import config, LIQUIDSOAP_TOKEN
6 6
 from uuid import uuid4                 # FIXME no longer needed i think
7
-from datetime import date              # same
7
+from datetime import date, datetime              # same
8
+from sqlalchemy import cast, Date
8 9
 
9 10
 # Flask stuff
10 11
 from flask import (Flask,
@@ -51,9 +52,12 @@ def index():
51 52
             'template': render_template(
52 53
                 "index.html",
53 54
                 podcasts=Podcast.list(number=3),
54
-                blog_posts = BlogPost.list(number=3),
55
-                events = Event.query.order_by(Event.begin.asc())\
56
-                  .limit(5).all()
55
+                blog_posts = BlogPost.query\
56
+                    .order_by(BlogPost.timestamp.desc()),
57
+                events = Event.query.order_by(Event.begin.desc())\
58
+                    .filter(cast(Event.begin, Date) >= date.today())\
59
+                    .order_by(Event.begin.asc())\
60
+                    .limit(5).all()
57 61
             )
58 62
         }
59 63
     }
@@ -284,7 +288,7 @@ def blog(id):
284 288
 def agendas():
285 289
     page = request.args.get('page', 1, type=int)
286 290
     pagination = Event.query                         \
287
-        .order_by(Event.begin.asc())            \
291
+        .order_by(Event.begin.desc())            \
288 292
         .paginate(page, per_page=10, error_out=False)
289 293
     events = pagination.items
290 294
     return {

Loading…
Cancel
Save