# Path: app/helpers/utils.py
# def dict_remove(d, *keys):
# def capitalize_first(str):
# def make_unique_md5():
# def get_all_functions(module):
# def sqlands(left, lst):
# def get_ip():
# def store(tablename, _test=False, **values):
# 
# 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 config import db
from app.helpers import utils
from app.helpers import email_templates
from cStringIO import StringIO
from datetime import date
# Author: Alex Ksikes




resume_dir = 'public/resumes/'

def submit_application(resume, d, simple=False):
    # clean up some fields
    clean_up_data(d)
    # handle the file upload
    d.resume_fn = save_resume(resume, d.first_name, d.last_name)
    # in simple mode, no reference is required
    if simple:
        # save the data in the db
        add_applicant(d)
        # email user and referee
        email_templates.to_applicant_simple(d)
    else:
        # make secret md5
        d.secret_md5 = utils.make_unique_md5()
        # save the data in the db
        add_applicant(d)
        # email user and referee

# Path: app/helpers/utils.py
# def dict_remove(d, *keys):
# def capitalize_first(str):
# def make_unique_md5():
# def get_all_functions(module):
# def sqlands(left, lst):
# def get_ip():
# def store(tablename, _test=False, **values):
# 
# 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/models/submissions.py
import web
from config import db
from app.helpers import utils
from app.helpers import email_templates
from cStringIO import StringIO
from datetime import date

# Author: Alex Ksikes




resume_dir = 'public/resumes/'

def submit_application(resume, d, simple=False):
    # clean up some fields
    clean_up_data(d)
    # handle the file upload
    d.resume_fn = save_resume(resume, d.first_name, d.last_name)
    # in simple mode, no reference is required
    if simple:
        # save the data in the db
        add_applicant(d)
        # email user and referee
        email_templates.to_applicant_simple(d)
    else:
        # make secret md5
        d.secret_md5 = utils.make_unique_md5()
        # save the data in the db
        add_applicant(d)
        # email user and referee

        email_templates.to_applicant(d)