Commits

Sebastián Magrí committed acde8ec

Don't show past events

  • Participants
  • Parent commits b0291ad

Comments (0)

Files changed (1)

+from datetime import datetime
+
 from flask import (Flask, request, url_for, render_template,
                    redirect, g)
 from flask.ext.bootstrap import Bootstrap
 @app.route('/', methods=('GET',))
 @db.wrap
 def index():
-    next_act = db.Event.find_one(sort=[('when', 1)], limit=1)
+    next_act = db.Event.find_one(
+        {'when': {'$gt': datetime.today()}},
+        sort=[('when', 1)],
+        limit=1
+    )
     tags = db.Event.find().distinct('tags')
     return render_template('index.html', next_act=next_act, tags=tags)
 
 @app.route('/events', methods=('GET', 'POST'))
 @db.wrap
 def events():
+    # Turn request args into MongoKit Qry
+    qry = dict(request.args.items())
+    qry.update(
+        {
+            'when': {
+                '$gt': datetime.today()
+            }
+        }
+    )
     acts = list(
         db.Event.find(
-            dict(request.args.items()),  # Turn request args into MongoKit Qry
+            qry,
             sort=[('when', 1)]
         )
     )