Permalink
Browse files

Embed videos in voting form

  • Loading branch information...
1 parent 26eb2e4 commit 1beb531c06f1faa74b42e69fbae2e955edf1c784 @georgevreilly committed Feb 3, 2013
@@ -37,8 +37,8 @@ def get_choices_remaining(index=2):
session = get_current_session()
playlist = session.get('playlist')
if not playlist:
- playlist = create_playlist()
- return playlist[:2], playlist[2:]
+ playlist = session['playlist'] = create_playlist()
+ return playlist[:index], playlist[index:]
def update_playlist():
(choices, remaining) = get_choices_remaining()
@@ -53,16 +53,20 @@ def start():
session['id'] = uuid.uuid4()
return render_template("start.html")
-class VideoChoice(RadioField):
- CHOICES = (("up", "Yes!"), ("down", "No!"))
-def vote_form(videos):
+def vote_form(choices):
class VoteForm(Form):
pass
- for index, video in enumerate(videos):
+ CHOICES = (("up", "Yes!"), ("down", "No!"))
+ videos = current_app.videos["videos"]
+
+ for index, choice in enumerate(choices):
+ class VideoChoice(RadioField):
+ ytid = videos[choice]['ytid']
+
name = "video_{}".format(index+1)
- field = VideoChoice(video, validators=[Required()], choices=VideoChoice.CHOICES)
+ field = VideoChoice(choice, validators=[Required()], choices=CHOICES)
setattr(VoteForm, name, field)
return VoteForm()
@@ -85,7 +89,8 @@ def vote():
id = get_current_session()['id']
form = vote_form(choices)
if form.validate_on_submit():
- update_playlist()
record_vote(form)
+ update_playlist()
return redirect(url_for(".vote"))
- return render_template("vote.html", form=form, remaining=remaining, id=id)
+ else:
+ return render_template("vote.html", form=form, remaining=remaining, id=id)
@@ -4,14 +4,14 @@
}
td.video-choice div {
- width: 300px;
+ width: 500px;
border-style: dotted;
margin-right: 30px;
padding: 10px;
}
div.get-started {
- width: 300px;
+ width: 500px;
background-color: orange;
font-size: 2em;
padding-left: 2ex;
@@ -14,6 +14,10 @@
{% macro render_video(video) %}
<div class="video_field">
<h4>{{ video.label }}</h4>
+ <iframe width="420" height="315"
+ src="http://www.youtube.com/embed/{{video.ytid}}"
+ frameborder="0" allowfullscreen>
+ </iframe>
{{ video(**kwargs) }}
</div>
{% endmacro %}
View
@@ -1,62 +1,62 @@
{
"videos": {
"bellringer": {
- "url": "http://youtu.be/57M3rKfYnpg",
+ "ytid": "57M3rKfYnpg",
"title": "Bell Ringer at College Football Game",
"duration": 10
},
"supermariobros": {
- "url": "http://youtu.be/yr_Rpk9HR1g",
+ "ytid": "yr_Rpk9HR1g",
"title": "Super Марио Brothers",
"duration": 7
},
"stapler": {
- "url": "http://youtu.be/UiyDmqO59QE",
+ "ytid": "UiyDmqO59QE",
"title": "Missing",
"duration": 8
},
"karma": {
- "url": "http://youtu.be/LVQVpuaB-nc",
+ "ytid": "LVQVpuaB-nc",
"title": "Un Gol Bastante Raro",
"duration": 11
},
"signpunch": {
- "url": "http://youtu.be/rZt0avHRR00",
+ "ytid": "rZt0avHRR00",
"title": "This is why you don't punch street signs",
"duration": 5
},
"cocaine": {
- "url": "http://youtu.be/CmC62Eg82E8",
+ "ytid": "CmC62Eg82E8",
"title": "Henry the Hoover's cocaine overdose",
"duration": 17
},
"i_so_pale": {
- "url": "http://youtu.be/ab0ddj6hadM",
+ "ytid": "ab0ddj6hadM",
"title": "I So Pale FAIL news blooper 2012",
"duration": 15
},
"primeval5": {
- "url": "http://youtu.be/FI3r73XJ7xU",
+ "ytid": "FI3r73XJ7xU",
"title": "Primeval Series 5 Clip",
"duration": 6
},
"failing": {
- "url": "http://youtu.be/_E_-Qt66XBY",
+ "ytid": "_E_-Qt66XBY",
"title": "You are Failing",
"duration": 3
},
"shutup": {
- "url": "http://youtu.be/CEgh8TUlpQc",
+ "ytid": "CEgh8TUlpQc",
"title": "SHUT UP",
"duration": 5
},
"please_no": {
- "url": "http://youtu.be/umDr0mPuyQc",
+ "ytid": "umDr0mPuyQc",
"title": "NO GOD! PLEASE NO!!! NOOOOOOOOOO",
"duration": 17
},
"aww_hell_naw": {
- "url": "http://youtu.be/im_5QdHp04E",
+ "ytid": "im_5QdHp04E",
"title": "AWW HELL NAW",
"duration": 3
}
View
@@ -1,17 +1,17 @@
{
"videos": {
"godaddy": {
- "url": "http://youtu.be/o-3j4-4N3Ng",
+ "ytid": "o-3j4-4N3Ng",
"title": "Perfect Match - Bar Refaeli's Big Kiss!",
"duration": 10
},
"hyundai": {
- "url": "http://youtu.be/3jEU7yd4yuI",
+ "ytid": "3jEU7yd4yuI",
"title": "2013 Hyundai Santa Fe | \"Don't Tell\"",
"duration": 10
},
"budweiser": {
- "url": "http://youtu.be/o2prAccclXs",
+ "ytid": "o2prAccclXs",
"title": "The Clydesdales: \"Brotherhood\"",
"duration": 10
}

0 comments on commit 1beb531

Please sign in to comment.