diff --git a/modules/django.py b/modules/django.py index f9e1208..e4294d3 100644 --- a/modules/django.py +++ b/modules/django.py @@ -9,6 +9,7 @@ from .utils import loggify, print_run, booleanize from .utils import generate_template_build_path from .utils import generate_template_files_path from .utils import handle_help +from .utils import prompt_continue import os @@ -267,11 +268,38 @@ def create_project(): fabric_ops.run("rm %s" % manage_path) if exists(full_project_path): - # backup whatever is there - fabric_ops.run("mv {project_path}/{project_name}" - " {project_path}/{project_name}.old".format( - project_name=project_name, - project_path=project_path)) + + # we need to make sure that + # a. we back up the current settings for the project + # b. that we don't override the OLD project backup settings + # c. and that we give ourselves the option to NOT backup + # + # so if the system sees that we already have a backup of the main + # folder, ie. projectname.old, then it will give us the option to + # either overwrite the old backup (Y), or to stop the proecess and do + # whatever needs to be done to clear things up + + project_path_old = "{project_path}/{project_name}.old".format( + project_path=project_path, + project_name=project_name) + + if exists(project_path_old): + prompt_continue( + message="found an already existing old version of " + "{project_path}, do you want to ignore backing up the version or exit? Y/n" + "( Y to continue without backing up. N to exit )", default="n") + + fabric_ops.run("rm -Rf {project_path}/{project_name}".format( + project_name=project_name, + project_path=project_path)) + + else: + + # backup whatever is there + fabric_ops.run("mv {project_path}/{project_name}" + " {project_path}/{project_name}.old".format( + project_name=project_name, + project_path=project_path)) with virtualenv(): fabric_ops.run(django_cmd)