From c4ffa15bd41ee252057a5b806aa6341a1ec191a3 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 12 Nov 2011 09:57:51 +0100 Subject: [PATCH] random --- pandora/item/urls.py | 1 + pandora/item/views.py | 10 ++++++++++ pandora/padma.jsonc | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pandora/item/urls.py b/pandora/item/urls.py index 23bf9fe61..e5fed4810 100644 --- a/pandora/item/urls.py +++ b/pandora/item/urls.py @@ -27,4 +27,5 @@ urlpatterns = patterns("item.views", (r'^(?P[A-Z0-9].+)/poster\.jpg$', 'siteposter'), (r'^(?P[A-Z0-9].+)/frameposter(?P\d+).jpg$', 'poster_frame'), + (r'^random$', 'random_annotation'), ) diff --git a/pandora/item/views.py b/pandora/item/views.py index 86bb1f416..c255e13ab 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -4,6 +4,7 @@ from __future__ import division import os.path from datetime import datetime, timedelta import mimetypes +import random import Image from django.db.models import Count, Sum, Max @@ -802,3 +803,12 @@ def video(request, id, resolution, format, index=None): response = HttpFileResponse(path) response['Cache-Control'] = 'public' return response + +def random_annotation(request): + n = models.Item.objects.all().count() + pos = random.randint(0, n) + item = models.Item.objects.all()[pos] + n = item.annotations.all().count() + pos = random.randint(0, n) + clip = item.annotations.all()[pos] + return redirect('/%s'% clip.public_id) diff --git a/pandora/padma.jsonc b/pandora/padma.jsonc index 76417e07c..1041bc38b 100644 --- a/pandora/padma.jsonc +++ b/pandora/padma.jsonc @@ -16,7 +16,7 @@ "title": "Title", "type": "string", "autocomplete": true, - "autocompleteSortKey": "popularity", + "autocompleteSortKey": "timesaccessed", "columnRequired": true, "columnWidth": 180, "find": true,