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].+)/poster\.jpg$', 'siteposter'),
|
||||||
(r'^(?P<id>[A-Z0-9].+)/frameposter(?P<position>\d+).jpg$', 'poster_frame'),
|
(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
|
import os.path
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
import random
|
||||||
|
|
||||||
import Image
|
import Image
|
||||||
from django.db.models import Count, Sum, Max
|
from django.db.models import Count, Sum, Max
|
||||||
|
@ -802,3 +803,12 @@ def video(request, id, resolution, format, index=None):
|
||||||
response = HttpFileResponse(path)
|
response = HttpFileResponse(path)
|
||||||
response['Cache-Control'] = 'public'
|
response['Cache-Control'] = 'public'
|
||||||
return response
|
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",
|
"title": "Title",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"autocomplete": true,
|
"autocomplete": true,
|
||||||
"autocompleteSortKey": "popularity",
|
"autocompleteSortKey": "timesaccessed",
|
||||||
"columnRequired": true,
|
"columnRequired": true,
|
||||||
"columnWidth": 180,
|
"columnWidth": 180,
|
||||||
"find": true,
|
"find": true,
|
||||||
|
|
Loading…
Reference in a new issue