Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Each reload consumes 2 choices from session playlist

  • Loading branch information...
commit 1441fc624ae627e626a5ea66fa7f6f2e3d902d03 1 parent 820b927
@georgevreilly authored
View
18 gae_flask_app/AdYouLation/handlers.py
@@ -3,13 +3,19 @@
from gaesessions import get_current_session
import random
+def create_playlist():
+ videos = current_app.videos
+ keys = videos["videos"].keys()
+ random.shuffle(keys)
+ return keys
+
@AdYouLation.route('/start')
def start():
session = get_current_session()
- counter = session.get('counter', 0)
- session['counter'] = counter + 1
+ playlist = session.get('playlist')
+ if not playlist:
+ playlist = create_playlist()
+ choices = playlist[:2]
+ session['playlist'] = remaining = playlist[2:]
- videos = current_app.videos
- keys = videos["videos"].keys()
- random.shuffle(keys)
- return render_template("start.html", names=keys, counter=counter)
+ return render_template("start.html", choices=choices, remaining=remaining)
View
14 gae_flask_app/templates/start.html
@@ -1,11 +1,19 @@
{% extends "layout.html" %}
{% block body %}
- <ul class=entries>
- {% for video in names %}
+ <h1>Choices</h1>
+ <ul class=choices>
+ {% for video in choices %}
+ <li><h2>{{ video }}</h2>
+ {% else %}
+ <li><em>Unbelievable. No entries here so far</em>
+ {% endfor %}
+ </ul>
+ <h1>Remaining</h1>
+ <ul class=remaining>
+ {% for video in remaining %}
<li><h2>{{ video }}</h2>
{% else %}
<li><em>Unbelievable. No entries here so far</em>
{% endfor %}
</ul>
- Counter = {{ counter }}.
{% endblock %}
Please sign in to comment.
Something went wrong with that request. Please try again.