# Path: app/models/users.py
# def create_account(email, password, nickname):
# def get_user_by_email(email):
# def is_email_available(email):
# def is_valid_password(password):
# def is_correct_password(email, password):
# def update(id, **kw):
# def get_user_by_id(id):
# 
# Path: app/helpers/session.py
# def add_sessions_to_app(app):
# def get_session():
# def is_logged():
# def login(email):
# def logout():
# def reset():
# def get_user_id():
# def get_last_visited_url():
# def set_last_visited_url():
# def login_required(meth):
#     def new(*args):
# def login_required_for_reviews(meth):
#     def new(*l):
# 
# Path: app/helpers/email_templates.py
# def to_applicant(applicant):
# def to_applicant_simple(applicant):
# def to_referee(applicant):
# def notify_applicant(applicant):
# def notify_referee(applicant):
# def resend_password(user):


import web
from web import form
from app.models import users
from app.helpers import session
from app.helpers import email_templates
from config import view
# Author: Alex Ksikes 




vemail = form.regexp(r'.+@.+', 'Please enter a valid email address')
login_form = form.Form(
    form.Textbox('email', 
        form.notnull, vemail,
        description='Your email:'),
    form.Password('password', 
        form.notnull,
        description='Your password:'),
                
    form.Button('submit', type='submit', value='Login'),
    validators = [
        form.Validator('Incorrect email / password combination.', 
            lambda i: users.is_correct_password(i.email, i.password))
    ]
)

register_form = form.Form(
    form.Textbox('email', 
        form.notnull, vemail,
        form.Validator('This email address is already taken.', 

# Path: app/models/users.py
# def create_account(email, password, nickname):
# def get_user_by_email(email):
# def is_email_available(email):
# def is_valid_password(password):
# def is_correct_password(email, password):
# def update(id, **kw):
# def get_user_by_id(id):
# 
# Path: app/helpers/session.py
# def add_sessions_to_app(app):
# def get_session():
# def is_logged():
# def login(email):
# def logout():
# def reset():
# def get_user_id():
# def get_last_visited_url():
# def set_last_visited_url():
# def login_required(meth):
#     def new(*args):
# def login_required_for_reviews(meth):
#     def new(*l):
# 
# Path: app/helpers/email_templates.py
# def to_applicant(applicant):
# def to_applicant_simple(applicant):
# def to_referee(applicant):
# def notify_applicant(applicant):
# def notify_referee(applicant):
# def resend_password(user):


# Path: app/controllers/account.py
import web
from web import form
from app.models import users
from app.helpers import session
from app.helpers import email_templates
from config import view

# Author: Alex Ksikes 




vemail = form.regexp(r'.+@.+', 'Please enter a valid email address')
login_form = form.Form(
    form.Textbox('email', 
        form.notnull, vemail,
        description='Your email:'),
    form.Password('password', 
        form.notnull,
        description='Your password:'),
                
    form.Button('submit', type='submit', value='Login'),
    validators = [
        form.Validator('Incorrect email / password combination.', 
            lambda i: users.is_correct_password(i.email, i.password))
    ]
)

register_form = form.Form(
    form.Textbox('email', 
        form.notnull, vemail,
        form.Validator('This email address is already taken.', 

        lambda x: users.is_email_available(x)),