Create project template for deployment.

This commit is contained in:
Adarnof 2017-10-05 00:33:18 -04:00
parent f121ed4062
commit c68574efc3
14 changed files with 85 additions and 39 deletions

View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name}}.settings.local")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)

View File

@ -61,7 +61,8 @@ CELERYBEAT_SCHEDULE = {
}
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
@ -172,7 +173,7 @@ ALLOWED_HOSTS = ['*']
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': str(os.path.join(BASE_DIR, 'alliance_auth.sqlite')),
'NAME': str(os.path.join(PROJECT_DIR, 'alliance_auth.sqlite3')),
},
}
@ -228,7 +229,7 @@ LOGGING = {
'log_file': {
'level': 'INFO', # edit this line to change logging level to file
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(BASE_DIR, 'log/allianceauth.log'),
'filename': os.path.join(PROJECT_DIR, 'log/allianceauth.log'),
'formatter': 'verbose',
'maxBytes': 1024 * 1024 * 5, # edit this line to change max log file size
'backupCount': 5, # edit this line to change number of log backups
@ -255,14 +256,3 @@ LOGGING = {
},
}
}
def add_auth_apps(APPS):
"""
Merges required auth apps with a list of custom user apps for project settings.
Leaves order of passed INSTALLED_APPS unchanged (passed apps come first) to allow overriding templates/static/etc
https://docs.djangoproject.com/en/2.0/ref/settings/#installed-apps
:param APPS: INSTALLED_APPS list
:return: Merged INSTALLED_APPS
"""
APPS += [app for app in INSTALLED_APPS if app not in APPS]

View File

@ -0,0 +1,36 @@
from .base import *
# These are required for Django to function properly
ROOT_URLCONF = '{{ project_name }}.urls'
WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
STATICFILES_DIRS = [
os.path.join(PROJECT_DIR, 'static'),
]
TEMPLATES[0]['DIRS'] += [os.path.join(PROJECT_DIR, 'templates')]
SECRET_KEY = '{{ secret_key }}'
# Change this to change the name of the auth site
SITE_NAME = '{{ project_name }}'
# Change this to enable/disable debug mode
DEBUG = False
######################################
# SSO Settings #
######################################
# Register an application at
# https://developers.eveonline.com
# and fill out these settings.
# Be sure to set the callback URL to
# https://example.com/sso/callback
# substituting your domain for example.com
######################################
ESI_SSO_CLIENT_ID = ''
ESI_SSO_CLIENT_SECRET = ''
ESI_SSO_CALLBACK_URL = ''
######################################
# Add any custom settings below here #
######################################

View File

@ -0,0 +1,6 @@
from django.conf.urls import include, url
from allianceauth import urls
urlpatterns = [
url(r'', include(urls)),
]

View File

@ -0,0 +1,14 @@
"""
WSGI config for {{ project_name }} project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings.local")
application = get_wsgi_application()

View File

@ -1,20 +0,0 @@
"""
WSGI config for alliance_auth project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "allianceauth.settings.base")
# virtualenv wrapper, uncomment below to activate
# activate_env=os.path.join(os.path.dirname(os.path.abspath(__file__)), 'env/bin/activate_this.py')
# execfile(activate_env, dict(__file__=activate_env))
application = get_wsgi_application()

View File

@ -3,7 +3,7 @@ import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "allianceauth.settings.base")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "allianceauth.project_template.project_name.settings.base")
try:
from django.core.management import execute_from_command_line
except ImportError:

View File

@ -2,7 +2,7 @@
Alliance Auth Test Suite Django settings.
"""
from allianceauth.settings.base import *
from allianceauth.project_template.project_name.settings.base import *
# Use nose to run all tests
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
@ -16,7 +16,7 @@ NOSE_ARGS = [
# Celery configuration
CELERY_ALWAYS_EAGER = True # Forces celery to run locally for testing
INSTALLED_APPS = [
INSTALLED_APPS += [
'allianceauth.hrapplications',
'allianceauth.timerboard',
'allianceauth.srp',
@ -39,8 +39,6 @@ INSTALLED_APPS = [
'django_nose',
]
add_auth_apps(INSTALLED_APPS)
ROOT_URLCONF = 'tests.urls'
CACHES['default'] = {'BACKEND': 'django.core.cache.backends.db.DatabaseCache'}