diff options
author | Prabhu Ramachandran | 2018-06-07 16:14:37 +0530 |
---|---|---|
committer | GitHub | 2018-06-07 16:14:37 +0530 |
commit | 4eb754c2e71922819de7390d1b4993a21763de3e (patch) | |
tree | fede3f4250f3711d31da4bb7edd262edd0a90727 /yaksh/middleware | |
parent | 78ce1804d3a82327aa0da1510bb5c03d6bbff3ba (diff) | |
parent | 93bb10eae5e1364ae6492f2534f0e7864c9c4254 (diff) | |
download | online_test-4eb754c2e71922819de7390d1b4993a21763de3e.tar.gz online_test-4eb754c2e71922819de7390d1b4993a21763de3e.tar.bz2 online_test-4eb754c2e71922819de7390d1b4993a21763de3e.zip |
Merge pull request #482 from adityacp/pep8_changes
Pep8 changes
Diffstat (limited to 'yaksh/middleware')
-rw-r--r-- | yaksh/middleware/one_session_per_user.py | 28 | ||||
-rw-r--r-- | yaksh/middleware/user_time_zone.py | 6 |
2 files changed, 21 insertions, 13 deletions
diff --git a/yaksh/middleware/one_session_per_user.py b/yaksh/middleware/one_session_per_user.py index 92e888d..1ed1786 100644 --- a/yaksh/middleware/one_session_per_user.py +++ b/yaksh/middleware/one_session_per_user.py @@ -7,21 +7,27 @@ from yaksh.models import ConcurrentUser class OneSessionPerUserMiddleware(object): """ Middleware to handle multiple logins with same credentials - - Creates a Database entry to record the current user and active session key - - Checks if the current user has already been logged in. If True, the new session - key is stored with respect to the user and the old session key is deleted, + - Creates a Database entry to record the current user and active + session key + - Checks if the current user has already been logged in. If True, the + new session key is stored with respect to the user and the old + session key is deleted, effectively terminating the older session for the same user. - - The concurrentuser attribute of the User model refers to the ConcurrentUser - model object and not the concurrent_user field due to behaviour described - in the Documentation - Link: https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#extending-the-existing-user-model) + - The concurrentuser attribute of the User model refers to the + ConcurrentUser + model object and not the concurrent_user field due to behaviour + described in the Documentation + Link: https://docs.djangoproject.com/en/1.5/topics/auth/customizing/ + #extending-the-existing-user-model """ def process_request(self, request): + """ + # Documentation: + # https://docs.djangoproject.com/en/1.5/topics/auth/customizing/ + #extending-the-existing-user-model + """ if isinstance(request.user, User): current_key = request.session.session_key - # - # Documentation: - # https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#extending-the-existing-user-model if hasattr(request.user, 'concurrentuser'): active_key = request.user.concurrentuser.session_key if active_key != current_key: @@ -32,4 +38,4 @@ class OneSessionPerUserMiddleware(object): ConcurrentUser.objects.create( concurrent_user=request.user, session_key=current_key, - )
\ No newline at end of file + ) diff --git a/yaksh/middleware/user_time_zone.py b/yaksh/middleware/user_time_zone.py index ff9ec5c..206c08a 100644 --- a/yaksh/middleware/user_time_zone.py +++ b/yaksh/middleware/user_time_zone.py @@ -4,8 +4,10 @@ from django.utils import timezone class TimezoneMiddleware(object): - """ Middleware to get user's timezone and activate timezone - if user timezone is not available default value 'Asia/Kolkata' is activated """ + """ Middleware to get user's timezone and activate timezone + if user timezone is not available default value 'Asia/Kolkata' + is activated + """ def process_request(self, request): user = request.user user_tz = 'Asia/Kolkata' |