diff --git a/allianceauth/settings/__init__.py b/allianceauth/project_template/__init__.py similarity index 100% rename from allianceauth/settings/__init__.py rename to allianceauth/project_template/__init__.py diff --git a/allianceauth/project_template/manage.py b/allianceauth/project_template/manage.py new file mode 100644 index 00000000..843d8a7d --- /dev/null +++ b/allianceauth/project_template/manage.py @@ -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) diff --git a/allianceauth/project_template/project_name/__init__.py b/allianceauth/project_template/project_name/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/allianceauth/log/.gitignore b/allianceauth/project_template/project_name/log/.gitignore similarity index 100% rename from allianceauth/log/.gitignore rename to allianceauth/project_template/project_name/log/.gitignore diff --git a/allianceauth/project_template/project_name/settings/__init__.py b/allianceauth/project_template/project_name/settings/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/allianceauth/settings/base.py b/allianceauth/project_template/project_name/settings/base.py similarity index 92% rename from allianceauth/settings/base.py rename to allianceauth/project_template/project_name/settings/base.py index 1630d76a..20f52cb2 100644 --- a/allianceauth/settings/base.py +++ b/allianceauth/project_template/project_name/settings/base.py @@ -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] diff --git a/allianceauth/project_template/project_name/settings/local.py b/allianceauth/project_template/project_name/settings/local.py new file mode 100644 index 00000000..614afede --- /dev/null +++ b/allianceauth/project_template/project_name/settings/local.py @@ -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 # +###################################### diff --git a/allianceauth/project_template/project_name/static/.gitkeep b/allianceauth/project_template/project_name/static/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/allianceauth/project_template/project_name/templates/.gitkeep b/allianceauth/project_template/project_name/templates/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/allianceauth/project_template/project_name/urls.py b/allianceauth/project_template/project_name/urls.py new file mode 100644 index 00000000..ecff76d8 --- /dev/null +++ b/allianceauth/project_template/project_name/urls.py @@ -0,0 +1,6 @@ +from django.conf.urls import include, url +from allianceauth import urls + +urlpatterns = [ + url(r'', include(urls)), +] diff --git a/allianceauth/project_template/project_name/wsgi.py b/allianceauth/project_template/project_name/wsgi.py new file mode 100644 index 00000000..e13622f3 --- /dev/null +++ b/allianceauth/project_template/project_name/wsgi.py @@ -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() diff --git a/allianceauth/wsgi.py b/allianceauth/wsgi.py deleted file mode 100644 index 39a09438..00000000 --- a/allianceauth/wsgi.py +++ /dev/null @@ -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() diff --git a/manage.py b/manage.py index 7eec003b..6afed5b2 100644 --- a/manage.py +++ b/manage.py @@ -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: diff --git a/tests/settings.py b/tests/settings.py index 01d68dcd..f653c0e3 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -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'}