forked from 0x2620/pandora
fix annotation links
This commit is contained in:
parent
9b1f482a21
commit
cff1c06546
1 changed files with 16 additions and 9 deletions
|
@ -5,7 +5,7 @@ import ox
|
||||||
|
|
||||||
|
|
||||||
def index(request, fragment):
|
def index(request, fragment):
|
||||||
from item.models import Item
|
from item.models import Item, Annotation
|
||||||
from edit.models import Edit
|
from edit.models import Edit
|
||||||
from document.models import Document
|
from document.models import Document
|
||||||
context = {}
|
context = {}
|
||||||
|
@ -52,19 +52,26 @@ def index(request, fragment):
|
||||||
type = 'item'
|
type = 'item'
|
||||||
id = parts[0]
|
id = parts[0]
|
||||||
item = Item.objects.filter(public_id=id).first()
|
item = Item.objects.filter(public_id=id).first()
|
||||||
if item and item.accessible(request.user):
|
if item and item.access(request.user):
|
||||||
link = request.build_absolute_uri(item.get_absolute_url())
|
link = request.build_absolute_uri(item.get_absolute_url())
|
||||||
if len(parts) > 1 and parts[1] in ('editor', 'player'):
|
if len(parts) > 1 and parts[1] in ('editor', 'player'):
|
||||||
parts = [parts[0]] + parts[2:]
|
parts = [parts[0]] + parts[2:]
|
||||||
if len(parts) > 1:
|
if len(parts) > 1:
|
||||||
inout = parts[1]
|
aid = '%s/%s' % (id, parts[1])
|
||||||
if '-' in inout:
|
annotation = Annotation.objects.filter(public_id=aid).first()
|
||||||
inout = inout.split('-')
|
if annotation:
|
||||||
|
inout = [annotation.start, annotation.end]
|
||||||
else:
|
else:
|
||||||
inout = inout.split(',')
|
inout = parts[1]
|
||||||
inout = [ox.parse_timecode(p) for p in inout]
|
if '-' in inout:
|
||||||
if len(inout) == 3:
|
inout = inout.split('-')
|
||||||
inout.pop(1)
|
else:
|
||||||
|
inout = inout.split(',')
|
||||||
|
print(inout)
|
||||||
|
if len(inout) == 3:
|
||||||
|
inout.pop(1)
|
||||||
|
if len(inout) == 2:
|
||||||
|
inout = [ox.parse_timecode(p) for p in inout]
|
||||||
context['preview'] = link + '/480p%s.jpg' % inout[0]
|
context['preview'] = link + '/480p%s.jpg' % inout[0]
|
||||||
else:
|
else:
|
||||||
context['preview'] = link + '/480p.jpg'
|
context['preview'] = link + '/480p.jpg'
|
||||||
|
|
Loading…
Reference in a new issue