clips,default annotations without user
This commit is contained in:
parent
94d066d053
commit
6835937431
2 changed files with 10 additions and 5 deletions
|
@ -1007,8 +1007,11 @@ class Item(models.Model):
|
||||||
.filter(selected=True).order_by('part'):
|
.filter(selected=True).order_by('part'):
|
||||||
subtitles_added = False
|
subtitles_added = False
|
||||||
prefix = os.path.splitext(f.path)[0]
|
prefix = os.path.splitext(f.path)[0]
|
||||||
|
if f.instances.all().count() > 0:
|
||||||
user = f.instances.all()[0].volume.user
|
user = f.instances.all()[0].volume.user
|
||||||
|
else:
|
||||||
|
#FIXME: allow annotations from no user instead?
|
||||||
|
user = User.objects.all().order_by('id')[0]
|
||||||
#if there is a subtitle with the same prefix, import
|
#if there is a subtitle with the same prefix, import
|
||||||
q = subtitles.filter(path__startswith=prefix,
|
q = subtitles.filter(path__startswith=prefix,
|
||||||
language=language)
|
language=language)
|
||||||
|
|
|
@ -224,11 +224,13 @@ Positions
|
||||||
def get_clips(qs):
|
def get_clips(qs):
|
||||||
n = qs.count()
|
n = qs.count()
|
||||||
if n > query['clip_items']:
|
if n > query['clip_items']:
|
||||||
|
num = query['clip_items']
|
||||||
clips = []
|
clips = []
|
||||||
step = int(n/query['clip_items'])
|
step = int(n / (num + 1))
|
||||||
offset = int((n - step * query['clip_items']) / 2)
|
i = step
|
||||||
for i in range(offset, n, step):
|
while i <= (n - step) and i < n and len(clips) < num:
|
||||||
clips.append(qs[i])
|
clips.append(qs[i])
|
||||||
|
i += step
|
||||||
else:
|
else:
|
||||||
clips = qs
|
clips = qs
|
||||||
return [c.json(query['clip_keys']) for c in clips]
|
return [c.json(query['clip_keys']) for c in clips]
|
||||||
|
|
Loading…
Reference in a new issue