Make Annotation.public_id non-NULLable (fixes #2829)
This fixes this race:
request 1 request 2
----------------------------- -------------------------
addAnnotation(...)
super(Annotation.self).save()
findAnnotations(...)
returns [{id: null, ...}]
annotation.public_id = x
returns {id: x}
This commit is contained in:
parent
eaa07b1ccb
commit
4f064fda76
4 changed files with 401 additions and 7 deletions
|
|
@ -446,9 +446,11 @@ class Item(models.Model):
|
|||
l.remove(self)
|
||||
if l.items.filter(id=other.id).count() == 0:
|
||||
l.add(other)
|
||||
self.annotations.all().update(item=other, public_id=None)
|
||||
for a in other.annotations.filter(public_id=None).order_by('id'):
|
||||
|
||||
for a in self.annotations.all().order_by('id'):
|
||||
a.item = other
|
||||
a.set_public_id()
|
||||
Annotations.objects.filter(id=a.id).update(item=other, public_id=a.public_id)
|
||||
|
||||
if hasattr(self, 'files'):
|
||||
for f in self.files.all():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue