From: Maciej Tronowski Date: Mon, 7 Sep 2015 17:05:38 +0000 (+0200) Subject: use better sessions X-Git-Tag: v1.1~19 X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=commitdiff_plain;h=d6745a489e727c742b32d8d574df537fa20ecd1b;p=qcg-portal.git use better sessions --- diff --git a/plgng/settings_common.py b/plgng/settings_common.py index 337f557..da27cd2 100644 --- a/plgng/settings_common.py +++ b/plgng/settings_common.py @@ -33,6 +33,7 @@ INSTALLED_APPS = ( 'django.contrib.webdesign', 'qcg', 'filex', + 'better_sessions', 'django_openid_auth', 'bootstrap3', ) @@ -45,10 +46,12 @@ MIDDLEWARE_CLASSES = ( 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'better_sessions.middleware.BetterSessionsMiddleware', ) TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + ( 'django.core.context_processors.request', + 'better_sessions.context_processors.settings', ) ROOT_URLCONF = 'plgng.urls' @@ -107,8 +110,7 @@ OPENID_STRICT_USERNAMES = True SESSION_COOKIE_NAME = 'qcg_session' -SESSION_COOKIE_AGE = 60 * 60 * 24 * 6 # 6 days, length of user proxy from openid is 1 week -SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' +SESSION_EXPIRE_AT_BROWSER_CLOSE = True # 3-rd party settings diff --git a/plgng/urls.py b/plgng/urls.py index e4324f9..931bd77 100644 --- a/plgng/urls.py +++ b/plgng/urls.py @@ -6,5 +6,6 @@ urlpatterns = patterns('', url(r'^grappelli/', include('grappelli.urls')), # grappelli URLS url(r'^filex/', include('filex.urls', namespace='filex')), + url(r'^session/', include('better_sessions.urls', namespace='session')), url(r'^', include('qcg.urls')), ) diff --git a/qcg/static/qcg/main.css b/qcg/static/qcg/main.css index f3091c2..6e46b1e 100644 --- a/qcg/static/qcg/main.css +++ b/qcg/static/qcg/main.css @@ -189,3 +189,18 @@ textarea { z-index: 1; } } + + +/* better session alerts */ + +#better-sessions-warn, +#better-sessions-expire { + position: fixed; + left: 15px; + right: 15px; + margin: 0 auto; + max-width: 800px; + z-index: 1050; + top: 10px; + text-align: center; +} diff --git a/qcg/templates/qcg/base.html b/qcg/templates/qcg/base.html index fcd82f0..56f37e1 100644 --- a/qcg/templates/qcg/base.html +++ b/qcg/templates/qcg/base.html @@ -78,6 +78,8 @@ {% endfor %} {% endblock messages %} + {% include 'better_sessions/alerts.html' %} + {% block container %} @@ -116,6 +118,23 @@ + + + + + + + {% if user.is_authenticated %} + + {% endif %} + {% block extra_js %}{% endblock %} diff --git a/qcg/templates/qcg/gridftp_upload.html b/qcg/templates/qcg/gridftp_upload.html index caaf3e6..d5f6b24 100644 --- a/qcg/templates/qcg/gridftp_upload.html +++ b/qcg/templates/qcg/gridftp_upload.html @@ -11,5 +11,7 @@ {% endblock extra_js %} {% block body %} + {% include 'better_sessions/alerts.html' %} + {% include 'filex/upload.html' %} {% endblock body %}