Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

core kioskization finished

  • Loading branch information...
commit ed8740f9756008e884a04662b1ec9b1273925b89 1 parent 792131e
Sebastian Steuer authored
View
15 kiosk/models.py
@@ -19,13 +19,15 @@
STREAM_PLAYING = 'p'
STREAM_FINISHED = 'f'
STREAM_ERROR = 'e'
+STREAM_ABORT = 'x'
STREAM_CHOICES =((STREAM_NEW, "NEW"),
(STREAM_DENIED, "DENIED"),
(STREAM_ALLOWED, "ALLOWED"),
(STREAM_PLAYING, "PLAYING"),
(STREAM_FINISHED, "FINISHED"),
- (STREAM_ERROR, "ERROR"))
+ (STREAM_ERROR, "ERROR"),
+ (STREAM_ABORT, "ABORT"))
class HistoryManager(models.Manager):
def get_latest(self):
@@ -46,7 +48,16 @@ def push_movie(self, ai):
new.save()
self.trim()
+
+ def push_stream(self, sr):
+ new = History(type = ITEM_TYPE_EXTERNAL_STREAM,
+ title = sr.title,
+ author = sr.author,
+ streamRequest = sr)
+ new.save()
+ self.trim()
+
def trim(self):
"""Delete all but the newest 100"""
for h in self.all()[100:]:
@@ -59,7 +70,7 @@ class History(models.Model):
author = models.CharField(max_length=512)
played = models.DateTimeField(auto_now_add = True)
animationInstance = models.ForeignKey(AnimationInstance, blank=True, null=True)
-
+ streamRequest = models.ForeignKey('StreamRequest', blank=True, null=True)
objects = HistoryManager()
class Meta():
View
4 kiosk/templates/kiosk.html
@@ -3,10 +3,12 @@
<h1>Initializing...</h1>
</div>
+{% comment %}
<ul>
<li><a href="{% url acab.views.index %}">ACABED</a></li>
<li><a href="">Select</a></li>
</ul>
+{% endcomment %}
</div>
@@ -27,7 +29,7 @@
<style type='text/css'>
#kioskbox {
width: 100%;
- height: 100px;
+ height: 200px;
background-color: grey;
}
</style>
View
20 kiosk/templates/kiosk_live.html
@@ -1,4 +1,20 @@
-<h1>onscreen: {{now}}</h1>
+<h1>Playing: {{now}}</h1>
+ {% if now.type == "l" or now.type == 'e' %}
+ SR:{{now.streamRequest.id}}
+ <button id = "button_abort" onclick = "setState({{now.streamRequest.id}},'x');">Abort</button>
+ {% endif %}
{% if request %}
<h1>Request: {{request}}</h1>
-{% endif %}
+ <button id = "button_allow" onclick = "setState({{request.id}},'a');">Allow</button>
+ <button id = "button_deny" onclick = "setState({{request.id}}, 'd');">Deny</button>
+{% endif %}
+
+<script type='text/javascript'>
+
+
+ function setState(id, state) {
+ bla = new Request.HTML({url:'{% url kiosk_set %}'}).post({'id': id, 'state': state});
+ }
+
+ //$('button_allow').addEvent('onclick', setState({{request.id}},'a'));
+</script>
View
5 kiosk/urls.py
@@ -21,6 +21,7 @@
from django.conf.urls.defaults import *
urlpatterns = patterns('',
- (r'^select$', 'kiosk.views.select'),
- (r'^live$', 'kiosk.views.live'),
+ url(r'^select$', 'kiosk.views.select', name="kiosk_select"),
+ url(r'^live$', 'kiosk.views.live', name='kiosk_live'),
+ url(r'^request/set/', 'kiosk.views.set', name='kiosk_set')
)
View
19 kiosk/views.py
@@ -1,6 +1,7 @@
-from django.shortcuts import render_to_response
+from django.shortcuts import render_to_response, get_object_or_404
from django.template.context import RequestContext
-from kiosk.models import History, StreamRequest
+from kiosk.models import History, StreamRequest, STREAM_CHOICES
+from django.http import HttpResponse
def live(request):
ctx = { 'now' : History.objects.get_latest(),
@@ -13,4 +14,16 @@ def live(request):
def select(request):
return render_to_response('select.html',
{},
- context_instance=RequestContext(request))
+ context_instance=RequestContext(request))
+
+def set(request):
+ if request.method == 'POST':
+ sr = get_object_or_404(StreamRequest, id=request.POST['id'])
+ state = request.POST['state']
+ if state in [s for (s,name) in STREAM_CHOICES]:
+ sr.state = state
+ sr.save()
+ return HttpResponse(status = 200)
+ return HttpResponse(status = 400)
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.