From 628aad5e0369789297e523c5dd920eed584dcf78 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Thu, 11 Jun 2015 21:01:58 +0300 Subject: [PATCH] added 2 methods (is_lecturer, get_user_by_token) --- SE_API/Validation_Utils.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/SE_API/Validation_Utils.py b/SE_API/Validation_Utils.py index 836e4d1..12c35d9 100644 --- a/SE_API/Validation_Utils.py +++ b/SE_API/Validation_Utils.py @@ -4,14 +4,27 @@ from models.User import User from google.appengine.api import mail -def is_user_token_valid(token): +def get_user_by_token(token): query = User.all() query.filter("seToken = ", token) - for u in query.run(): + for u in query.run(limit = 1): + return u + return None + +def is_user_token_valid(token): + user = get_user_by_token(token) + if user is not None: return True return False +def is_lecturer(token): + user = get_user_by_token(token) + if user is None: + return False + return user.isLecturer + + def send_validation_email(token, email, name): message = mail.EmailMessage(sender="SE-Hub Support ", subject="SE-Hub Activate Account")