Commit 5db067b4 authored by fred's avatar fred

add party mode

parent d58db7ef
......@@ -25,6 +25,8 @@ urlpatterns = patterns('',
url(r'^news/archives/$', 'panikweb.search.newsArchives', name='newsArchives'),
url(r'^news/(?P<slug>[\w,-]+)$', 'panikweb.views.newsitemview', name='newsitem-view'),
url(r'^party', 'panikweb.views.party', name='party'),
url(r'^search/', 'panikweb.search.view', name='search'),
url(r'^news.rss', 'panikweb.views.rss_news_feed', name='rss-feed'),
......
from datetime import datetime, timedelta
import math
import random
import os
import stat
import time
......@@ -603,3 +604,31 @@ class AtomNewsFeed(RssNewsFeed):
feed_type = Atom1Feed
atom_news_feed = AtomNewsFeed()
class Party(TemplateView):
template_name = 'party.html'
def get_context_data(self, **kwargs):
context = super(Party, self).get_context_data(**kwargs)
t = random.choice(['newsitem']*2 + ['emission']*3 + ['soundfile']*1 + ['episode']*2)
focus = Focus()
if t == 'newsitem':
focus.newsitem = NewsItem.objects.exclude(
image__isnull=True).exclude(image__exact='').order_by('?')[0]
elif t == 'emission':
focus.emission = Emission.objects.exclude(
image__isnull=True).exclude(image__exact='').order_by('?')[0]
elif t == 'episode':
focus.episode = Episode.objects.exclude(
image__isnull=True).exclude(image__exact='').order_by('?')[0]
elif t == 'soundfile':
focus.soundfile = SoundFile.objects.exclude(
episode__image__isnull=True).exclude(episode__image__exact='').order_by('?')[0]
context['focus'] = focus
return context
party = Party.as_view()
{% extends "base.html" %}
{% load thumbnails %}
{% load paniktags %}
{% load staticfiles %}
{% load i18n %}
{% block bodyID %}Party{% endblock %}
{% block title %}Party{% endblock %}
{% block extrascripts %}
<script>
function reload() {
if (location.href.indexOf('?') == -1) {
href = location.href;
} else {
href = location.href.substring(0, location.href.indexOf('?'));
}
href = href + '?' + new Date().getTime()
$('#Changing').fadeOut();
$('#Changing').load(href + " #Changing>*", null, function() {$('#Changing').fadeIn();});
}
$(function() {
timer = setInterval(reload, 10000);
});
</script>
{% endblock %}
{% block main %}
<div id="party" class="news">
<div class="content content-inline cf special">
<a class="block cf" href="{{ focus|get_focus_url}}">
{% if focus.content_category_title %}
<div class="label labels absolute">
<span class="item inBlock">{{ focus.content_category_title }}</span>
</div>
{% endif %}
<div class="logo">
<img class="normal" src="{{ focus.content_image|thumbnail:'500x375' }}"/>
</div>
<div class="title"><div>{{ focus.focus_title }}</div></div>
</a>
</div>
<style>
#metaNav, #Footer, .metas { display: none; }
.special .title {
opacity:0.9;
width: 482px;
background: black;
color: white;
position: absolute;
bottom: 0;
font-family: "RegloBold";
padding: 10px;
}
body {
height: 90%;
overflow: hidden;
}
#Changing,
#Commons {
float: none;
height: 200px;
width: 500px;
margin: 0 auto 0 auto;
}
#backgroundBox {
margin: auto 0;
}
#Commons > .wrapper {
position: relative;
}
#Player {
width: 200px;
position: absolute;
top: 50px;
left: 200px;
}
</style>
{% endblock %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment