mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-10 00:56:19 +01:00
Create project template for deployment.
This commit is contained in:
0
allianceauth/project_template/__init__.py
Normal file
0
allianceauth/project_template/__init__.py
Normal file
22
allianceauth/project_template/manage.py
Normal file
22
allianceauth/project_template/manage.py
Normal 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)
|
||||
2
allianceauth/project_template/project_name/log/.gitignore
vendored
Normal file
2
allianceauth/project_template/project_name/log/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
!.gitignore
|
||||
*
|
||||
258
allianceauth/project_template/project_name/settings/base.py
Normal file
258
allianceauth/project_template/project_name/settings/base.py
Normal file
@@ -0,0 +1,258 @@
|
||||
# -*- coding: UTF-8 -*-
|
||||
"""
|
||||
Django settings for alliance_auth project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 1.10.1.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/1.10/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/1.10/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.contrib import messages
|
||||
from celery.schedules import crontab
|
||||
|
||||
INSTALLED_APPS = [
|
||||
# Core apps - required to function
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.humanize',
|
||||
'django_celery_beat',
|
||||
'bootstrapform',
|
||||
'sortedm2m',
|
||||
'esi',
|
||||
'allianceauth',
|
||||
'allianceauth.authentication',
|
||||
'allianceauth.services',
|
||||
'allianceauth.eveonline',
|
||||
'allianceauth.groupmanagement',
|
||||
'allianceauth.notifications',
|
||||
'allianceauth.thirdparty.navhelper',
|
||||
]
|
||||
|
||||
# Celery configuration
|
||||
BROKER_URL = 'redis://localhost:6379/0'
|
||||
CELERYBEAT_SCHEDULER = "django_celery_beat.schedulers.DatabaseScheduler"
|
||||
CELERYBEAT_SCHEDULE = {
|
||||
'esi_cleanup_callbackredirect': {
|
||||
'task': 'esi.tasks.cleanup_callbackredirect',
|
||||
'schedule': crontab(hour='*/4'),
|
||||
},
|
||||
'esi_cleanup_token': {
|
||||
'task': 'esi.tasks.cleanup_token',
|
||||
'schedule': crontab(day_of_month='*/1'),
|
||||
},
|
||||
'run_model_update': {
|
||||
'task': 'allianceauth.eveonline.tasks.run_model_update',
|
||||
'schedule': crontab(minute=0, hour="*/6"),
|
||||
},
|
||||
'check_all_character_ownership': {
|
||||
'task': 'allianceauth.authentication.tasks.check_all_character_ownership',
|
||||
'schedule': crontab(hour='*/4'),
|
||||
}
|
||||
}
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
BASE_DIR = os.path.dirname(PROJECT_DIR)
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'allianceauth.urls'
|
||||
|
||||
LOCALE_PATHS = (
|
||||
os.path.join(BASE_DIR, 'locale/'),
|
||||
)
|
||||
|
||||
ugettext = lambda s: s
|
||||
LANGUAGES = (
|
||||
('en', ugettext('English')),
|
||||
('de', ugettext('German')),
|
||||
)
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.template.context_processors.i18n',
|
||||
'django.template.context_processors.media',
|
||||
'django.template.context_processors.static',
|
||||
'django.template.context_processors.tz',
|
||||
'allianceauth.notifications.context_processors.user_notification_count',
|
||||
'allianceauth.groupmanagement.context_processors.can_manage_groups',
|
||||
'allianceauth.context_processors.auth_settings',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'allianceauth.wsgi.application'
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
AUTHENTICATION_BACKENDS = ['allianceauth.authentication.backends.StateBackend',
|
||||
'django.contrib.auth.backends.ModelBackend']
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/1.10/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/1.10/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, "static")
|
||||
|
||||
# Bootstrap messaging css workaround
|
||||
MESSAGE_TAGS = {
|
||||
messages.ERROR: 'danger'
|
||||
}
|
||||
|
||||
CACHES = {
|
||||
"default": {
|
||||
"BACKEND": "redis_cache.RedisCache",
|
||||
"LOCATION": "localhost:6379",
|
||||
"OPTIONS": {
|
||||
"DB": 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECRET_KEY = 'this is a very bad secret key you should change'
|
||||
DEBUG = True
|
||||
ALLOWED_HOSTS = ['*']
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': str(os.path.join(PROJECT_DIR, 'alliance_auth.sqlite3')),
|
||||
},
|
||||
}
|
||||
|
||||
SITE_NAME = 'Alliance Auth'
|
||||
|
||||
#################
|
||||
# Login Settings
|
||||
#################
|
||||
# LOGIN_REDIRECT_URL - default destination when logging in if no redirect specified
|
||||
# LOGOUT_REDIRECT_URL - destination after logging out
|
||||
# Both of these redirects accept values as per the django redirect shortcut
|
||||
# https://docs.djangoproject.com/en/1.11/topics/http/shortcuts/#redirect
|
||||
# - url names eg 'authentication:dashboard'
|
||||
# - relative urls eg '/dashboard'
|
||||
# - absolute urls eg 'http://example.com/dashboard'
|
||||
# LOGIN_TOKEN_SCOPES - scopes required on new tokens when logging in. Cannot be blank.
|
||||
# ACCOUNT_ACTIVATION_DAYS - number of days email verification tokens are valid for
|
||||
##################
|
||||
LOGIN_URL = 'auth_login_user'
|
||||
LOGIN_REDIRECT_URL = 'authentication:dashboard'
|
||||
LOGOUT_REDIRECT_URL = 'authentication:dashboard'
|
||||
LOGIN_TOKEN_SCOPES = ['esi-characters.read_opportunities.v1']
|
||||
ACCOUNT_ACTIVATION_DAYS = 1
|
||||
|
||||
#####################################################
|
||||
##
|
||||
## Logging Configuration
|
||||
##
|
||||
#####################################################
|
||||
# Set log_file and console level to desired state:
|
||||
# DEBUG - basically stack trace, explains every step
|
||||
# INFO - model creation, deletion, updates, etc
|
||||
# WARN - unexpected function outcomes that do not impact user
|
||||
# ERROR - unexcpeted function outcomes which prevent user from achieving desired outcome
|
||||
# EXCEPTION - something critical went wrong, unhandled
|
||||
#####################################
|
||||
# Recommended level for log_file is INFO, console is DEBUG
|
||||
# Change log level of individual apps below to narrow your debugging
|
||||
#####################################
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
|
||||
'datefmt': "%d/%b/%Y %H:%M:%S"
|
||||
},
|
||||
'simple': {
|
||||
'format': '%(levelname)s %(message)s'
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'log_file': {
|
||||
'level': 'INFO', # edit this line to change logging level to file
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'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
|
||||
},
|
||||
'console': {
|
||||
'level': 'DEBUG', # edit this line to change logging level to console
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
'notifications': { # creates notifications for users with logging_notifications permission
|
||||
'level': 'ERROR', # edit this line to change logging level to notifications
|
||||
'class': 'allianceauth.notifications.handlers.NotificationHandler',
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'allianceauth': {
|
||||
'handlers': ['log_file', 'console', 'notifications'],
|
||||
'level': 'DEBUG',
|
||||
},
|
||||
'django': {
|
||||
'handlers': ['log_file', 'console'],
|
||||
'level': 'ERROR',
|
||||
},
|
||||
}
|
||||
}
|
||||
36
allianceauth/project_template/project_name/settings/local.py
Normal file
36
allianceauth/project_template/project_name/settings/local.py
Normal 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 #
|
||||
######################################
|
||||
6
allianceauth/project_template/project_name/urls.py
Normal file
6
allianceauth/project_template/project_name/urls.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.conf.urls import include, url
|
||||
from allianceauth import urls
|
||||
|
||||
urlpatterns = [
|
||||
url(r'', include(urls)),
|
||||
]
|
||||
14
allianceauth/project_template/project_name/wsgi.py
Normal file
14
allianceauth/project_template/project_name/wsgi.py
Normal 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()
|
||||
Reference in New Issue
Block a user