less async item creation
This commit is contained in:
parent
b2a9a5f711
commit
7c53dca65b
1 changed files with 16 additions and 8 deletions
|
@ -98,7 +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()
|
item.save(sync=not async)
|
||||||
if async:
|
if async:
|
||||||
tasks.update_external.delay(item.public_id)
|
tasks.update_external.delay(item.public_id)
|
||||||
else:
|
else:
|
||||||
|
@ -124,8 +124,8 @@ 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()
|
p = item.save(sync=not async)
|
||||||
if not p:
|
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 +137,8 @@ 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()
|
p = item.save(sync=not async)
|
||||||
if not p:
|
if not p and async:
|
||||||
tasks.update_poster.delay(item.public_id)
|
tasks.update_poster.delay(item.public_id)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
@ -347,6 +347,9 @@ class Item(models.Model):
|
||||||
return '/%s' % self.public_id
|
return '/%s' % self.public_id
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
sync = kwargs.get('sync', False)
|
||||||
|
if 'sync' in kwargs:
|
||||||
|
del kwargs['sync']
|
||||||
update_poster = False
|
update_poster = False
|
||||||
update_ids = False
|
update_ids = False
|
||||||
if not self.id:
|
if not self.id:
|
||||||
|
@ -430,6 +433,11 @@ class Item(models.Model):
|
||||||
if public_id != a.public_id:
|
if public_id != a.public_id:
|
||||||
a.public_id = public_id
|
a.public_id = public_id
|
||||||
a.save()
|
a.save()
|
||||||
|
if sync:
|
||||||
|
tasks.update_file_paths(self.public_id)
|
||||||
|
if update_poster:
|
||||||
|
tasks.update_poster(self.public_id)
|
||||||
|
else:
|
||||||
tasks.update_file_paths.delay(self.public_id)
|
tasks.update_file_paths.delay(self.public_id)
|
||||||
if update_poster:
|
if update_poster:
|
||||||
return tasks.update_poster.delay(self.public_id)
|
return tasks.update_poster.delay(self.public_id)
|
||||||
|
|
Loading…
Reference in a new issue