From 58bd6a8dbe0aa440ad8ec517fc85d388d02dc5e7 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 2 Dec 2015 18:30:12 +0530 Subject: Change model name associated with concurrent login --- yaksh/middleware/one_session_per_user.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'yaksh/middleware') diff --git a/yaksh/middleware/one_session_per_user.py b/yaksh/middleware/one_session_per_user.py index d9e97bb..f382652 100644 --- a/yaksh/middleware/one_session_per_user.py +++ b/yaksh/middleware/one_session_per_user.py @@ -1,22 +1,21 @@ from django.contrib.auth.models import User from django.contrib.sessions.models import Session -from yaksh.models import Visitor +from yaksh.models import ConcurrentUser class OneSessionPerUserMiddleware(object): def process_request(self, request): if isinstance(request.user, User): current_key = request.session.session_key - if hasattr(request.user, 'visitor'): - active_key = request.user.visitor.session_key - print active_key, current_key + if hasattr(request.user, 'concurrentuser'): + active_key = request.user.concurrentuser.session_key if active_key != current_key: Session.objects.filter(session_key=active_key).delete() - request.user.visitor.session_key = current_key - request.user.visitor.save() + request.user.concurrentuser.session_key = current_key + request.user.concurrentuser.save() else: - Visitor.objects.create( - visitor_user=request.user, + ConcurrentUser.objects.create( + concurrent_user=request.user, session_key=current_key, ) \ No newline at end of file -- cgit