added 2 methods (is_lecturer, get_user_by_token)

This commit is contained in:
Aran Zaiger 2015-06-11 21:01:58 +03:00
parent dcb83987f8
commit 628aad5e03

View file

@ -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 <se-hub@appspot.gserviceaccount.com>",
subject="SE-Hub Activate Account")