More transactions enabled.

This commit is contained in:
Philip Sargent 2020-07-22 23:36:46 +01:00
parent 1ef5924f0c
commit 3e3cae507c
2 changed files with 22 additions and 21 deletions

View File

@ -41,6 +41,7 @@ from django.db import connection, close_old_connections, connections
from django.http import HttpResponse from django.http import HttpResponse
from django.urls import reverse from django.urls import reverse
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db import transaction
from troggle.core.models import get_process_memory from troggle.core.models import get_process_memory
from troggle.core.models_caves import Cave, Entrance from troggle.core.models_caves import Cave, Entrance
@ -100,6 +101,7 @@ def reinit_db():
print(" - done migration on: " + settings.DATABASES['default']['NAME']) print(" - done migration on: " + settings.DATABASES['default']['NAME'])
print("users in db already: ",len(User.objects.all())) print("users in db already: ",len(User.objects.all()))
with transaction.atomic():
try: try:
print(" - Setting up admin user on: " + django.db.connections.databases['default']['NAME']) print(" - Setting up admin user on: " + django.db.connections.databases['default']['NAME'])
print(" - user: {} ({:.5}...) <{}> ".format(expouser, expouserpass, expouseremail)) print(" - user: {} ({:.5}...) <{}> ".format(expouser, expouserpass, expouseremail))

View File

@ -59,15 +59,14 @@ def import_survex():
def import_loadpos(): def import_loadpos():
# when this import is moved to the top with the rest it all crashes horribly # when this import is moved to the top with the rest it all crashes horribly
with transaction.atomic():
import troggle.parsers.survex import troggle.parsers.survex
print(" - Survex entrances x/y/z Positions") print(" - Survex entrances x/y/z Positions")
import troggle.parsers.survex with transaction.atomic():
troggle.parsers.survex.LoadPositions() troggle.parsers.survex.LoadPositions()
def import_drawingsfiles(): def import_drawingsfiles():
print("-- Importing Drawings files") print("-- Importing Drawings files")
import troggle.parsers.survex with transaction.atomic():
troggle.parsers.surveys.LoadDrawingFiles() troggle.parsers.surveys.LoadDrawingFiles()
# Fossil. # Fossil.