dont update timeline in update_selected, remove unused async get_item case

This commit is contained in:
j 2016-06-16 14:48:54 +02:00
parent 0486d62ec9
commit 6dcbcdd19c
2 changed files with 13 additions and 19 deletions

View file

@ -105,7 +105,7 @@ def process_stream(fileId):
file = models.File.objects.get(id=fileId) file = models.File.objects.get(id=fileId)
file.encoding = False file.encoding = False
file.save() file.save()
file.item.update_selected(update_timeline=False) file.item.update_selected()
if not file.item.rendered \ if not file.item.rendered \
and not file.item.files.exclude(id=fileId).filter(Q(queued=True) | Q(encoding=True)).count(): and not file.item.files.exclude(id=fileId).filter(Q(queued=True) | Q(encoding=True)).count():
file.item.update_timeline() file.item.update_timeline()

View file

@ -64,7 +64,7 @@ def get_id(info):
return imdbId return imdbId
return None return None
def get_item(info, user=None, async=False): def get_item(info, user=None):
''' '''
info dict with: info dict with:
imdbId, title, director, year, imdbId, title, director, year,
@ -98,10 +98,7 @@ def get_item(info, user=None, async=False):
item.external_data = item_data item.external_data = item_data
item.user = user item.user = user
item.oxdbId = item.public_id item.oxdbId = item.public_id
item.save(sync=not async) item.save(sync=True)
if async:
tasks.update_external.delay(item.public_id)
else:
item.update_external() item.update_external()
else: else:
public_id = get_id(info) public_id = get_id(info)
@ -124,8 +121,7 @@ def get_item(info, user=None, async=False):
item = existing_item item = existing_item
except Item.DoesNotExist: except Item.DoesNotExist:
item.oxdbId = item.oxdb_id() item.oxdbId = item.oxdb_id()
p = item.save(sync=not async) item.save(sync=True)
if not p and async:
tasks.update_poster.delay(item.public_id) tasks.update_poster.delay(item.public_id)
else: else:
qs = Item.objects.filter(find__key='title', find__value__iexact=info['title']) qs = Item.objects.filter(find__key='title', find__value__iexact=info['title'])
@ -137,8 +133,7 @@ def get_item(info, user=None, async=False):
item = Item() item = Item()
item.data = item_data item.data = item_data
item.user = user item.user = user
p = item.save(sync=not async) item.save(sync=True)
if not p and async:
tasks.update_poster.delay(item.public_id) tasks.update_poster.delay(item.public_id)
return item return item
@ -361,6 +356,7 @@ class Item(models.Model):
self.public_id = str(uuid.uuid1()) self.public_id = str(uuid.uuid1())
self.add_default_data() self.add_default_data()
super(Item, self).save(*args, **kwargs) super(Item, self).save(*args, **kwargs)
update_poster = True
if not settings.USE_IMDB: if not settings.USE_IMDB:
self.public_id = ox.toAZ(self.id) self.public_id = ox.toAZ(self.id)
@ -462,7 +458,7 @@ class Item(models.Model):
for a in self.annotations.all().order_by('id'): for a in self.annotations.all().order_by('id'):
a.item = other a.item = other
a.set_public_id() a.set_public_id()
Annotations.objects.filter(id=a.id).update(item=other, public_id=a.public_id) Annotation.objects.filter(id=a.id).update(item=other, public_id=a.public_id)
if hasattr(self, 'files'): if hasattr(self, 'files'):
for f in self.files.all(): for f in self.files.all():
@ -1186,7 +1182,7 @@ class Item(models.Model):
qs = qs.exclude(id__in=wanted) qs = qs.exclude(id__in=wanted)
qs.update(wanted=False) qs.update(wanted=False)
def update_selected(self, update_timeline=True): def update_selected(self):
sets = self.sets() sets = self.sets()
for s in sets: for s in sets:
if s.filter(Q(is_video=True) | Q(is_audio=True)).filter(available=False).count() == 0: if s.filter(Q(is_video=True) | Q(is_audio=True)).filter(available=False).count() == 0:
@ -1202,8 +1198,6 @@ class Item(models.Model):
if update: if update:
self.rendered = False self.rendered = False
self.save() self.save()
if update_timeline:
tasks.update_timeline.delay(self.public_id)
break break
if not sets: if not sets:
self.rendered = False self.rendered = False