updated files to use 'core' as main django app
This commit is contained in:
parent
11416705bd
commit
ce6df87b85
11 changed files with 72 additions and 63 deletions
|
|
@ -432,20 +432,23 @@ def create_project():
|
||||||
logger = loggify("django", "create_project")
|
logger = loggify("django", "create_project")
|
||||||
|
|
||||||
project_path = configuration.paths.django.root
|
project_path = configuration.paths.django.root
|
||||||
|
project_base = configuration.paths.django.settings.base
|
||||||
project_name = configuration.project.name
|
project_name = configuration.project.name
|
||||||
|
|
||||||
import os
|
import os
|
||||||
full_project_path = os.path.join(project_path, project_name)
|
full_project_path = os.path.join(project_path, project_base)
|
||||||
|
|
||||||
django_cmd = \
|
django_cmd = \
|
||||||
"django-admin startproject {project_name} {project_path}".format(
|
"django-admin startproject {project_base} {project_path}".format(
|
||||||
project_name=configuration.project.name,
|
project_base=project_base,
|
||||||
project_path=project_path)
|
project_path=project_path)
|
||||||
|
|
||||||
manage_path = "%s/manage.py" % project_path
|
manage_path = "%s/manage.py" % project_path
|
||||||
|
|
||||||
logger.debug("django_root : %s" % configuration.paths.django.root)
|
logger.debug("django_root : %s" % configuration.paths.django.root)
|
||||||
logger.debug("project_path : %s" % project_path)
|
logger.debug("project_path : %s" % project_path)
|
||||||
|
logger.debug("project_base : %s" % project_base)
|
||||||
|
logger.debug("project_name : %s" % project_name)
|
||||||
|
|
||||||
# I accidentally deleted the code directory, this checks to see if the
|
# I accidentally deleted the code directory, this checks to see if the
|
||||||
# project path exists, if not, create it.
|
# project path exists, if not, create it.
|
||||||
|
|
@ -467,9 +470,9 @@ def create_project():
|
||||||
# either overwrite the old backup (Y), or to stop the proecess and do
|
# either overwrite the old backup (Y), or to stop the proecess and do
|
||||||
# whatever needs to be done to clear things up
|
# whatever needs to be done to clear things up
|
||||||
|
|
||||||
project_path_old = "{project_path}/{project_name}.old".format(
|
project_path_old = "{project_path}/{project_base}.old".format(
|
||||||
project_path=project_path,
|
project_path=project_path,
|
||||||
project_name=project_name)
|
project_base=project_base)
|
||||||
|
|
||||||
if exists(project_path_old):
|
if exists(project_path_old):
|
||||||
prompt_continue(
|
prompt_continue(
|
||||||
|
|
@ -478,23 +481,23 @@ def create_project():
|
||||||
" backing up the version or exit? Y/n ( Y to "
|
" backing up the version or exit? Y/n ( Y to "
|
||||||
"continue without backing up. N to exit )", default="n")
|
"continue without backing up. N to exit )", default="n")
|
||||||
|
|
||||||
fabric_ops.run("rm -Rf {project_path}/{project_name}".format(
|
fabric_ops.run("rm -Rf {project_path}/{project_base}".format(
|
||||||
project_name=project_name,
|
project_base=project_base,
|
||||||
project_path=project_path))
|
project_path=project_path))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
# backup whatever is there
|
# backup whatever is there
|
||||||
fabric_ops.run("mv {project_path}/{project_name}"
|
fabric_ops.run("mv {project_path}/{project_base}"
|
||||||
" {project_path}/{project_name}.old".format(
|
" {project_path}/{project_base}.old".format(
|
||||||
project_name=project_name,
|
project_base=project_base,
|
||||||
project_path=project_path))
|
project_path=project_path))
|
||||||
|
|
||||||
with virtualenv():
|
with virtualenv():
|
||||||
fabric_ops.run(django_cmd)
|
fabric_ops.run(django_cmd)
|
||||||
|
|
||||||
django_path = "{project_path}/{project_name}".format(
|
django_path = "{project_path}/{project_base}".format(
|
||||||
project_name=configuration.project.name, project_path=project_path)
|
project_base=project_base, project_path=project_path)
|
||||||
|
|
||||||
fabric_ops.run("mkdir %s/_settings" % django_path)
|
fabric_ops.run("mkdir %s/_settings" % django_path)
|
||||||
fabric_ops.run("touch %s/_settings/__init__.py" % django_path)
|
fabric_ops.run("touch %s/_settings/__init__.py" % django_path)
|
||||||
|
|
@ -524,9 +527,10 @@ def generate_scripts(template_name, make_copy=False):
|
||||||
if env.debug:
|
if env.debug:
|
||||||
logger = loggify("django", "generate_scripts")
|
logger = loggify("django", "generate_scripts")
|
||||||
|
|
||||||
project_name = configuration.project.name
|
project_base = configuration.paths.django.settings.base
|
||||||
project_branch = configuration.project.branch
|
project_branch = configuration.project.branch
|
||||||
project_path = configuration.paths.django.root
|
project_path = configuration.paths.django.root
|
||||||
|
project_name = configuration.project.name
|
||||||
|
|
||||||
secret_key = generate_secret_key()
|
secret_key = generate_secret_key()
|
||||||
|
|
||||||
|
|
@ -538,19 +542,20 @@ def generate_scripts(template_name, make_copy=False):
|
||||||
|
|
||||||
context = dict()
|
context = dict()
|
||||||
context['project_name'] = project_name
|
context['project_name'] = project_name
|
||||||
|
context['project_base'] = project_base
|
||||||
context['project_branch'] = project_branch
|
context['project_branch'] = project_branch
|
||||||
context['secret_key'] = secret_key
|
context['secret_key'] = secret_key
|
||||||
context['paths_tools_fabric'] = configuration.paths.tools.fabric
|
context['paths_tools_fabric'] = configuration.paths.tools.fabric
|
||||||
|
|
||||||
copy_path = "{project_path}/{project_name}".format(
|
copy_path = "{project_path}/{project_base}".format(
|
||||||
project_path=project_path,
|
project_path=project_path,
|
||||||
project_name=project_name)
|
project_base=project_base)
|
||||||
|
|
||||||
if template_name == 'local':
|
if template_name == 'local':
|
||||||
|
|
||||||
copy_path = "{project_path}/{project_name}/_settings".format(
|
copy_path = "{project_path}/{project_base}/_settings".format(
|
||||||
project_path=project_path,
|
project_path=project_path,
|
||||||
project_name=project_name)
|
project_base=project_base)
|
||||||
build_name = "%s.py" % project_branch
|
build_name = "%s.py" % project_branch
|
||||||
|
|
||||||
# generate the local generate scripts
|
# generate the local generate scripts
|
||||||
|
|
@ -558,9 +563,9 @@ def generate_scripts(template_name, make_copy=False):
|
||||||
|
|
||||||
elif template_name == 'local.generated':
|
elif template_name == 'local.generated':
|
||||||
|
|
||||||
copy_path = "{project_path}/{project_name}/_settings".format(
|
copy_path = "{project_path}/{project_base}/_settings".format(
|
||||||
project_path=project_path,
|
project_path=project_path,
|
||||||
project_name=project_name)
|
project_base=project_base)
|
||||||
build_name = "%s_generated.py" % project_branch
|
build_name = "%s_generated.py" % project_branch
|
||||||
|
|
||||||
# add extra local specfic context variables
|
# add extra local specfic context variables
|
||||||
|
|
@ -622,7 +627,7 @@ def generate_scripts(template_name, make_copy=False):
|
||||||
if env.debug:
|
if env.debug:
|
||||||
logger.debug("template_name : %s" % template_name)
|
logger.debug("template_name : %s" % template_name)
|
||||||
logger.debug("project_branch : %s" % project_branch)
|
logger.debug("project_branch : %s" % project_branch)
|
||||||
logger.debug("project_name : %s" % project_name)
|
logger.debug("project_base : %s" % project_base)
|
||||||
logger.debug("build_path : %s" % build_path)
|
logger.debug("build_path : %s" % build_path)
|
||||||
logger.debug("files_path : %s" % files_path)
|
logger.debug("files_path : %s" % files_path)
|
||||||
logger.debug("files_name : %s" % files_name)
|
logger.debug("files_name : %s" % files_name)
|
||||||
|
|
@ -655,7 +660,7 @@ def generate_scripts(template_name, make_copy=False):
|
||||||
fabric_ops.run(copy_cmd)
|
fabric_ops.run(copy_cmd)
|
||||||
|
|
||||||
print("\n\n------------------------------")
|
print("\n\n------------------------------")
|
||||||
print("project_name : %s" % project_name)
|
print("project_base : %s" % project_base)
|
||||||
print("project_branch : %s" % project_branch)
|
print("project_branch : %s" % project_branch)
|
||||||
print("project_path : %s" % project_path)
|
print("project_path : %s" % project_path)
|
||||||
print("template_name : %s" % template_name)
|
print("template_name : %s" % template_name)
|
||||||
|
|
@ -855,7 +860,7 @@ def edit(param='help'):
|
||||||
project_branch = configuration.project.branch
|
project_branch = configuration.project.branch
|
||||||
project_path = configuration.paths.django.root
|
project_path = configuration.paths.django.root
|
||||||
|
|
||||||
project_settings_dir = configuration.project.django.settings_folder
|
project_settings_dir = configuration.paths.django.settings.base
|
||||||
|
|
||||||
django_path = "{project_path}/{project_settings_dir}".format(
|
django_path = "{project_path}/{project_settings_dir}".format(
|
||||||
project_path=project_path,
|
project_path=project_path,
|
||||||
|
|
|
||||||
|
|
@ -233,32 +233,8 @@ def get_config(branchname):
|
||||||
|
|
||||||
dataobject.project.sudo = config['project']['sudo']
|
dataobject.project.sudo = config['project']['sudo']
|
||||||
|
|
||||||
#
|
|
||||||
# django settings directory
|
|
||||||
|
|
||||||
# NOTE:
|
|
||||||
# this is a tricky problem, because sometimes the project.name will NOT
|
|
||||||
# be what I originally set the settings folder name to. For example, I
|
|
||||||
# created a project named 'raquelsanchez' but then the production url was
|
|
||||||
# set to 'raquelsanchezart', well, those two names don't match, and I don't
|
|
||||||
# feel like going through the complication of changing the wsgi files and
|
|
||||||
# folder names for the settings directory.
|
|
||||||
#
|
|
||||||
# so over here, we check to see if django.settings_folder is the same as
|
|
||||||
# project.name, if it is, great, if not we set it to whatever is in
|
|
||||||
# config.django.settings_folder
|
|
||||||
|
|
||||||
dataobject.project.addbranch('django')
|
dataobject.project.addbranch('django')
|
||||||
|
|
||||||
# this is the default name for the django settings_dir
|
|
||||||
|
|
||||||
dataobject.project.django.settings_folder = \
|
|
||||||
config['project']['name']
|
|
||||||
|
|
||||||
if 'settings_folder' in config['django']:
|
|
||||||
dataobject.project.django.settings_folder = \
|
|
||||||
config['django']['settings_folder']
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# allowed_hosts are the ip addresses and hostnames
|
# allowed_hosts are the ip addresses and hostnames
|
||||||
# that this instance is allowed to run on
|
# that this instance is allowed to run on
|
||||||
|
|
@ -400,9 +376,35 @@ def get_config(branchname):
|
||||||
|
|
||||||
dataobject.paths.django.addbranch('settings')
|
dataobject.paths.django.addbranch('settings')
|
||||||
|
|
||||||
|
#
|
||||||
|
# django settings directory
|
||||||
|
|
||||||
|
# NOTE:
|
||||||
|
# this is a tricky problem, because sometimes the project.name will NOT
|
||||||
|
# be what I originally set the settings folder name to. For example, I
|
||||||
|
# created a project named 'raquelsanchez' but then the production url was
|
||||||
|
# set to 'raquelsanchezart', well, those two names don't match, and I don't
|
||||||
|
# feel like going through the complication of changing the wsgi files and
|
||||||
|
# folder names for the settings directory.
|
||||||
|
#
|
||||||
|
# so over here, we check to see if django.settings.base is the same as
|
||||||
|
# project.name, if it is, great, if not we set it to whatever is in
|
||||||
|
# config.django.settings.paths.base
|
||||||
|
|
||||||
|
# this is the default name for the django settings dir
|
||||||
|
|
||||||
|
dataobject.paths.django.settings.base = \
|
||||||
|
config['project']['name']
|
||||||
|
|
||||||
|
if 'paths' in config['django']:
|
||||||
|
if 'settings' in config['django']['paths']:
|
||||||
|
if 'base' in config['django']['paths']['settings']:
|
||||||
|
dataobject.paths.django.settings.base = \
|
||||||
|
config['django']['paths']['settings']['base']
|
||||||
|
|
||||||
dataobject.paths.django.settings.root = os.path.join(
|
dataobject.paths.django.settings.root = os.path.join(
|
||||||
dataobject.paths.django.root,
|
dataobject.paths.django.root,
|
||||||
dataobject.project.django.settings_folder)
|
dataobject.paths.django.settings.base)
|
||||||
|
|
||||||
dataobject.paths.django.settings.local = os.path.join(
|
dataobject.paths.django.settings.local = os.path.join(
|
||||||
dataobject.paths.django.settings.root,
|
dataobject.paths.django.settings.root,
|
||||||
|
|
@ -421,8 +423,8 @@ def get_config(branchname):
|
||||||
dataobject.addbranch('imports')
|
dataobject.addbranch('imports')
|
||||||
|
|
||||||
dataobject.imports.settings = \
|
dataobject.imports.settings = \
|
||||||
"{projectname}.{settings_local}.{projectbranch}".format(
|
"{project_base}.{settings_local}.{projectbranch}".format(
|
||||||
projectname=dataobject.project.django.settings_folder,
|
project_base=dataobject.paths.django.settings.base,
|
||||||
settings_local=layout['paths']['django']['settings.local'],
|
settings_local=layout['paths']['django']['settings.local'],
|
||||||
projectbranch=dataobject.project.branch)
|
projectbranch=dataobject.project.branch)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ def upload():
|
||||||
# rest of the project
|
# rest of the project
|
||||||
|
|
||||||
context['django_settings_folder'] = \
|
context['django_settings_folder'] = \
|
||||||
configuration.project.django.settings_folder
|
configuration.paths.django.settings.base
|
||||||
|
|
||||||
context['server_path_virtualenv_bin'] = os.path.join(
|
context['server_path_virtualenv_bin'] = os.path.join(
|
||||||
configuration.paths.server.virtual, 'bin')
|
configuration.paths.server.virtual, 'bin')
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
LOCAL_SETTINGS = True # avoid recursive imports
|
LOCAL_SETTINGS = True # avoid recursive imports
|
||||||
BRANCH = '{{ project_branch }}'
|
BRANCH = '{{ project_branch }}'
|
||||||
|
|
||||||
from {{ project_name }}.settings import *
|
from {{ project_base }}.settings import *
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
LOCAL_SETTINGS = True # avoid recursive imports
|
LOCAL_SETTINGS = True # avoid recursive imports
|
||||||
|
|
||||||
from {{ project_name }}._settings.{{ project_branch }}_generated import *
|
from {{ project_base }}._settings.{{ project_branch }}_generated import *
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ MIDDLEWARE = [
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = '{{ project_name }}.urls'
|
ROOT_URLCONF = '{{ project_base }}.urls'
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
|
|
@ -82,7 +82,7 @@ TEMPLATES = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
|
WSGI_APPLICATION = '{{ project_base }}.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import os
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}._settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_base }}._settings")
|
||||||
|
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
LOCAL_SETTINGS = True # avoid recursive imports
|
LOCAL_SETTINGS = True # avoid recursive imports
|
||||||
BRANCH = '{{ project_branch }}'
|
BRANCH = '{{ project_branch }}'
|
||||||
|
|
||||||
from {{ project_name }}.settings import *
|
from {{ project_base }}.settings import *
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
LOCAL_SETTINGS = True # avoid recursive imports
|
LOCAL_SETTINGS = True # avoid recursive imports
|
||||||
|
|
||||||
from {{ project_name }}._settings.{{ project_branch }}_generated import *
|
from {{ project_base }}._settings.{{ project_branch }}_generated import *
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import os
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}._settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_base }}._settings")
|
||||||
|
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ django:
|
||||||
host: DJANGO_IP
|
host: DJANGO_IP
|
||||||
port: DJANGO_PORT
|
port: DJANGO_PORT
|
||||||
allowed_hosts: [127.0.0.1, 'PROJECT_NAME.BRANCH_EXT',]
|
allowed_hosts: [127.0.0.1, 'PROJECT_NAME.BRANCH_EXT',]
|
||||||
|
settings:
|
||||||
|
folder: "core"
|
||||||
docker:
|
docker:
|
||||||
database:
|
database:
|
||||||
env: {name: POSTGRES_DB, pass: POSTGRES_PASSWORD, user: POSTGRES_USER}
|
env: {name: POSTGRES_DB, pass: POSTGRES_PASSWORD, user: POSTGRES_USER}
|
||||||
|
|
@ -38,11 +40,11 @@ maintenance:
|
||||||
#
|
#
|
||||||
# uncomment if you have and plan to use coverage python package
|
# uncomment if you have and plan to use coverage python package
|
||||||
#
|
#
|
||||||
# coverage:
|
coverage:
|
||||||
# config: setup.cfg
|
config: setup.cfg
|
||||||
# paths:
|
paths:
|
||||||
# root: share/coverage
|
root: share/coverage
|
||||||
# html: htmlcov
|
html: htmlcov
|
||||||
|
|
||||||
media:
|
media:
|
||||||
paths: {dynamic: dynamic, root: public/media, static: static}
|
paths: {dynamic: dynamic, root: public/media, static: static}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue