forked from 0x2620/pandora
random
This commit is contained in:
parent
8aa54922b7
commit
c4ffa15bd4
3 changed files with 12 additions and 1 deletions
|
@ -27,4 +27,5 @@ urlpatterns = patterns("item.views",
|
|||
(r'^(?P<id>[A-Z0-9].+)/poster\.jpg$', 'siteposter'),
|
||||
(r'^(?P<id>[A-Z0-9].+)/frameposter(?P<position>\d+).jpg$', 'poster_frame'),
|
||||
|
||||
(r'^random$', 'random_annotation'),
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
"title": "Title",
|
||||
"type": "string",
|
||||
"autocomplete": true,
|
||||
"autocompleteSortKey": "popularity",
|
||||
"autocompleteSortKey": "timesaccessed",
|
||||
"columnRequired": true,
|
||||
"columnWidth": 180,
|
||||
"find": true,
|
||||
|
|
Loading…
Reference in a new issue