Rollback transaction for installion app during syncdb
This commit is contained in:
@@ -7,6 +7,7 @@ from project_tools.api import register_tool
|
|||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.db.utils import DatabaseError
|
from django.db.utils import DatabaseError
|
||||||
|
from django.db import transaction
|
||||||
|
|
||||||
from .links import installation_details
|
from .links import installation_details
|
||||||
from .models import Installation
|
from .models import Installation
|
||||||
@@ -20,12 +21,13 @@ def trigger_first_time(sender, **kwargs):
|
|||||||
details.save()
|
details.save()
|
||||||
|
|
||||||
|
|
||||||
|
@transaction.commit_on_success
|
||||||
def check_first_run():
|
def check_first_run():
|
||||||
try:
|
try:
|
||||||
details = Installation.objects.get()
|
details = Installation.objects.get()
|
||||||
except DatabaseError:
|
except DatabaseError:
|
||||||
# Avoid database errors when the app tables haven't been created yet
|
# Avoid database errors when the app tables haven't been created yet
|
||||||
pass
|
transaction.rollback()
|
||||||
else:
|
else:
|
||||||
if details.is_first_run:
|
if details.is_first_run:
|
||||||
details.submit()
|
details.submit()
|
||||||
|
|||||||
Reference in New Issue
Block a user