avoid looking up item twice
This commit is contained in:
parent
7c53dca65b
commit
22f83288c5
3 changed files with 11 additions and 8 deletions
|
|
@ -434,7 +434,7 @@ class Item(models.Model):
|
|||
a.public_id = public_id
|
||||
a.save()
|
||||
if sync:
|
||||
tasks.update_file_paths(self.public_id)
|
||||
self.update_file_paths()
|
||||
if update_poster:
|
||||
tasks.update_poster(self.public_id)
|
||||
else:
|
||||
|
|
@ -1099,6 +1099,11 @@ class Item(models.Model):
|
|||
else:
|
||||
self.update_facet(key)
|
||||
|
||||
def update_file_paths(self):
|
||||
for f in item.files.all():
|
||||
if f.normalize_path() != f.path:
|
||||
f.save()
|
||||
|
||||
def path(self, name=''):
|
||||
h = self.public_id
|
||||
h = (7-len(h))*'0' + h
|
||||
|
|
|
|||
|
|
@ -67,9 +67,7 @@ def update_poster(public_id):
|
|||
@task(ignore_results=True, queue='default')
|
||||
def update_file_paths(public_id):
|
||||
item = models.Item.objects.get(public_id=public_id)
|
||||
for f in item.files.all():
|
||||
if f.normalize_path() != f.path:
|
||||
f.save()
|
||||
item.update_file_paths()
|
||||
|
||||
@task(ignore_results=True, queue='default')
|
||||
def update_external(public_id):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue