random
This commit is contained in:
parent
8aa54922b7
commit
c4ffa15bd4
3 changed files with 12 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue