Update .gitlab-ci.yml to support new settings

- list env vars
- also update manage.py and wsgi.py to use associated settings
parent 22614d74
Pipeline #1194 passed with stage
in 1 minute and 3 seconds
......@@ -14,15 +14,21 @@ before_script:
- pip install -r requirements/ci.txt
- nohup redis-server &
- cd go/
- cp settings/settings.py.template settings/settings.py
- cp settings/secret.py.template settings/secret.py
- export SECRET_KEY=$(dd if=/dev/urandom count=100 | tr -dc "A-Za-z0-9" | fold -w 60 | head -n1 2>/dev/null)
- export DJANGO_DEBUG="True"
- sed -i settings/secret.py -e 's/DB_NAME.*/DB_NAME = \"go\"/'
- sed -i settings/secret.py -e 's/DB_USER.*/DB_USER = \"root\"/'
- sed -i settings/secret.py -e 's/DB_PASSWORD.*/DB_PASSWORD = \"root\"/'
- sed -i settings/secret.py -e 's/DB_HOST.*/DB_HOST = \"mysql\"/'
- sed -i settings/secret.py -e 's/SECRET_KEY.*/SECRET_KEY = \"${SECRET_KEY}\"/'
- export GO_SECRET_KEY=$(dd if=/dev/urandom count=100 | tr -dc "A-Za-z0-9" | fold -w 60 | head -n1 2>/dev/null)
- export GO_DB_NAME="go"
- export GO_DB_USER="root"
- export GO_DB_PASSWORD="root"
- export GO_DB_HOST="mysql"
- export GO_DB_PORT=3306
- export GO_ALLOWED_HOSTS="*"
- export GO_EMAIL_DOMAIN="@masonlive.gmu.edu"
- export GO_CAS_URL="https://cas.srct.gmu.edu/"
- export GO_EMAIL_HOST=
- export GO_EMAIL_PORT=
- export GO_EMAIL_HOST_USER=
- export GO_EMAIL_HOST_PASSWORD=
- export GO_EMAIL_FROM=
- export GO_EMAIL_TO=
- python manage.py makemigrations
- python manage.py makemigrations go
- python manage.py migrate
......
......@@ -3,7 +3,7 @@ import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.local")
from django.core.management import execute_from_command_line
......
# Create a new file 'secret.py' and copy these contents into that file
# Please be sure to keep these variables secret in production
# You can generate a secret key from the following link: http://www.miniwebtool.com/django-secret-key-generator/
SECRET_KEY = ""
# Use the values from the database configuration
DB_NAME = ""
DB_USER = ""
# Remember to use a strong password in production
DB_PASSWORD = ""
# Often left blank
DB_HOST = ""
# Email configuration, if necessary
EMAIL_HOST = ""
EMAIL_PORT = ""
EMAIL_HOST_USER = ""
EMAIL_HOST_PASSWORD = ""
# Create a new file 'settings.py' and copy these contents into that file
from . import secret
import os
import sys
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# DEBUG mode is used to view more details when errors occur
# Do not have set True in production
DEBUG = False
ADMINS = ()
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': secret.DB_NAME,
'USER': secret.DB_USER,
'PASSWORD': secret.DB_PASSWORD,
'HOST': secret.DB_HOST,
'PORT': '',
}
}
# The domains this application will be deployed on
# e.g. Which domains this app should listen to requests from.
ALLOWED_HOSTS = ['127.0.0.1']
# Peoplefinder API
PF_URL = "https://api.srct.gmu.edu/pf/v1/"
TIME_ZONE = 'America/New_York'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True
MEDIA_URL = '/media/'
MEDIA_ROOT = ''
MEDIAFILES_DIRS = (
os.path.join(BASE_DIR, 'media/'),
)
STATIC_URL = '/static/'
STATIC_ROOT = ''
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static/'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
SECRET_KEY = secret.SECRET_KEY
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates')
],
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.request'
],
'loaders': [
'django.template.loaders.app_directories.Loader'
],
'debug': DEBUG
}
}
]
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
ROOT_URLCONF = 'settings.urls'
WSGI_APPLICATION = 'settings.wsgi.application'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'go',
'django.contrib.admin',
'qrcode',
'crispy_forms',
'bootstrap3_datetime',
)
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'stream': sys.stdout
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'django': {
'handlers': ['console'],
'level': 'INFO',
'propogate': True
},
}
}
LOGIN_URL = '/login'
LOGOUT_URL = '/logout'
LOGIN_REDIRECT_URL = '/'
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
CAS_SERVER_URL = "https://login.gmu.edu"
CAS_LOGOUT_COMPLETELY = True
CAS_PROVIDE_URL_TO_LOGOUT = True
AUTHENTICATION_BACKENDS += (
'cas.backends.CASBackend',
)
CAS_RESPONSE_CALLBACKS = (
'go.cas_callbacks.create_user',
)
INSTALLED_APPS += (
'cas',
)
MIDDLEWARE_CLASSES += (
'cas.middleware.CASMiddleware',
)
CRISPY_TEMPLATE_PACK = 'bootstrap3'
# Mail settings
EMAIL_HOST = secret.EMAIL_HOST
EMAIL_PORT = secret.EMAIL_PORT
EMAIL_HOST_USER = secret.EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = secret.EMAIL_HOST_PASSWORD
EMAIL_FROM = "example@example.com"
EMAIL_TO = "to@example.com"
# Domain used to email to users. See line 231 in views.py
# ie. in Mason's case '@masonlive.gmu.edu'
EMAIL_DOMAIN = "@example.com"
# Use redis cache when not in local development
if DEBUG:
pass
else:
CACHES = {
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': 'localhost:6379',
},
}
......@@ -166,7 +166,7 @@ class UrlsTest(TestCase):
url = reverse('useradmin')
self.assertEqual(url, '/useradmin')
def test_useradmin(self):
def test_login(self):
"""
/login - login portal
"""
......@@ -174,7 +174,7 @@ class UrlsTest(TestCase):
url = reverse('go_login')
self.assertEqual(url, '/login')
def test_useradmin(self):
def test_logout(self):
"""
/logout - logout portal
"""
......
......@@ -8,7 +8,7 @@ https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.production")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment