summaryrefslogtreecommitdiff
path: root/yaksh/decorators.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-04-28 17:14:43 +0530
committerGitHub2017-04-28 17:14:43 +0530
commitb285378b2eca29e7125bf9474cd57c973a202f37 (patch)
tree726da35ba55acacfde255e31bdc2233600f75395 /yaksh/decorators.py
parent2694fd6dd4d37a1a6570792e234998feef21edca (diff)
parent624e752684125aa525d9b3643cbd7c9b7ba61682 (diff)
downloadonline_test-b285378b2eca29e7125bf9474cd57c973a202f37.tar.gz
online_test-b285378b2eca29e7125bf9474cd57c973a202f37.tar.bz2
online_test-b285378b2eca29e7125bf9474cd57c973a202f37.zip
Merge pull request #273 from adityacp/email_verification
Email verification during registration
Diffstat (limited to 'yaksh/decorators.py')
-rw-r--r--yaksh/decorators.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/yaksh/decorators.py b/yaksh/decorators.py
new file mode 100644
index 0000000..f0d354c
--- /dev/null
+++ b/yaksh/decorators.py
@@ -0,0 +1,25 @@
+from django.shortcuts import render_to_response
+from django.conf import settings
+from django.template import RequestContext
+
+
+def email_verified(func):
+ """ This decorator is used to check if email is verified.
+ If email is not verified then redirect user for email
+ verification
+ """
+
+ def is_email_verified(request, *args, **kwargs):
+ ci = RequestContext(request)
+ user = request.user
+ context = {}
+ if not settings.IS_DEVELOPMENT:
+ if user.is_authenticated() and hasattr(user, 'profile'):
+ if not user.profile.is_email_verified:
+ context['success'] = False
+ context['msg'] = "Your account is not verified. \
+ Please verify your account"
+ return render_to_response('yaksh/activation_status.html',
+ context, context_instance=ci)
+ return func(request, *args, **kwargs)
+ return is_email_verified \ No newline at end of file