Commit d7daa950 authored by Zac Wood's avatar Zac Wood

clean up, use custom mysql image for CI

parent 5d3a0b48
Pipeline #4604 failed with stages
in 50 seconds
services:
- mysql:5.6
- registry.srct.gmu.edu/srct/go/db
stages:
- test
......@@ -35,33 +35,12 @@ before_script:
- python manage.py migrate
- echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('root', 'root@srct.gmu.edu', 'root') " | python manage.py shell
# Go-py2.7:
# image: library/python:2.7
# stage: test
# script:
# - python manage.py test
# Go-py3.4:
# image: library/python:3.4
# stage: test
# script:
# - python manage.py test
Go-py3.7:
image: library/python:3.7
stage: test
script:
- python manage.py test
#Go-py3.6:
# image: library/python:3.6
# stage: test
# script:
# - if pip list --outdated | grep "Latest" | wc -l > 0; then pip list --outdated && exit 1; else exit 0; fi
# - coverage run --source=go --omit=*migrations/*,*admin.py,*manage.py,*wsgi.py,*settings.py,*secret.py,*__init__.py,*.pyc,*templates/*,*static/* manage.py test
# - coverage html -i && grep pc_cov htmlcov/index.html | egrep -o "[0-9]+\%" | awk '{ print "covered " $1;}'
Go-flake8:
image: library/python:3.7
stage: lint
......
......@@ -11,6 +11,7 @@ services:
depends_on:
- db
environment:
- GO_ENV=development
- GO_ALLOWED_HOSTS=*
- GO_EMAIL_DOMAIN=@masonlive.gmu.edu
- GO_CAS_URL=https://login.gmu.edu/
......@@ -29,8 +30,7 @@ services:
- superuser=zwood2
db:
image: mysql:8
command: --default-authentication-plugin=mysql_native_password
image: registry.srct.gmu.edu/srct/go/db
environment:
MYSQL_DATABASE: go
MYSQL_USER: go
......
......@@ -37,16 +37,6 @@ class URLForm(ModelForm):
"""
# get the entered target link
target = self.cleaned_data.get('target')
# Commented out as this check cannont properly be tested since we cannot
# dynamically generate request.META.get('HTTP_HOST')
# # if the host (go.gmu.edu) is in the entered target link or where it
# # redirects
# if self.host in final_url or self.host in target:
# raise ValidationError("You can't make a Go link to Go silly!")
# else:
# return target
return target
# Custom target URL field
......
......@@ -75,24 +75,6 @@ def handle_regUser_creation(sender, instance, created, **kwargs):
if created:
RegisteredUser.objects.create(user=instance)
# Don't send mail for now
#
# user_mail = instance.username + settings.EMAIL_DOMAIN
# send_mail(
# 'We have received your Go application!',
# ######################
# 'Hey there %s,\n\n'
# 'The Go admins have received your application and are '
# 'currently in the process of reviewing it.\n\n'
# 'You will receive another email when you have been '
# 'approved.\n\n'
# '- Go Admins'
# % (str(instance.username)),
# ######################
# settings.EMAIL_FROM,
# [user_mail]
# )
class URL(models.Model):
"""
......
......@@ -50,6 +50,8 @@ class URLFormTest(TestCase):
print(form.errors)
self.assertTrue(form.is_valid())
# Uncomment when custom forms are implemented again
#
# def test_valid_form_custom(self):
# """
# Test that form fields are validated correctly given valid data.
......
......@@ -3,7 +3,7 @@ import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.local")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.settings")
from django.core.management import execute_from_command_line
......
"""
settings/base.py
Base Settings
"""
# Python stdlib Imports
import os
import sys
# STANDALONE VARS
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# You can generate a secret key from the following link:
# http://www.miniwebtool.com/django-secret-key-generator/
# export SECRET_KEY=$(dd if=/dev/urandom count=100 | tr -dc "A-Za-z0-9" | fold -w 60 | head -n1 2>/dev/null)
# assert 'SECRET_KEY' in os.environ, 'You need to set the SECRET_KEY enviornment variable!'
SECRET_KEY = os.environ['GO_SECRET_KEY']
# Peoplefinder API
PF_URL = "https://api.srct.gmu.edu/peoplefinder/v1/"
# 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']
ALLOWED_HOSTS = [os.getenv('GO_ALLOWED_HOSTS', '*')]
ADMINS = ()
MANAGERS = ADMINS
# TIME
TIME_ZONE = 'America/New_York'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True
# MEDIA/STATIC FILE CONFIGURATION
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',
)
# TEMPLATING
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates')
],
'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',
],
'loaders': [
'django.template.loaders.app_directories.Loader'
],
}
}
]
########## DATABASE CONFIGURATION
# Use the same DB everywhere.
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.getenv('GO_DB_NAME', ''),
'USER': os.getenv('GO_DB_USER', ''),
'PASSWORD': os.getenv('GO_DB_PASSWORD', ''),
'HOST': os.getenv('GO_DB_HOST', ''),
'PORT': os.getenv('GO_DB_PORT', ''),
}
}
# MIDDLEWARE
MIDDLEWARE = [
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'cas.middleware.CASMiddleware',
]
# URL CONF
ROOT_URLCONF = 'settings.urls'
WSGI_APPLICATION = 'settings.wsgi.application'
# APPS
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'go',
'qrcode',
'crispy_forms',
'bootstrap_datepicker',
'cas',
)
CRISPY_TEMPLATE_PACK = 'bootstrap3'
# LOGGING
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
},
}
}
# CAS AUTH
LOGIN_URL = '/login'
LOGOUT_URL = '/logout'
LOGIN_REDIRECT_URL = '/'
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'cas.backends.CASBackend',
)
CAS_SERVER_URL = os.getenv('GO_CAS_URL', 'https://login.gmu.edu/')
CAS_LOGOUT_COMPLETELY = True
CAS_PROVIDE_URL_TO_LOGOUT = True
CAS_RESPONSE_CALLBACKS = (
'go.cas_callbacks.create_user',
)
# MAIL
EMAIL_HOST = os.getenv('GO_EMAIL_HOST', '0.0.0.0')
EMAIL_PORT = os.getenv('GO_EMAIL_PORT', '25')
EMAIL_HOST_USER = os.getenv('GO_EMAIL_HOST_USER', '')
EMAIL_HOST_PASSWORD = os.getenv('GO_EMAIL_HOST_PASSWORD', '')
# example@example.com
EMAIL_FROM = os.getenv('GO_EMAIL_FROM', 'srct@gmu.edu')
# to@example.com
EMAIL_TO = os.getenv('GO_EMAIL_TO', '')
# Domain used to email to users. See implementation in views.py
# ie. in Mason's case '@gmu.edu'
EMAIL_DOMAIN = os.getenv('GO_EMAIL_DOMAIN', '@gmu.edu')
# if 'test' in sys.argv:
# DATABASES['default'] = {'ENGINE': 'django.db.backends.sqlite3'}
"""
settings/local.py
Development settings and globals.
"""
# Base Settings Import
from .base import *
# DEBUG mode is used to view more details when errors occur
# Do not have set True in production
DEBUG = True
CAS_SERVER_URL = "https://login.gmu.edu/"
# dummy cache for development-- doesn't actually cache things
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
"""
settings/production.py
Production settings and globals.
"""
# Base Settings Import
from .base import *
# DEBUG mode is used to view more details when errors occur
# Do not have set True in production
DEBUG = False
CAS_SERVER_URL = "https://login.gmu.edu"
CACHES = {
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': 'localhost:6379',
},
}
......@@ -8,7 +8,6 @@ https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""
import os
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