From bd5ea38446bc784143238487e43bd07fc51bc10d Mon Sep 17 00:00:00 2001 From: Adarnof Date: Wed, 21 Feb 2018 22:32:23 -0500 Subject: [PATCH] Add a warning against editing base.py Beautify local.py by removing big block comments. Move some settings back to base.py which don't need to be in local.py --- .../project_name/settings/base.py | 54 +++++--------- .../project_name/settings/local.py | 70 +++++-------------- 2 files changed, 35 insertions(+), 89 deletions(-) diff --git a/allianceauth/project_template/project_name/settings/base.py b/allianceauth/project_template/project_name/settings/base.py index 630121d8..f59a3eac 100644 --- a/allianceauth/project_template/project_name/settings/base.py +++ b/allianceauth/project_template/project_name/settings/base.py @@ -1,14 +1,10 @@ # -*- coding: UTF-8 -*- """ -Django settings for alliance_auth project. +DO NOT EDIT THIS FILE -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/ +This settings file contains everything needed for Alliance Auth projects to function. +It gets overwritten by the 'allianceauth update' command. +If you wish to make changes, overload the setting in your project's settings file (local.py). """ import os @@ -17,7 +13,6 @@ 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', @@ -38,6 +33,8 @@ INSTALLED_APPS = [ 'allianceauth.thirdparty.navhelper', ] +SECRET_KEY = "wow I'm a really bad default secret key" + # Celery configuration BROKER_URL = 'redis://localhost:6379/0' CELERYBEAT_SCHEDULER = "django_celery_beat.schedulers.DatabaseScheduler" @@ -90,7 +87,7 @@ LANGUAGES = ( TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [os.path.join(PROJECT_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -148,8 +145,11 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ - STATIC_URL = '/static/' +STATICFILES_DIRS = [ + os.path.join(PROJECT_DIR, 'static'), +] +STATIC_ROOT = os.path.join(BASE_DIR, 'static') # Bootstrap messaging css workaround MESSAGE_TAGS = { @@ -178,40 +178,20 @@ DATABASES = { 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 +LOGIN_URL = 'auth_login_user' # default destination when logging in if no redirect specified +LOGIN_REDIRECT_URL = 'authentication:dashboard' # 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' + +# scopes required on new tokens when logging in. Cannot be blank. LOGIN_TOKEN_SCOPES = ['esi-characters.read_opportunities.v1'] + +# number of days email verification links are valid for 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, diff --git a/allianceauth/project_template/project_name/settings/local.py b/allianceauth/project_template/project_name/settings/local.py index 7caba5b8..412b3016 100644 --- a/allianceauth/project_template/project_name/settings/local.py +++ b/allianceauth/project_template/project_name/settings/local.py @@ -1,49 +1,29 @@ +# Every setting in base.py can be overloaded by redefining it here. from .base import * -# These are required for Django to function properly +# These are required for Django to function properly. Don't touch. ROOT_URLCONF = '{{ project_name }}.urls' WSGI_APPLICATION = '{{ project_name }}.wsgi.application' -STATICFILES_DIRS = [ - os.path.join(PROJECT_DIR, 'static'), -] -STATIC_ROOT = "/var/www/{{ project_name }}/static/" -TEMPLATES[0]['DIRS'] += [os.path.join(PROJECT_DIR, 'templates')] SECRET_KEY = '{{ secret_key }}' -####################################### -# Site Name # -####################################### -# Change this to change the name of the -# auth site displayed in page titles -# and the site header. -####################################### +# This is where css/images will be placed for your webserver to read +STATIC_ROOT = "/var/www/{{ project_name }}/static/" + +# Change this to change the name of the auth site displayed +# in page titles and the site header. SITE_NAME = '{{ project_name }}' -####################################### -# Debug Mode # -####################################### -# Change this to enable/disable debug -# mode, which displays useful error -# messages but can leak sensitive data. -####################################### +# Change this to enable/disable debug mode, which displays +# useful error messages but can leak sensitive data. DEBUG = False -####################################### -# Additional Applications # -####################################### # Add any additional apps to this list. -####################################### INSTALLED_APPS += [ ] -####################################### -# Database Settings # -####################################### -# Uncomment and change the database name -# and credentials to use MySQL/MariaDB. -# Leave commented to use sqlite3 -####################################### +# Uncomment by removing the """ and change the database name and +# credentials to use MySQL/MariaDB. Leave commented to use sqlite3 """ DATABASES['default'] = { 'ENGINE': 'django.db.backends.mysql', @@ -55,32 +35,18 @@ DATABASES['default'] = { } """ -####################################### -# 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 -# Select all available esi- scopes. -####################################### +# 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 +# Select all available scopes starting with esi- ESI_SSO_CLIENT_ID = '' ESI_SSO_CLIENT_SECRET = '' ESI_SSO_CALLBACK_URL = '' -####################################### -# Email Settings # -####################################### -# Alliance Auth validates emails before -# new users can log in. -# It's recommended to use a free service -# like SparkPost or Mailgun to send email. +# Emails are validated before new users can log in. +# It's recommended to use a free service like SparkPost or Mailgun to send email. # https://www.sparkpost.com/docs/integrations/django/ -# Set the default from email to something -# like 'noreply@example.com' -####################################### +# Set the default from email to something like 'noreply@example.com' EMAIL_HOST = '' EMAIL_PORT = 587 EMAIL_HOST_USER = ''