Add code to check if there is existing data before executing a bootstrap setup

This commit is contained in:
Roberto Rosario
2012-09-27 01:45:52 -04:00
parent b42a43bafd
commit 3b895d7560
4 changed files with 26 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ from .permissions import (PERMISSION_BOOTSTRAP_VIEW, PERMISSION_BOOTSTRAP_CREATE
PERMISSION_BOOTSTRAP_EXECUTE, PERMISSION_NUKE_DATABASE, PERMISSION_BOOTSTRAP_DUMP)
from .icons import icon_bootstrap_setup_execute, icon_nuke_database, icon_bootstrap_setup_delete
from .forms import BootstrapSetupForm, BootstrapSetupForm_view, BootstrapSetupForm_dump
from .exceptions import ExistingData
def bootstrap_setup_list(request):
@@ -155,6 +156,8 @@ def bootstrap_setup_execute(request, bootstrap_setup_pk):
if request.method == 'POST':
try:
bootstrap_setup.execute()
except ExistingData:
messages.error(request, _(u'Cannot execute bootstrap setup, there is existing data. Erase database and try again.'))
except Exception, exc:
messages.error(request, _(u'Error executing bootstrap setup; %s') % exc)
else: