use transaction.atomic

This commit is contained in:
j 2016-02-19 21:55:09 +05:30
commit e22cc432b3
13 changed files with 19 additions and 19 deletions

View file

@ -17,7 +17,7 @@ class Command(BaseCommand):
def handle(self, id, height, position, **options):
position = float(position)
height = int(height)
with transaction.commit_on_success():
with transaction.atomic():
i = models.Item.objects.get(public_id=id)
path = i.frame(position, height)
if path:

View file

@ -769,7 +769,7 @@ class Item(models.Model):
return titles
with transaction.commit_on_success():
with transaction.atomic():
for key in settings.CONFIG['itemKeys']:
i = key['id']
if i == 'title':
@ -1547,7 +1547,7 @@ class Item(models.Model):
# only import on 0xdb for now or if forced manually
# since this will remove all existing subtitles
if force or not existing.count() or settings.USE_IMDB:
with transaction.commit_on_success():
with transaction.atomic():
Annotation.objects.filter(layer=layer, item=self).delete()
AnnotationSequence.reset(self)
offset = 0
@ -1790,7 +1790,7 @@ class AnnotationSequence(models.Model):
@classmethod
def nextid(cls, item):
with transaction.commit_on_success():
with transaction.atomic():
s, created = cls.objects.get_or_create(item=item)
if created:
nextid = s.value

View file

@ -32,7 +32,7 @@ def update_random_sort():
def update_random_clip_sort():
if filter(lambda f: f['id'] == 'random', settings.CONFIG['itemKeys']):
with transaction.commit_on_success():
with transaction.atomic():
cursor = connection.cursor()
cursor.execute('DROP TABLE clip_random;')
cursor.execute('CREATE TABLE "clip_random" AS SELECT id AS clip_id, row_number() OVER (ORDER BY random()) AS random FROM "clip_clip"')