# Path: app/helpers/paging.py
# def get_paging(start, max_results, query=False, results_per_page=15, window_size=15):
# def get_paging_results(start, max_results, id, results, results_per_page):
# 
# 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/models/applicants.py
# def get_where(context='', query=None, user_id=None):
# def query(context='', query=None, offset=0, limit=50, order='creation_ts desc', user_id=None):
# def get_by_id(id):
# def admit(ids, user_id):
# def reject(ids, user_id):
# def undecide(ids, user_id):
# def grant(user_id, id, amount):
# def add_comment(id, comment):
# def rate(ids, score):
# def get_counts():
# def get_by_secret_md5(secret_md5):
# def get_dummy_record():
# def get_stats():
# 
# Path: app/models/comments.py
# def add_comment(user_id, applicant_id, comment):
# def delete_comment(user_id, id):
# def get_comments(applicant_id):
# 
# Path: app/models/votes.py
# def add(ids, score, user_id):
# def update_calculated_votes(applicant_id):
# def get_votes(applicant_id):


import web
import config
from app.helpers import paging
from app.helpers import session
from app.models import applicants
from app.models import comments
from app.models import votes
from config import view
            view.applicants(results, context, pager, i), 
            user, context, counts, i.query, stats)

class show:
    @session.login_required_for_reviews
    def GET(self, id):
        i = web.input(context='all', start=0, order=default_order, desc='desc', query='')
        start = int(i.start)
        user_id = session.is_logged() and session.get_user_id()
        
        results, num_results = applicants.query(query=i.query, context=i.context, 
            offset=start and start - 1, limit=results_per_page+2, order=i.order + ' ' + i.desc, 
            user_id=user_id)
        
        pager = web.storage(paging.get_paging_results(start, num_results, 
            int(id), results, results_per_page))
        
        counts = applicants.get_counts()
        
        user = session.get_session()
        
        applicant = applicants.get_by_id(id)
        
        _comments = comments.get_comments(applicant.id)
        
        _votes = votes.get_votes(applicant.id)
        
        stats = applicants.get_stats()
        
        return view.layout(

# Path: app/helpers/paging.py
# def get_paging(start, max_results, query=False, results_per_page=15, window_size=15):
# def get_paging_results(start, max_results, id, results, results_per_page):
# 
# 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/models/applicants.py
# def get_where(context='', query=None, user_id=None):
# def query(context='', query=None, offset=0, limit=50, order='creation_ts desc', user_id=None):
# def get_by_id(id):
# def admit(ids, user_id):
# def reject(ids, user_id):
# def undecide(ids, user_id):
# def grant(user_id, id, amount):
# def add_comment(id, comment):
# def rate(ids, score):
# def get_counts():
# def get_by_secret_md5(secret_md5):
# def get_dummy_record():
# def get_stats():
# 
# Path: app/models/comments.py
# def add_comment(user_id, applicant_id, comment):
# def delete_comment(user_id, id):
# def get_comments(applicant_id):
# 
# Path: app/models/votes.py
# def add(ids, score, user_id):
# def update_calculated_votes(applicant_id):
# def get_votes(applicant_id):


# Path: app/controllers/browse.py
import web
import config
from app.helpers import paging
from app.helpers import session
from app.models import applicants
from app.models import comments
from app.models import votes
from config import view

            view.applicants(results, context, pager, i), 
            user, context, counts, i.query, stats)

class show:
    @session.login_required_for_reviews
    def GET(self, id):
        i = web.input(context='all', start=0, order=default_order, desc='desc', query='')
        start = int(i.start)
        user_id = session.is_logged() and session.get_user_id()
        
        results, num_results = applicants.query(query=i.query, context=i.context, 
            offset=start and start - 1, limit=results_per_page+2, order=i.order + ' ' + i.desc, 
            user_id=user_id)
        
        pager = web.storage(paging.get_paging_results(start, num_results, 
            int(id), results, results_per_page))
        
        counts = applicants.get_counts()
        
        user = session.get_session()
        
        applicant = applicants.get_by_id(id)
        
        _comments = comments.get_comments(applicant.id)
        
        _votes = votes.get_votes(applicant.id)
        
        stats = applicants.get_stats()
        
        return view.layout(

            view.applicant(applicant, _comments, _votes, user, pager, i), 