summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--online_test/settings.py2
-rw-r--r--yaksh/middleware/one_session_per_user.py15
-rw-r--r--yaksh/models.py4
3 files changed, 11 insertions, 10 deletions
diff --git a/online_test/settings.py b/online_test/settings.py
index e5b34d0..f96632b 100644
--- a/online_test/settings.py
+++ b/online_test/settings.py
@@ -86,3 +86,5 @@ USE_TZ = False
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_URL = '/static/'
+
+LOGIN_URL = '/exam/login'
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
diff --git a/yaksh/models.py b/yaksh/models.py
index 15340f3..e7852d5 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -8,8 +8,8 @@ from taggit.managers import TaggableManager
###############################################################################
-class Visitor(models.Model):
- visitor_user = models.OneToOneField(User, null=False)
+class ConcurrentUser(models.Model):
+ concurrent_user = models.OneToOneField(User, null=False)
session_key = models.CharField(null=False, max_length=40)