From 111105d48b96200f50eeca6cb1fccdcd5aa080e8 Mon Sep 17 00:00:00 2001 From: Adarnof Date: Wed, 4 Oct 2017 23:12:49 -0400 Subject: [PATCH] Restructure settings (#882) * Refactor settings into importable base. User deployment should use 'from allianceauth.settings.base import *' in their project settings. * Restructure tests folder. Remove DOMAIN setting. Use localhost for services revoked emails. * Add missing python3.4 typing requirement typing is included python3.5+ * Remove legacy setup comments Remove legacy update script --- .gitattributes | 1 - .gitignore | 8 - alliance_auth/.gitignore | 2 - alliance_auth/settings.py.example | 565 ------------------ allianceauth/context_processors.py | 1 - allianceauth/log/.gitignore | 2 + .../services/modules/phpbb3/manager.py | 2 +- allianceauth/services/modules/smf/manager.py | 2 +- .../settings}/__init__.py | 0 allianceauth/settings/base.py | 268 +++++++++ allianceauth/srp/managers.py | 4 +- {alliance_auth => allianceauth}/wsgi.py | 2 +- manage.py | 2 +- runtests.py | 2 +- setup.py | 5 +- test_allianceauth/settings.py | 408 ------------- {test_allianceauth => tests}/__init__.py | 0 tests/settings.py | 195 ++++++ {test_allianceauth => tests}/urls.py | 1 + {test_allianceauth => tests}/views.py | 0 update.sh | 4 - 21 files changed, 475 insertions(+), 999 deletions(-) delete mode 100644 .gitattributes delete mode 100644 alliance_auth/.gitignore delete mode 100644 alliance_auth/settings.py.example create mode 100644 allianceauth/log/.gitignore rename {alliance_auth => allianceauth/settings}/__init__.py (100%) create mode 100644 allianceauth/settings/base.py rename {alliance_auth => allianceauth}/wsgi.py (87%) delete mode 100644 test_allianceauth/settings.py rename {test_allianceauth => tests}/__init__.py (100%) create mode 100644 tests/settings.py rename {test_allianceauth => tests}/urls.py (99%) rename {test_allianceauth => tests}/views.py (100%) delete mode 100755 update.sh diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 9369413a..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*/*.py.example linguist-language=Python diff --git a/.gitignore b/.gitignore index c1610880..f183222b 100644 --- a/.gitignore +++ b/.gitignore @@ -53,20 +53,12 @@ docs/_build/ # PyBuilder target/ -.vagrant/ -alliance_auth/settings.py *Thumbs.db nginx_config.txt -# custom staticfiles -static/* - #celerybeat *.pid celerybeat-schedule #pycharm .idea/* - -#log folder -log/* diff --git a/alliance_auth/.gitignore b/alliance_auth/.gitignore deleted file mode 100644 index 7c24c40c..00000000 --- a/alliance_auth/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/settings.py -!/*.example diff --git a/alliance_auth/settings.py.example b/alliance_auth/settings.py.example deleted file mode 100644 index 1914632c..00000000 --- a/alliance_auth/settings.py.example +++ /dev/null @@ -1,565 +0,0 @@ -# -*- 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', - - - # Optional apps - remove if not desired - 'allianceauth.corputils', - 'allianceauth.hrapplications', - 'allianceauth.timerboard', - 'allianceauth.srp', - 'allianceauth.optimer', - 'allianceauth.fleetup', - 'allianceauth.fleetactivitytracking', - 'allianceauth.permissions_tool', - - # Services - remove if not used - 'allianceauth.services.modules.mumble', - 'allianceauth.services.modules.discord', - 'allianceauth.services.modules.discourse', - 'allianceauth.services.modules.ips4', - 'allianceauth.services.modules.market', - 'allianceauth.services.modules.openfire', - 'allianceauth.services.modules.seat', - 'allianceauth.services.modules.smf', - 'allianceauth.services.modules.phpbb3', - 'allianceauth.services.modules.xenforo', - 'allianceauth.services.modules.teamspeak3', -] - -##################################################### -## -## Django Project Configuration -## -##################################################### -# Don't touch unless you know what you're doing. -# Scroll down for Auth Configuration -##################################################### - -# 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, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - -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.context_processors.auth_settings', - 'allianceauth.notifications.context_processors.user_notification_count', - 'allianceauth.groupmanagement.context_processors.can_manage_groups', - ], - }, - }, -] - -WSGI_APPLICATION = 'alliance_auth.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'] -LOGIN_URL = 'auth_login_user' - -# 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, - } - } -} - -##################################################### -## -## Auth Configuration -## -##################################################### - -############################### -# Required Django Settings -############################### -# SECRET_KEY - Random alphanumeric string for cryptographic signing -# http://www.miniwebtool.com/django-secret-key-generator/ -# DEBUG - True to display stack traces when errors are encountered. -# Set this False once auth is installed and working for security. -# ALLOWED_HOSTS - A list of hosts to serve content on. Wildcards accepted. -# Requests for hosts not listed here will be rejected. -# Example: ['example.com', 'auth.example.com'] -# DATABASES - Auth database connection information. -################################ -SECRET_KEY = '' -DEBUG = True -ALLOWED_HOSTS = [] -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'alliance_auth', - 'USER': 'allianceserver', - 'PASSWORD': '', - 'HOST': '127.0.0.1', - 'PORT': '3306', - }, -} - -#################################### -# SITE_NAME - Name of the auth site. -#################################### -SITE_NAME = 'Alliance Auth' - -################# -# EMAIL SETTINGS -################# -# DEFAULT_FROM_EMAIL - no-reply email address -# DOMAIN - The Alliance Auth domain (or subdomain) address, no leading http:// -# EMAIL_HOST - SMTP Server URL -# EMAIL_PORT - SMTP Server PORT -# EMAIL_HOST_USER - Email Username (for gmail, the entire address) -# EMAIL_HOST_PASSWORD - Email Password -# EMAIL_USE_TLS - Set to use TLS encryption -################# -DEFAULT_FROM_EMAIL = 'no-reply@example.com' -DOMAIN = 'example.com' -EMAIL_HOST = 'smtp.gmail.com' -EMAIL_PORT = 587 -EMAIL_HOST_USER = '' -EMAIL_HOST_PASSWORD = '' -EMAIL_USE_TLS = True - -################### -# SSO Settings -################### -# Get client ID and client secret from registering an app at -# https://developers.eveonline.com/ -# Callback URL should be https://example.com/sso/callback -################### -ESI_SSO_CLIENT_ID = '' -ESI_SSO_CLIENT_SECRET = '' -ESI_SSO_CALLBACK_URL = '' - -################# -# 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.10/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_REDIRECT_URL = 'authentication:dashboard' -LOGOUT_REDIRECT_URL = 'authentication:dashboard' -LOGIN_TOKEN_SCOPES = ['esi-characters.read_opportunities.v1'] -ACCOUNT_ACTIVATION_DAYS = 1 - -##################################################### -## -## Service Configuration -## -##################################################### - -##################### -# Alliance Market -##################### -MARKET_URL = 'http://example.com/market' -MARKET_DB = { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'alliance_market', - 'USER': 'allianceserver-market', - 'PASSWORD': '', - 'HOST': '127.0.0.1', - 'PORT': '3306', -} - -######################## -# XenForo Configuration -######################## -XENFORO_ENDPOINT = 'example.com/api.php' -XENFORO_DEFAULT_GROUP = 0 -XENFORO_APIKEY = '' -##################### - -###################### -# Jabber Configuration -###################### -# JABBER_URL - Jabber address url, no leading http:// -# JABBER_PORT - Jabber service portal -# JABBER_SERVER - Jabber server url (server name, eg 'example.com'), no leading http:// -# OPENFIRE_ADDRESS - Address of the openfire admin console including port -# Please use http:// with 9090 or https:// with 9091 -# eg 'http://example.com:9090' or 'https://example.com:9091' -# OPENFIRE_SECRET_KEY - Openfire REST API secret key -# BROADCAST_USER - Broadcast user username (before @ sign) -# BROADCAST_USER_PASSWORD - Broadcast user password -# BROADCAST_SERVICE_NAME - Name of the Openfire service to broadcast to, usually "broadcast" -###################### -JABBER_URL = '' -JABBER_PORT = 5223 -JABBER_SERVER = '' -OPENFIRE_ADDRESS = '' -OPENFIRE_SECRET_KEY = '' -BROADCAST_USER = "broadcast" + "@" + JABBER_URL -BROADCAST_USER_PASSWORD = '' -BROADCAST_SERVICE_NAME = "broadcast" - -###################################### -# Mumble Configuration -###################################### -# MUMBLE_URL - Mumble server url, tolerates leading http://, mumble://, or none -# eg 'http://example.com', 'mumble://example.com', or 'example.com' -###################################### -MUMBLE_URL = '' - -###################################### -# PHPBB3 Configuration -###################################### -PHPBB3_URL = 'http://example.com/phpbb/' -PHPBB3_DB = { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'alliance_forum', - 'USER': 'allianceserver-phpbb3', - 'PASSWORD': '', - 'HOST': '127.0.0.1', - 'PORT': '3306', -} - -###################################### -# Teamspeak3 Configuration -###################################### -# TEAMSPEAK3_SERVER_IP - Teamspeak3 server ip -# TEAMSPEAK3_SERVER_PORT - Teamspeak3 server port -# TEAMSPEAK3_SERVERQUERY_USER - Teamspeak3 serverquery username -# TEAMSPEAK3_SERVERQUERY_PASSWORD - Teamspeak3 serverquery password -# TEAMSPEAK3_VIRTUAL_SERVER - Virtual server id -# TEAMSPEAK3_AUTHED_GROUP_ID - Default authed group id -# TEAMSPEAK3_PUBLIC_URL - teamspeak3 public url used for link creation -###################################### -TEAMSPEAK3_SERVER_IP = '127.0.0.1' -TEAMSPEAK3_SERVER_PORT = 10011 -TEAMSPEAK3_SERVERQUERY_USER = 'serveradmin' -TEAMSPEAK3_SERVERQUERY_PASSWORD = '' -TEAMSPEAK3_VIRTUAL_SERVER = 1 -TEAMSPEAK3_PUBLIC_URL = '' - -###################################### -# Discord Configuration -###################################### -# DISCORD_GUILD_ID - ID of the guild to manage -# DISCORD_BOT_TOKEN - OAuth token of the app bot user -# DISCORD_INVITE_CODE - Alphanumeric string invite code to the server -# Do not include the leading http://discord.gg/ -# DISCORD_APP_ID - OAuth app client ID -# DISCORD_APP_SECRET - OAuth app secret -# DISCORD_CALLBACK_URL - OAuth callback url -# Should be of the form 'http://example.com/discord/callback' -# DISCORD_SYNC_NAMES - Force discord nicknames to be set to eve char name -###################################### -DISCORD_GUILD_ID = '' -DISCORD_BOT_TOKEN = '' -DISCORD_INVITE_CODE = '' -DISCORD_APP_ID = '' -DISCORD_APP_SECRET = '' -DISCORD_CALLBACK_URL = '' -DISCORD_SYNC_NAMES = False - -###################################### -# Discourse Configuration -###################################### -# DISCOURSE_URL - Web address of the forums (no trailing slash). Include http:// -# DISCOURSE_API_USERNAME - API account username -# DISCOURSE_API_KEY - API Key -# DISCOURSE_SSO_SECRET - SSO secret key -###################################### -DISCOURSE_URL = '' -DISCOURSE_API_USERNAME = '' -DISCOURSE_API_KEY = '' -DISCOURSE_SSO_SECRET = '' - -##################################### -# IPS4 Configuration -##################################### -# IPS4_URL - Base URL of the IPS4 install (no trailing slash). Include http:// -##################################### -IPS4_URL = '' -IPS4_DB = { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'alliance_ips4', - 'USER': 'allianceserver-ips4', - 'PASSWORD': '', - 'HOST': '127.0.0.1', - 'PORT': '3306', -} - -##################################### -# SEAT Configuration -##################################### -# SEAT_URL - Base URL of the seat install (no trailing slash). Include http:// -# SEAT_XTOKEN - API key X-Token provided by SeAT -##################################### -SEAT_URL = '' -SEAT_XTOKEN = '' - -###################################### -# SMF Configuration -###################################### -# SMF_URL - Web address of the forums. Include leading http:// -###################################### -SMF_URL = '' -SMF_DB = { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'alliance_smf', - 'USER': 'allianceserver-smf', - 'PASSWORD': '', - 'HOST': '127.0.0.1', - 'PORT': '3306', -} - -###################################### -# Fleet-Up Configuration -###################################### -# FLEETUP_APP_KEY - The app key from http://fleet-up.com/Api/MyApps -# FLEETUP_USER_ID - The user id from http://fleet-up.com/Api/MyKeys -# FLEETUP_API_ID - The API id from http://fleet-up.com/Api/MyKeys -# FLEETUP_GROUP_ID - The id of the group you want to pull data from, see http://fleet-up.com/Api/Endpoints#groups_mygroupmemberships -###################################### -FLEETUP_APP_KEY = os.environ.get('AA_FLEETUP_APP_KEY', '') -FLEETUP_USER_ID = os.environ.get('AA_FLEETUP_USER_ID', '') -FLEETUP_API_ID = os.environ.get('AA_FLEETUP_API_ID', '') -FLEETUP_GROUP_ID = os.environ.get('AA_FLEETUP_GROUP_ID', '') - -##################################################### -## -## 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(BASE_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', - }, - 'celerytask': { - 'handlers': ['log_file', 'console', 'notifications'], - 'level': 'DEBUG', - }, - 'portal': { - 'handlers': ['log_file', 'console', 'notifications'], - 'level': 'DEBUG', - }, - 'registration': { - 'handlers': ['log_file', 'console', 'notifications'], - 'level': 'DEBUG', - }, - 'util': { - 'handlers': ['log_file', 'console', 'notifications'], - 'level': 'DEBUG', - }, - 'django': { - 'handlers': ['log_file', 'console'], - 'level': 'ERROR', - }, - } -} - -##################################################### -## -## Magic Block -## -##################################################### -# This block automagically inserts needed settings if -# certain services are installed. -# Don't touch. -######################################### - -# Conditionally add databases only if configured -if 'services.modules.phpbb3' in INSTALLED_APPS: - DATABASES['phpbb3'] = PHPBB3_DB -if 'services.modules.smf' in INSTALLED_APPS: - DATABASES['smf'] = SMF_DB -if 'services.modules.market' in INSTALLED_APPS: - DATABASES['market'] = MARKET_DB -if 'services.modules.ips4' in INSTALLED_APPS: - DATABASES['ips4'] = IPS4_DB - - -# Conditionally add periodic tasks for services if installed -if 'services.modules.teamspeak3' in INSTALLED_APPS: - CELERYBEAT_SCHEDULE['run_ts3_group_update'] = { - 'task': 'services.modules.teamspeak3.tasks.run_ts3_group_update', - 'schedule': crontab(minute='*/30'), - } diff --git a/allianceauth/context_processors.py b/allianceauth/context_processors.py index acbdb6f8..ae596ac3 100644 --- a/allianceauth/context_processors.py +++ b/allianceauth/context_processors.py @@ -3,6 +3,5 @@ from django.conf import settings def auth_settings(request): return { - 'DOMAIN': settings.DOMAIN, 'SITE_NAME': settings.SITE_NAME, } diff --git a/allianceauth/log/.gitignore b/allianceauth/log/.gitignore new file mode 100644 index 00000000..73edf032 --- /dev/null +++ b/allianceauth/log/.gitignore @@ -0,0 +1,2 @@ +!.gitignore +* \ No newline at end of file diff --git a/allianceauth/services/modules/phpbb3/manager.py b/allianceauth/services/modules/phpbb3/manager.py index 621de22e..01b2dec8 100755 --- a/allianceauth/services/modules/phpbb3/manager.py +++ b/allianceauth/services/modules/phpbb3/manager.py @@ -195,7 +195,7 @@ class Phpbb3Manager: cursor = connections['phpbb3'].cursor() password = Phpbb3Manager.__gen_hash(Phpbb3Manager.__generate_random_pass()) - revoke_email = "revoked@" + settings.DOMAIN + revoke_email = "revoked@localhost" try: pwhash = Phpbb3Manager.__gen_hash(password) cursor.execute(Phpbb3Manager.SQL_DIS_USER, [revoke_email, pwhash, username]) diff --git a/allianceauth/services/modules/smf/manager.py b/allianceauth/services/modules/smf/manager.py index f0816209..ff9f346a 100644 --- a/allianceauth/services/modules/smf/manager.py +++ b/allianceauth/services/modules/smf/manager.py @@ -235,7 +235,7 @@ class SmfManager: cursor = connections['smf'].cursor() password = cls.generate_random_pass() - revoke_email = "revoked@" + settings.DOMAIN + revoke_email = "revoked@localhost" try: pwhash = cls.gen_hash(username, password) cursor.execute(cls.SQL_DIS_USER, [revoke_email, pwhash, username]) diff --git a/alliance_auth/__init__.py b/allianceauth/settings/__init__.py similarity index 100% rename from alliance_auth/__init__.py rename to allianceauth/settings/__init__.py diff --git a/allianceauth/settings/base.py b/allianceauth/settings/base.py new file mode 100644 index 00000000..1630d76a --- /dev/null +++ b/allianceauth/settings/base.py @@ -0,0 +1,268 @@ +# -*- 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, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +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(BASE_DIR, 'alliance_auth.sqlite')), + }, +} + +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(BASE_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', + }, + } +} + + +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/srp/managers.py b/allianceauth/srp/managers.py index 2c394c91..d59e5366 100644 --- a/allianceauth/srp/managers.py +++ b/allianceauth/srp/managers.py @@ -1,4 +1,4 @@ -from django.conf import settings +from allianceauth import NAME import requests import logging @@ -20,7 +20,7 @@ class SRPManager: def get_kill_data(kill_id): url = ("https://www.zkillboard.com/api/killID/%s/" % kill_id) headers = { - 'User-Agent': "%s Alliance Auth" % settings.DOMAIN, + 'User-Agent': NAME, 'Content-Type': 'application/json', } r = requests.get(url, headers=headers) diff --git a/alliance_auth/wsgi.py b/allianceauth/wsgi.py similarity index 87% rename from alliance_auth/wsgi.py rename to allianceauth/wsgi.py index a5087167..39a09438 100644 --- a/alliance_auth/wsgi.py +++ b/allianceauth/wsgi.py @@ -10,7 +10,7 @@ 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", "alliance_auth.settings") +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') diff --git a/manage.py b/manage.py index e6768c3c..7eec003b 100644 --- a/manage.py +++ b/manage.py @@ -3,7 +3,7 @@ import os import sys if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "alliance_auth.settings") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "allianceauth.settings.base") try: from django.core.management import execute_from_command_line except ImportError: diff --git a/runtests.py b/runtests.py index 45c5201c..cdf361a0 100644 --- a/runtests.py +++ b/runtests.py @@ -3,7 +3,7 @@ import os import sys if __name__ == "__main__": - os.environ['DJANGO_SETTINGS_MODULE'] = 'test_allianceauth.settings' + os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' try: from django.core.management import execute_from_command_line diff --git a/setup.py b/setup.py index a3409457..7e9e35dc 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,6 @@ install_requires = [ 'django-redis-cache>=1.7.1', 'django-celery-beat', - # Openfire 'openfire-restapi', 'sleekxmpp', @@ -41,12 +40,12 @@ setup( author='Alliance Auth', author_email='adarnof@gmail.com', description='Eve alliance auth for the 99 percent', - # Any changes in these package requirements - # should be reflected in requirements.txt as well. install_requires=install_requires, extras_require={ 'testing': testing_extras, + ':python_version=="3.4"': ['typing'], }, + python_requires='~=3.4', license='GPLv2', packages=['allianceauth'], url='https://github.com/allianceauth/allianceauth', diff --git a/test_allianceauth/settings.py b/test_allianceauth/settings.py deleted file mode 100644 index 739e0daa..00000000 --- a/test_allianceauth/settings.py +++ /dev/null @@ -1,408 +0,0 @@ -""" -Alliance Auth Test Suite Django settings. -""" - -import os - -from django.contrib import messages - -import alliance_auth - -# Use nose to run all tests -TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' - -NOSE_ARGS = [ - #'--with-coverage', - #'--cover-package=', - #'--exe', # If your tests need this to be found/run, check they py files are not chmodded +x -] - -# Celery configuration -CELERY_ALWAYS_EAGER = True # Forces celery to run locally for testing - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(alliance_auth.__file__))) - -SECRET_KEY = 'testing only' - -DEBUG = False - -# Application definition - -INSTALLED_APPS = [ - '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', - 'esi', - 'allianceauth', - 'allianceauth.authentication', - 'allianceauth.services', - 'allianceauth.eveonline', - 'allianceauth.groupmanagement', - 'allianceauth.hrapplications', - 'allianceauth.timerboard', - 'allianceauth.srp', - 'allianceauth.optimer', - 'allianceauth.corputils', - 'allianceauth.fleetactivitytracking', - 'allianceauth.fleetup', - 'allianceauth.notifications', - 'allianceauth.permissions_tool', - 'allianceauth.thirdparty.navhelper', - - 'allianceauth.services.modules.mumble', - 'allianceauth.services.modules.discord', - 'allianceauth.services.modules.discourse', - 'allianceauth.services.modules.ips4', - 'allianceauth.services.modules.market', - 'allianceauth.services.modules.openfire', - 'allianceauth.services.modules.seat', - 'allianceauth.services.modules.smf', - 'allianceauth.services.modules.phpbb3', - 'allianceauth.services.modules.xenforo', - 'allianceauth.services.modules.teamspeak3', - 'django_nose', -] - -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 = 'test_allianceauth.urls' - -LOCALE_PATHS = ( - os.path.join(BASE_DIR, 'locale/'), -) - -ugettext = lambda s: s -LANGUAGES = ( - ('en', ugettext('English')), - ('de', ugettext('German')), -) -LOGIN_TOKEN_SCOPES = ['esi-characters.read_opportunities.v1'] -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.context_processors.auth_settings', - 'allianceauth.notifications.context_processors.user_notification_count', - 'allianceauth.groupmanagement.context_processors.can_manage_groups', - ], - }, - }, -] - -# Database -# https://docs.djangoproject.com/en/1.10/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': 'alliance_auth', - 'USER': os.environ.get('AA_DB_DEFAULT_USER', None), - 'PASSWORD': os.environ.get('AA_DB_DEFAULT_PASSWORD', None), - 'HOST': os.environ.get('AA_DB_DEFAULT_HOST', None) - }, -} - -LOGIN_URL = 'auth_login_user' - -SUPERUSER_STATE_BYPASS = 'True' == os.environ.get('AA_SUPERUSER_STATE_BYPASS', 'True') - -# Internationalization -# https://docs.djangoproject.com/en/1.10/topics/i18n/ - -LANGUAGE_CODE = os.environ.get('AA_LANGUAGE_CODE', 'en') - -TIME_ZONE = os.environ.get('AA_TIME_ZONE', 'UTC') - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) - -STATIC_URL = '/static/' -STATIC_ROOT = os.path.join(BASE_DIR, "static") - -# Bootstrap messaging css workaround -MESSAGE_TAGS = { - messages.ERROR: 'danger' -} - -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.db.DatabaseCache', - } -} - -AUTHENTICATION_BACKENDS = ['allianceauth.authentication.backends.StateBackend', 'django.contrib.auth.backends.ModelBackend'] - -##################################################### -## -## Auth configuration starts here -## -##################################################### - -################# -# EMAIL SETTINGS -################# -# DOMAIN - The alliance auth domain_url -# EMAIL_HOST - SMTP Server URL -# EMAIL_PORT - SMTP Server PORT -# EMAIL_HOST_USER - Email Username (for gmail, the entire address) -# EMAIL_HOST_PASSWORD - Email Password -# EMAIL_USE_TLS - Set to use TLS encryption -################# -DOMAIN = os.environ.get('AA_DOMAIN', 'https://example.com') -SITE_NAME = os.environ.get('AA_SITE_NAME', 'Test Alliance Auth') -EMAIL_HOST = os.environ.get('AA_EMAIL_HOST', 'smtp.example.com') -EMAIL_PORT = int(os.environ.get('AA_EMAIL_PORT', '587')) -EMAIL_HOST_USER = os.environ.get('AA_EMAIL_HOST_USER', '') -EMAIL_HOST_PASSWORD = os.environ.get('AA_EMAIL_HOST_PASSWORD', '') -EMAIL_USE_TLS = 'True' == os.environ.get('AA_EMAIL_USE_TLS', 'True') - -################### -# SSO Settings -################### -# Optional SSO. -# Get client ID and client secret from registering an app at -# https://developers.eveonline.com/ -# Callback URL should be http://mydomain.com/sso/callback -# Leave callback blank to hide SSO button on login page -################### -ESI_SSO_CLIENT_ID = os.environ.get('AA_ESI_SSO_CLIENT_ID', '') -ESI_SSO_CLIENT_SECRET = os.environ.get('AA_ESI_SSO_CLIENT_SECRET', '') -ESI_SSO_CALLBACK_URL = os.environ.get('AA_ESI_SSO_CALLBACK_URL', '') - -####################### -# EVE Provider Settings -####################### -# EVEONLINE_CHARACTER_PROVIDER - Name of default data source for getting eve character data -# EVEONLINE_CORP_PROVIDER - Name of default data source for getting eve corporation data -# EVEONLINE_ALLIANCE_PROVIDER - Name of default data source for getting eve alliance data -# EVEONLINE_ITEMTYPE_PROVIDER - Name of default data source for getting eve item type data -# -# Available sources are 'esi' and 'xml'. Leaving blank results in the default 'esi' being used. -####################### -EVEONLINE_CHARACTER_PROVIDER = os.environ.get('AA_EVEONLINE_CHARACTER_PROVIDER', 'xml') -EVEONLINE_CORP_PROVIDER = os.environ.get('AA_EVEONLINE_CORP_PROVIDER', 'xml') -EVEONLINE_ALLIANCE_PROVIDER = os.environ.get('AA_EVEONLINE_ALLIANCE_PROVIDER', 'xml') -EVEONLINE_ITEMTYPE_PROVIDER = os.environ.get('AA_EVEONLINE_ITEMTYPE_PROVIDER', 'xml') - -##################### -# Alliance Market -##################### -MARKET_URL = os.environ.get('AA_MARKET_URL', 'http://yourdomain.com/market') - -##################### -# HR Configuration -##################### -# JACK_KNIFE_URL - Url for the audit page of API Jack knife -# Should seriously replace with your own. -##################### -JACK_KNIFE_URL = os.environ.get('AA_JACK_KNIFE_URL', 'http://example.com/eveapi/audit.php') - -######################## -# XenForo Configuration -######################## -XENFORO_ENDPOINT = os.environ.get('AA_XENFORO_ENDPOINT', 'example.com/api.php') -XENFORO_DEFAULT_GROUP = os.environ.get('AA_XENFORO_DEFAULT_GROUP', 0) -XENFORO_APIKEY = os.environ.get('AA_XENFORO_APIKEY', 'yourapikey') -##################### - -###################### -# Jabber Configuration -###################### -# JABBER_URL - Jabber address url -# JABBER_PORT - Jabber service portal -# JABBER_SERVER - Jabber server url -# OPENFIRE_ADDRESS - Address of the openfire admin console including port -# Please use http with 9090 or https with 9091 -# OPENFIRE_SECRET_KEY - Openfire REST API secret key -# BROADCAST_USER - Broadcast user JID -# BROADCAST_USER_PASSWORD - Broadcast user password -###################### -JABBER_URL = os.environ.get('AA_JABBER_URL', "example.com") -JABBER_PORT = int(os.environ.get('AA_JABBER_PORT', '5223')) -JABBER_SERVER = os.environ.get('AA_JABBER_SERVER', "example.com") -OPENFIRE_ADDRESS = os.environ.get('AA_OPENFIRE_ADDRESS', "http://example.com:9090") -OPENFIRE_SECRET_KEY = os.environ.get('AA_OPENFIRE_SECRET_KEY', "somekey") -BROADCAST_USER = os.environ.get('AA_BROADCAST_USER', "broadcast@") + JABBER_URL -BROADCAST_USER_PASSWORD = os.environ.get('AA_BROADCAST_USER_PASSWORD', "somepassword") -BROADCAST_SERVICE_NAME = os.environ.get('AA_BROADCAST_SERVICE_NAME', "broadcast") - -###################################### -# Mumble Configuration -###################################### -# MUMBLE_URL - Mumble server url -# MUMBLE_SERVER_ID - Mumble server id -###################################### -MUMBLE_URL = os.environ.get('AA_MUMBLE_URL', "example.com") -MUMBLE_SERVER_ID = int(os.environ.get('AA_MUMBLE_SERVER_ID', '1')) - -###################################### -# PHPBB3 Configuration -###################################### -PHPBB3_URL = os.environ.get('AA_FORUM_URL', '') - -###################################### -# Teamspeak3 Configuration -###################################### -# TEAMSPEAK3_SERVER_IP - Teamspeak3 server ip -# TEAMSPEAK3_SERVER_PORT - Teamspeak3 server port -# TEAMSPEAK3_SERVERQUERY_USER - Teamspeak3 serverquery username -# TEAMSPEAK3_SERVERQUERY_PASSWORD - Teamspeak3 serverquery password -# TEAMSPEAK3_VIRTUAL_SERVER - Virtual server id -# TEAMSPEAK3_AUTHED_GROUP_ID - Default authed group id -# TEAMSPEAK3_PUBLIC_URL - teamspeak3 public url used for link creation -###################################### -TEAMSPEAK3_SERVER_IP = os.environ.get('AA_TEAMSPEAK3_SERVER_IP', '127.0.0.1') -TEAMSPEAK3_SERVER_PORT = int(os.environ.get('AA_TEAMSPEAK3_SERVER_PORT', '10011')) -TEAMSPEAK3_SERVERQUERY_USER = os.environ.get('AA_TEAMSPEAK3_SERVERQUERY_USER', 'serveradmin') -TEAMSPEAK3_SERVERQUERY_PASSWORD = os.environ.get('AA_TEAMSPEAK3_SERVERQUERY_PASSWORD', 'passwordhere') -TEAMSPEAK3_VIRTUAL_SERVER = int(os.environ.get('AA_TEAMSPEAK3_VIRTUAL_SERVER', '1')) -TEAMSPEAK3_PUBLIC_URL = os.environ.get('AA_TEAMSPEAK3_PUBLIC_URL', 'example.com') - -###################################### -# Discord Configuration -###################################### -# DISCORD_GUILD_ID - ID of the guild to manage -# DISCORD_BOT_TOKEN - oauth token of the app bot user -# DISCORD_INVITE_CODE - invite code to the server -# DISCORD_APP_ID - oauth app client ID -# DISCORD_APP_SECRET - oauth app secret -# DISCORD_CALLBACK_URL - oauth callback url -# DISCORD_SYNC_NAMES - enable to force discord nicknames to be set to eve char name (bot needs Manage Nicknames permission) -###################################### -DISCORD_GUILD_ID = os.environ.get('AA_DISCORD_GUILD_ID', '0118999') -DISCORD_BOT_TOKEN = os.environ.get('AA_DISCORD_BOT_TOKEN', 'bottoken') -DISCORD_INVITE_CODE = os.environ.get('AA_DISCORD_INVITE_CODE', 'invitecode') -DISCORD_APP_ID = os.environ.get('AA_DISCORD_APP_ID', 'appid') -DISCORD_APP_SECRET = os.environ.get('AA_DISCORD_APP_SECRET', 'secret') -DISCORD_CALLBACK_URL = os.environ.get('AA_DISCORD_CALLBACK_URL', 'http://example.com/discord/callback') -DISCORD_SYNC_NAMES = 'True' == os.environ.get('AA_DISCORD_SYNC_NAMES', 'False') - -###################################### -# Discourse Configuration -###################################### -# DISCOURSE_URL - Web address of the forums (no trailing slash) -# DISCOURSE_API_USERNAME - API account username -# DISCOURSE_API_KEY - API Key -# DISCOURSE_SSO_SECRET - SSO secret key -###################################### -DISCOURSE_URL = os.environ.get('AA_DISCOURSE_URL', 'https://example.com') -DISCOURSE_API_USERNAME = os.environ.get('AA_DISCOURSE_API_USERNAME', '') -DISCOURSE_API_KEY = os.environ.get('AA_DISCOURSE_API_KEY', '') -DISCOURSE_SSO_SECRET = 'd836444a9e4084d5b224a60c208dce14' -# Example secret from https://meta.discourse.org/t/official-single-sign-on-for-discourse/13045 - -##################################### -# IPS4 Configuration -##################################### -# IPS4_URL - base url of the IPS4 install (no trailing slash) -# IPS4_API_KEY - API key provided by IPS4 -##################################### -IPS4_URL = os.environ.get('AA_IPS4_URL', 'http://example.com/ips4') -IPS4_API_KEY = os.environ.get('AA_IPS4_API_KEY', '') - -##################################### -# SEAT Configuration -##################################### -# SEAT_URL - base url of the seat install (no trailing slash) -# SEAT_XTOKEN - API key X-Token provided by SeAT -##################################### -SEAT_URL = os.environ.get('AA_SEAT_URL', 'http://example.com/seat') -SEAT_XTOKEN = os.environ.get('AA_SEAT_XTOKEN', 'tokentokentoken') - -###################################### -# SMF Configuration -###################################### -SMF_URL = os.environ.get('AA_SMF_URL', '') - -###################################### -# Fleet-Up Configuration -###################################### -# FLEETUP_APP_KEY - The app key from http://fleet-up.com/Api/MyApps -# FLEETUP_USER_ID - The user id from http://fleet-up.com/Api/MyKeys -# FLEETUP_API_ID - The API id from http://fleet-up.com/Api/MyKeys -# FLEETUP_GROUP_ID - The id of the group you want to pull data from, see http://fleet-up.com/Api/Endpoints#groups_mygroupmemberships -###################################### -FLEETUP_APP_KEY = os.environ.get('AA_FLEETUP_APP_KEY', '') -FLEETUP_USER_ID = os.environ.get('AA_FLEETUP_USER_ID', '') -FLEETUP_API_ID = os.environ.get('AA_FLEETUP_API_ID', '') -FLEETUP_GROUP_ID = os.environ.get('AA_FLEETUP_GROUP_ID', '') - -PASSWORD_HASHERS = [ - 'django.contrib.auth.hashers.UnsaltedMD5PasswordHasher', -] - - -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': { - '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': ['console', 'notifications'], - 'level': 'DEBUG', - }, - 'celerytask': { - 'handlers': ['console', 'notifications'], - 'level': 'DEBUG', - }, - 'django': { - 'handlers': ['console', 'notifications'], - 'level': 'ERROR', - }, - } -} - -LOGGING = None # Comment out to enable logging for debugging diff --git a/test_allianceauth/__init__.py b/tests/__init__.py similarity index 100% rename from test_allianceauth/__init__.py rename to tests/__init__.py diff --git a/tests/settings.py b/tests/settings.py new file mode 100644 index 00000000..01d68dcd --- /dev/null +++ b/tests/settings.py @@ -0,0 +1,195 @@ +""" +Alliance Auth Test Suite Django settings. +""" + +from allianceauth.settings.base import * + +# Use nose to run all tests +TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' + +NOSE_ARGS = [ + #'--with-coverage', + #'--cover-package=', + #'--exe', # If your tests need this to be found/run, check they py files are not chmodded +x +] + +# Celery configuration +CELERY_ALWAYS_EAGER = True # Forces celery to run locally for testing + +INSTALLED_APPS = [ + 'allianceauth.hrapplications', + 'allianceauth.timerboard', + 'allianceauth.srp', + 'allianceauth.optimer', + 'allianceauth.corputils', + 'allianceauth.fleetactivitytracking', + 'allianceauth.fleetup', + 'allianceauth.permissions_tool', + 'allianceauth.services.modules.mumble', + 'allianceauth.services.modules.discord', + 'allianceauth.services.modules.discourse', + 'allianceauth.services.modules.ips4', + 'allianceauth.services.modules.market', + 'allianceauth.services.modules.openfire', + 'allianceauth.services.modules.seat', + 'allianceauth.services.modules.smf', + 'allianceauth.services.modules.phpbb3', + 'allianceauth.services.modules.xenforo', + 'allianceauth.services.modules.teamspeak3', + 'django_nose', +] + +add_auth_apps(INSTALLED_APPS) + +ROOT_URLCONF = 'tests.urls' + +CACHES['default'] = {'BACKEND': 'django.core.cache.backends.db.DatabaseCache'} + +##################### +# Alliance Market +##################### +MARKET_URL = 'http://yourdomain.com/market' + +##################### +# HR Configuration +##################### +# JACK_KNIFE_URL - Url for the audit page of API Jack knife +# Should seriously replace with your own. +##################### +JACK_KNIFE_URL = 'http://example.com/eveapi/audit.php' + +######################## +# XenForo Configuration +######################## +XENFORO_ENDPOINT = 'example.com/api.php' +XENFORO_DEFAULT_GROUP = 0 +XENFORO_APIKEY = 'yourapikey' +##################### + +###################### +# Jabber Configuration +###################### +# JABBER_URL - Jabber address url +# JABBER_PORT - Jabber service portal +# JABBER_SERVER - Jabber server url +# OPENFIRE_ADDRESS - Address of the openfire admin console including port +# Please use http with 9090 or https with 9091 +# OPENFIRE_SECRET_KEY - Openfire REST API secret key +# BROADCAST_USER - Broadcast user JID +# BROADCAST_USER_PASSWORD - Broadcast user password +###################### +JABBER_URL = "example.com" +JABBER_PORT = 5223 +JABBER_SERVER = "example.com" +OPENFIRE_ADDRESS = "http://example.com:9090" +OPENFIRE_SECRET_KEY = "somekey" +BROADCAST_USER = "broadcast@" + JABBER_URL +BROADCAST_USER_PASSWORD = "somepassword" +BROADCAST_SERVICE_NAME = "broadcast" + +###################################### +# Mumble Configuration +###################################### +# MUMBLE_URL - Mumble server url +# MUMBLE_SERVER_ID - Mumble server id +###################################### +MUMBLE_URL = "example.com" +MUMBLE_SERVER_ID = 1 + +###################################### +# PHPBB3 Configuration +###################################### +PHPBB3_URL = '' + +###################################### +# Teamspeak3 Configuration +###################################### +# TEAMSPEAK3_SERVER_IP - Teamspeak3 server ip +# TEAMSPEAK3_SERVER_PORT - Teamspeak3 server port +# TEAMSPEAK3_SERVERQUERY_USER - Teamspeak3 serverquery username +# TEAMSPEAK3_SERVERQUERY_PASSWORD - Teamspeak3 serverquery password +# TEAMSPEAK3_VIRTUAL_SERVER - Virtual server id +# TEAMSPEAK3_AUTHED_GROUP_ID - Default authed group id +# TEAMSPEAK3_PUBLIC_URL - teamspeak3 public url used for link creation +###################################### +TEAMSPEAK3_SERVER_IP = '127.0.0.1' +TEAMSPEAK3_SERVER_PORT = 10011 +TEAMSPEAK3_SERVERQUERY_USER = 'serveradmin' +TEAMSPEAK3_SERVERQUERY_PASSWORD = 'passwordhere' +TEAMSPEAK3_VIRTUAL_SERVER = 1 +TEAMSPEAK3_PUBLIC_URL = 'example.com' + +###################################### +# Discord Configuration +###################################### +# DISCORD_GUILD_ID - ID of the guild to manage +# DISCORD_BOT_TOKEN - oauth token of the app bot user +# DISCORD_INVITE_CODE - invite code to the server +# DISCORD_APP_ID - oauth app client ID +# DISCORD_APP_SECRET - oauth app secret +# DISCORD_CALLBACK_URL - oauth callback url +# DISCORD_SYNC_NAMES - enable to force discord nicknames to be set to eve char name (bot needs Manage Nicknames permission) +###################################### +DISCORD_GUILD_ID = '0118999' +DISCORD_BOT_TOKEN = 'bottoken' +DISCORD_INVITE_CODE = 'invitecode' +DISCORD_APP_ID = 'appid' +DISCORD_APP_SECRET = 'secret' +DISCORD_CALLBACK_URL = 'http://example.com/discord/callback' +DISCORD_SYNC_NAMES = 'True' == 'False' + +###################################### +# Discourse Configuration +###################################### +# DISCOURSE_URL - Web address of the forums (no trailing slash) +# DISCOURSE_API_USERNAME - API account username +# DISCOURSE_API_KEY - API Key +# DISCOURSE_SSO_SECRET - SSO secret key +###################################### +DISCOURSE_URL = 'https://example.com' +DISCOURSE_API_USERNAME = '' +DISCOURSE_API_KEY = '' +DISCOURSE_SSO_SECRET = 'd836444a9e4084d5b224a60c208dce14' +# Example secret from https://meta.discourse.org/t/official-single-sign-on-for-discourse/13045 + +##################################### +# IPS4 Configuration +##################################### +# IPS4_URL - base url of the IPS4 install (no trailing slash) +# IPS4_API_KEY - API key provided by IPS4 +##################################### +IPS4_URL = 'http://example.com/ips4' +IPS4_API_KEY = '' + +##################################### +# SEAT Configuration +##################################### +# SEAT_URL - base url of the seat install (no trailing slash) +# SEAT_XTOKEN - API key X-Token provided by SeAT +##################################### +SEAT_URL = 'http://example.com/seat' +SEAT_XTOKEN = 'tokentokentoken' + +###################################### +# SMF Configuration +###################################### +SMF_URL = '' + +###################################### +# Fleet-Up Configuration +###################################### +# FLEETUP_APP_KEY - The app key from http://fleet-up.com/Api/MyApps +# FLEETUP_USER_ID - The user id from http://fleet-up.com/Api/MyKeys +# FLEETUP_API_ID - The API id from http://fleet-up.com/Api/MyKeys +# FLEETUP_GROUP_ID - The id of the group you want to pull data from, see http://fleet-up.com/Api/Endpoints#groups_mygroupmemberships +###################################### +FLEETUP_APP_KEY = '' +FLEETUP_USER_ID = '' +FLEETUP_API_ID = '' +FLEETUP_GROUP_ID = '' + +PASSWORD_HASHERS = [ + 'django.contrib.auth.hashers.MD5PasswordHasher', +] + +LOGGING = None # Comment out to enable logging for debugging diff --git a/test_allianceauth/urls.py b/tests/urls.py similarity index 99% rename from test_allianceauth/urls.py rename to tests/urls.py index 53993dfd..8c2b2233 100644 --- a/test_allianceauth/urls.py +++ b/tests/urls.py @@ -1,4 +1,5 @@ from django.conf.urls import url + import allianceauth.urls from . import views diff --git a/test_allianceauth/views.py b/tests/views.py similarity index 100% rename from test_allianceauth/views.py rename to tests/views.py diff --git a/update.sh b/update.sh deleted file mode 100755 index 936222e0..00000000 --- a/update.sh +++ /dev/null @@ -1,4 +0,0 @@ -pip install --upgrade -r requirements.txt -python manage.py migrate --fake-initial -yes yes | python manage.py collectstatic -c -python manage.py check --deploy \ No newline at end of file