added messages to jinja context, added urls for new apps, updated core settings

This commit is contained in:
iou1name 2018-08-10 19:16:40 -04:00
parent 10ccab21eb
commit cba4094e2b
3 changed files with 38 additions and 4 deletions

View File

@ -3,8 +3,9 @@
Custom Jinja2 environment. Custom Jinja2 environment.
""" """
import jinja2 import jinja2
from django.contrib.staticfiles.storage import staticfiles_storage
from django.urls import reverse from django.urls import reverse
from django.contrib import messages
from django.contrib.staticfiles.storage import staticfiles_storage
def environment(**options): def environment(**options):
""" """
@ -12,11 +13,13 @@ def environment(**options):
""" """
env = jinja2.Environment(**options) env = jinja2.Environment(**options)
env.globals.update({ env.globals.update({
'static': staticfiles_storage.url,
'url': reverse,
'undefined': jinja2.StrictUndefined, 'undefined': jinja2.StrictUndefined,
'autoescape': True, 'autoescape': True,
'trim_blocks': True, 'trim_blocks': True,
'lstrip_blocks': True, 'lstrip_blocks': True,
'url': reverse,
'static': staticfiles_storage.url,
'get_messages': messages.get_messages,
}) })
return env return env

View File

@ -31,9 +31,12 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'quest.apps.QuestConfig', 'users.apps.UsersConfig',
'homepage.apps.HomepageConfig', 'homepage.apps.HomepageConfig',
'create_quest.apps.CreateQuestConfig', 'create_quest.apps.CreateQuestConfig',
'quest.apps.QuestConfig',
'login.apps.LoginConfig',
'signup.apps.SignupConfig',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@ -58,6 +61,19 @@ TEMPLATES = [
'auto_reload': DEBUG, 'auto_reload': DEBUG,
}, },
}, },
{
'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',
],
},
},
] ]
WSGI_APPLICATION = 'titivillus.wsgi.application' WSGI_APPLICATION = 'titivillus.wsgi.application'
@ -87,6 +103,9 @@ AUTH_PASSWORD_VALIDATORS = [
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
'OPTIONS': {
'min_length': 8,
}
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
@ -119,3 +138,12 @@ STATIC_ROOT = '/usr/local/www/html/static/'
STATICFILES_DIRS = [ STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'), os.path.join(BASE_DIR, 'static'),
] ]
AUTH_USER_MODEL = 'users.User'
PASSWORD_HASHERS = [
'django.contrib.auth.hashers.Argon2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
]

View File

@ -11,4 +11,7 @@ urlpatterns = [
path('quest/', include('quest.urls')), path('quest/', include('quest.urls')),
path('create_quest/', include('create_quest.urls')), path('create_quest/', include('create_quest.urls')),
path('set_session/', include('set_session.urls')), path('set_session/', include('set_session.urls')),
path('signup/', include('signup.urls')),
path('login/', include('login.urls')),
path('logout/', include('logout.urls')),
] ]