Add devmode_settings.py for local dev

* Adds an env variable to .env to turn on dev mode
* Uses the inbuilt django auth rather than saml when in dev mode
* For laziness, re-uses the admin login form for the non-admin login

make_dev_container now comes up ready to be logged into by any
user. No non-admin users are preconfigured; but you can add one at
http://localhost:28000/admin/auth/user/add/, log out, and then hit
http://localhost:28000/ to log in as the new user.
This commit is contained in:
James Polley 2017-08-27 22:07:37 +10:00
parent 0d06fc08eb
commit 37fb435e18
4 changed files with 17 additions and 1 deletions

View file

@ -4,3 +4,4 @@ STRIPE_SECRET_KEY=5CEA51A5-A613-4AEF-A9FB-D0A57D77C13B
GCS_BUCKET=5CEA51A5-A613-4AEF-A9FB-D0A57D77C13B
GOOGLE_APPLICATION_CREDENTIALS=/dev/null
DATABASE_URL=sqlite:////tmp/symposion.sqlite
SYMPOSION_DEV_MODE=LAPTOP

View file

@ -0,0 +1,7 @@
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
AUTHENTICATION_BACKENDS = [
'symposion.teams.backends.TeamPermissionsBackend',
'django.contrib.auth.backends.ModelBackend',
]
LOGIN_URL='/accounts/login'

View file

@ -382,3 +382,8 @@ DEFAULT_FILE_STORAGE = 'gapc_storage.storage.GoogleCloudStorage'
GAPC_STORAGE = {
'num_retries': 2,
}
DEV_MODE = os.environ.get("SYMPOSION_DEV_MODE", None)
if DEV_MODE and DEV_MODE == "LAPTOP":
print("ENABLING LAPTOP MODE")
from .devmode_settings import *

View file

@ -33,6 +33,9 @@ urlpatterns = [
if settings.DEBUG:
import debug_toolbar
urlpatterns.insert(0, url(r'^__debug__/', include(debug_toolbar.urls)))
if settings.DEV_MODE:
from django.contrib.auth.views import login, logout
urlpatterns.insert(0, url(r'^accounts/logout', logout, {'template_name': 'admin/logout.html'}))
urlpatterns.insert(0, url(r'^accounts/login', login, {'template_name': 'admin/login.html'}))
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)