Example #1
0
def loader_user(email):
    connection = pool.getconn()
    user = the_app._database.database_authorisation.search_for_user(
        connection, email)
    pool.putconn(connection)

    if user is not None:
        return user
    else:
        return None
Example #2
0
def add_new_customer(first_name, last_name, email, address, city, birth_date):
    connection = pool.getconn()
    cust_num = the_app._database.database_bank.add_customer(
        connection=connection,
        first_name=first_name,
        last_name=last_name,
        birthdate_input=birth_date,
        email=email,
        address=address,
        city=city)
    pool.putconn(connection)
    return cust_num
Example #3
0
def update_customer(cust_num, first_name, last_name, email, address, city,
                    birth_date):
    connection = pool.getconn()
    the_app._database.database_bank.update_customer(connection=connection,
                                                    cust_num=cust_num,
                                                    first_name=first_name,
                                                    last_name=last_name,
                                                    email=email,
                                                    address=address,
                                                    city=city,
                                                    birth_date=birth_date)
    pool.putconn(connection)
Example #4
0
def authenticate_user(email, password, user_remote_addr, user_agent):

    connection = pool.getconn()
    user = the_app._database.database_authorisation.search_for_user(
        connection, email)
    if user is not None and check_password_hash(user[4], password):
        the_app._database.database_authorisation.log_login(
            connection,
            id=user[0],
            email=user[1],
            username=user[2],
            role=user[3],
            agent=user_agent,
            remote_adr=user_remote_addr)
        pool.putconn(connection)
        return user
    else:
        pool.putconn(connection)
        return None
Example #5
0
def addNewUser(email, username, password):

    newUserCheck = NewUser(False, False, False)

    connection = pool.getconn()

    newUserCheck.email_exists = the_app._database.database_authorisation.check_email_exixts(
        connection, email)
    newUserCheck.username_exists = the_app._database.database_authorisation.check_username_exixts(
        connection, username)

    newUserCheck.overall_result = 1
    if (newUserCheck.email_exists) or (newUserCheck.username_exists):
        newUserCheck.overall_result = False
    else:
        newUserCheck.overall_result = True
        password_hash = generate_password_hash(password)
        the_app._database.database_authorisation.add_new_user(
            connection, email, username, password_hash)

    pool.putconn(connection)
    return newUserCheck
Example #6
0
def get_transaction_details(transaction_num):
    connection = pool.getconn()
    transactions = the_app._database.database_bank.get_transaction_details(
        connection, transaction_num)
    pool.putconn(connection)
    return transactions
Example #7
0
def make_transaction(account_in, account_out, quote, trans_type, trans_title):
    connection = pool.getconn()
    message = the_app._database.database_bank.db_transaction(
        connection, account_in, account_out, quote, trans_type, trans_title)
    pool.putconn(connection)
    return message
Example #8
0
def add_new_account(customer_num, account_name):
    connection = pool.getconn()
    account = the_app._database.database_bank.add_new_account(
        connection, customer_num, account_name)
    pool.putconn(connection)
Example #9
0
def get_last_transactions(account_num):
    connection = pool.getconn()
    account = the_app._database.database_bank.get_last_transactions(
        connection, account_num)
    pool.putconn(connection)
    return account
Example #10
0
def get_accounts(cust_num):
    connection = pool.getconn()
    accounts = the_app._database.database_bank.get_accounts(
        connection, cust_num)
    pool.putconn(connection)
    return accounts
Example #11
0
def get_customers_by_name(name):
    connection = pool.getconn()
    customers = the_app._database.database_bank.get_customers_by_name(
        connection, name)
    pool.putconn(connection)
    return customers
Example #12
0
def get_all_customers():
    connection = pool.getconn()
    customers = the_app._database.database_bank.get_all_customres(connection)
    pool.putconn(connection)
    return customers
Example #13
0
def get_customer(cust_num):
    connection = pool.getconn()
    customer = the_app._database.database_bank.get_customer(
        connection=connection, customer_number=cust_num)
    pool.putconn(connection)
    return customer