コード例 #1
0
ファイル: app.py プロジェクト: ankitaiyer/sessions
def create_account():
    username = request.form.get("username")
    password = request.form.get("password")
    model.create_account(username, password)

    #return render_template("register.html", username=username)
    return redirect(url_for("process_login"))
コード例 #2
0
ファイル: app.py プロジェクト: ankitaiyer/sessions
def create_account():
        username = request.form.get("username")
        password = request.form.get("password")
        model.create_account(username, password)

        #return render_template("register.html", username=username)
        return redirect(url_for("process_login"))
コード例 #3
0
ファイル: controller.py プロジェクト: ra1993/banking_terminal
def run():
    while True:
        selection = view.show_mainmenu()

        if selection == '1':
            model.create_account()
        elif selection == '2':
            view.show_loginmenu()
        elif selection == '3':
            exit(1)
コード例 #4
0
ファイル: app.py プロジェクト: KelseyYocum/Session-Lesson
def create_account():
    username = request.form.get("username")
    password = request.form.get("password")

    if model.given_name_return_id(username):
        flash("You already have an account!")
        return redirect(url_for("index"))
    else:
        model.create_account(username, password)
        flash ("You have successfully created an account!")
        return redirect(url_for("index"))
コード例 #5
0
def create_account():
    # if session.get("user_id"):
    #     username = model.get_username_by_userid(session.get("user_id"))
    #     return redirect(url_for("show_user_profile", username=username))
    # else: 
        print "CREATING ACCOUNT"
        username = request.form.get("username")
        password = request.form.get("password")
        print "USERMAME", username
        print "PASSWORD", password
        model.create_account(username, password)

        #return render_template("register.html", username=username)
        return redirect(url_for("process_login"))
コード例 #6
0
ファイル: app.py プロジェクト: jonahaga/Session_Lession
def create_account():
    # Receive form from Register template
    model.connect_to_db()
    username = request.form.get("username")
    
    user_id = model.get_userid_by_name(username)
    if user_id == None:
        username = request.form.get("username")
        password = request.form.get("password")
        flash("Account successfully created. Please sign in below.")
        model.create_account(username, password)
        return redirect(url_for("index"))
    else:
        flash("User already exists.")
        return redirect(url_for("register"))
コード例 #7
0
ファイル: app.py プロジェクト: jonahaga/Session_Lession
def create_account():
    # Receive form from Register template
    model.connect_to_db()
    username = request.form.get("username")

    user_id = model.get_userid_by_name(username)
    if user_id == None:
        username = request.form.get("username")
        password = request.form.get("password")
        flash("Account successfully created. Please sign in below.")
        model.create_account(username, password)
        return redirect(url_for("index"))
    else:
        flash("User already exists.")
        return redirect(url_for("register"))
コード例 #8
0
def homepage():
    while True:
        view.show_homepage()
        selection = view.get_input()

        if selection != '1' and selection != '2' and selection != '3':
            view.bad_selection()
        elif selection == '1':
            customer = get_user_info()
            if customer[2] != customer[3]:
                view.no_pin_match()
            else:
                new_customer = model.create_account(customer)
                logged_in_homepage(new_customer)
                return
        elif selection == '2':
            name = view.login_name()
            pin = view.login_pin()
            if model.login_user(name, pin):
                customer = model.login_user(name, pin)
                logged_in_homepage(customer)
                return
            else:
                view.invalid_login()
                pass
        elif selection == '3':
            view.goodbye()
            return
コード例 #9
0
def start_menu():
    # Start menu (create account, log in, exit)
    start_done = False
    while not start_done:
        user_input = view.start_menu()
        if user_input == "1":
            username, password = view.create_account_menu()
            status = model.create_account(username, password)
            print(status)
            if "Success" in status:
                start_done = True
                exit = view.wait("main menu")
                return username
            else:
                exit = view.wait("previous menu")
        elif user_input == "2":
            username, password = view.login_menu()
            status = model.login(username, password)
            print(status)
            if "Success" in status:
                start_done = True
                exit = view.wait("main menu")
                return username
            else:
                exit = view.wait("previous menu")
        elif user_input == "3":
            status = view.exit_message()
            start_done = True
            print(status)
            return "exit"
コード例 #10
0
def run():
    while True:
        choice = view.main_menu()
        if choice == "3":  #Exit
            return
        elif choice == "1":  #Create Account
            view.create_account()
            fname = view.first_name()
            lname = view.last_name()
            pin = view.choose_pin()
            initial = float(view.deposit_initial())
            #Create new account then display
            view.new_account(model.create_account(fname, lname, pin, initial))

        elif choice == "2":  #log in
            account_num, pin = view.login()
            #Check if login info is correct
            if model.login(account_num, pin) == False:
                view.bad_login()
            else:
                #Login Menu - Check Balance, Withdraw, Deposit, Open Savings Account
                info = model.login(account_num, pin)
                view.welcome(account_num, info)
                while True:
                    choice = view.login_menu()
                    if choice == "1":
                        view.check_balance(info)
                    elif choice == "2":
                        login_withdrawal(account_num)  #see line 58
                    elif choice == "3":
                        num = view.deposit()
                        new_balance = model.deposit(num, account_num)
                        view.deposit_new_balance(num, new_balance)
                    elif choice == "4":
                        from_account, to_account, amount = view.transfer()

                        #Add " account" at the end of the string so it matches the key in the dictionary
                        from_account = from_account + " account"
                        to_account = to_account + " account"
                        #convert amount value from string to float
                        amount = float(amount)

                        info = model.transfer(from_account, to_account, amount,
                                              account_num)
                        view.transfer_new_balance(info, from_account,
                                                  to_account)
                    elif choice == "5":
                        yesorno, deposit = view.create_savings()
                        model.open_savings(yesorno, float(deposit),
                                           account_num)
                        view.savings_opened(float(deposit))
                    elif choice == "6":
                        view.signout()
                        return
        else:
            view.bad_input()
コード例 #11
0
ファイル: admin.py プロジェクト: heliumpigs/snowball
 def put(self, path):
     if path.startswith('/controller/accounts/'):
         name = path[21:]
         password = self.get_argument('password')
         
         if not model.create_account(self.db, name, password):
             raise web.HTTPError(409, 'account already exists')
         
     else:
         raise web.HTTPError(404, 'not found')
コード例 #12
0
def account_create_loop():
    fname, lname, pin_try, pin_confirm = view.account_create_menu()
    if pin_confirm == pin_try:
        pin = pin_try
        new_account_num = model.create_account(fname, lname, pin)
        print("account created, your account number is {}.".format(
            new_account_num))
        main_loop()
    else:
        print("Please confirm pin matches and re-enter")
        account_create_loop()
コード例 #13
0
ファイル: controller.py プロジェクト: amudera/test_repo
def mainmenu(selection):
    while True:
        if selection == '3':
            model.save()
            break ### this is not exiting the program
        elif selection == '1':
            firstname = view.First()
            lastname = view.Last()
            genpin = view.create_PIN()
            model.create_account(firstname,lastname,genpin)
            model.save()
            run()
        elif selection == '2':
            checkac = view.login_ac()
            checkpin = view.login_pin()
            if model.login_verify(checkac,checkpin) == True:
                secondary() 
            else:
                run()
        else:
            view.bad_input()
            run()
コード例 #14
0
def signup():
    if request.method == 'GET':
        return render_template('signup.html')
    else:
        username = request.form['username']
        password = request.form['password']

        if model.user_exists(username):
            error_message = 'Username already exists'
            return render_template('signup.html', message=error_message)

        message = model.create_account(username, password)
        return render_template('signup.html', message=message)
コード例 #15
0
def register_user():
    model.connect_to_db()
    username = request.form.get("username")
    password = request.form.get("password")
    password_verify = request.form.get("password_verify")
    response = model.create_account(username, password, password_verify)
    if response == 1:
        flash("That name is already in use. Please try again.")
        return redirect(url_for("register"))
    elif response == 2:
        flash("Passwords do not match. Please try again.")
        return redirect(url_for("register"))
    else:
        flash("Success! Please log in to view your wall.")
        return redirect(url_for("index"))
コード例 #16
0
def initialmenu():
    while True:
        view.show_initalmenu()
        selection = view.get_input()
        print(selection)
        if selection == '1':
            new_Firstname = view.get_FirstName()
            new_LastName = view.get_LastName()
            new_pin = view.get_pin()
            newaccount = model.create_account(new_Firstname, new_LastName,
                                              new_pin)
            model.save(newaccount)

        elif selection == '2':
            clientcheck = view.clientcheck()
            accountcheck = int(view.accountcheck())
            pin = int(view.pincheck())
            model.login(clientcheck, accountcheck, pin)
            mainmenu(clientcheck, accountcheck)

        elif selection == '3':
            pass
        else:
            view.bad_input()
コード例 #17
0
def debit_loop(db_name, module_logger):

    create_input = ['c', 'create']      # create account
    charge_input = ['r', 'charge']      # charge account
    hold_input = ['h', 'hold']          # place hold on account
    settle_input = ['s', 'settle']      # release hold & charge actual amount
    quit_input = ['q', 'quit']          # exit the game

    # valid input is combination of all other inputs
    valid_actions = create_input + charge_input + hold_input + settle_input + quit_input

    msg = 'Valid actions are: [' + ','.join(valid_actions) + ']'
    view.show_user_results(msg)

    # Loop until user requests to quit
    switched_on = True
    while switched_on:
        user_input = view.menu().lower()

        # perform user requested action
        if user_input in create_input:
            # create_account(initial_balance)
            amt, ignore1, ignore2, valid_input = get_user_input(['amount'])

            if valid_input:
                acct_num = model.create_account(amt, db_name)
                if acct_num == -1:
                    view.show_user_results('Failed to create account')
                else:
                    msg = 'New account number = {acct_num} Initial balance = {amt}.'.\
                        format(acct_num=acct_num, amt=amt)
                    view.show_user_results(msg)
                    module_logger.info(msg)

        elif user_input in charge_input:
            # charge(account_id, amount)
            # get user input
            amt, acct_num, ignore2, valid_input = get_user_input(['amount', 'account'])

            # if user entered valid input, process it
            if valid_input:
                ret_sts = model.charge(acct_num, amt, db_name)
                if ret_sts == 0:
                    msg = 'Successfully charge account {acct_num} {amt}'.\
                        format(acct_num=acct_num, amt=amt)
                elif ret_sts == -1:
                    msg = 'Failed to charge account {acct_num}'.format(acct_num=acct_num)
                elif ret_sts == -2:
                    msg = 'Insufficient funds to charge account {acct_num} {amt}'.\
                        format(acct_num=acct_num, amt=amt)
                else:
                    msg = 'Unknown status returned from model.charge {ret_sts}'.\
                        format(ret_sts=ret_sts)
                view.show_user_results(msg)
                module_logger.info(msg)

        elif user_input in hold_input:
            # hold(account_id, vendor_id, amount)
            # get user input
            amt, acct_num, vendor_id, valid_input = get_user_input(['amount', 'account', 'vendor'])

            # if user entered valid input, process it
            if valid_input:
                ret_sts = model.hold(acct_num, vendor_id, amt, db_name)
                if ret_sts == 0:
                    msg = 'Hold on account {acct_num} for {amt} is successful'.\
                        format(acct_num=acct_num, amt=amt)
                elif ret_sts == -1:
                    msg = 'Failed to place hold on account {acct_num} for {amt}'.\
                        format(acct_num=acct_num, amt=amt)
                elif ret_sts == -2:
                    msg = 'Insufficient funds to place hold on account {acct_num} for {amt}'.\
                        format(acct_num=acct_num, amt=amt)
                elif ret_sts == -3:
                    msg = 'Only 1 hold per vendor id for account {acct_num}'.\
                        format(acct_num=acct_num)
                else:
                    msg = 'Unknown status returned from model.hold {ret_sts}'.\
                        format(ret_sts=ret_sts)
                view.show_user_results(msg)
                module_logger.info(msg)

        elif user_input in settle_input:
            # settle_hold(account_id, vendor_id, actual_amount)
            # get user input
            amt, acct_num, vendor_id, valid_input = get_user_input(['amount', 'account', 'vendor'])

            if valid_input:
                ret_sts = model.settle_hold(acct_num, vendor_id, amt, db_name)
                if ret_sts == 0:
                    msg = 'Settle hold on account {acct_num} for {amt} is successful'.\
                            format(acct_num=acct_num, amt=amt)
                elif ret_sts == -1:
                    msg = 'Failed to settle hold on account {acct_num}'.\
                            format(acct_num=acct_num)
                elif ret_sts == -2:
                    msg = 'Insufficient funds to settle hold on account {acct_num} for {amt}'. \
                        format(acct_num=acct_num, amt=amt)
                else:
                    msg = 'Unknown status returned from model.hold {ret_sts}'. \
                        format(ret_sts=ret_sts)
                view.show_user_results(msg)
                module_logger.info(msg)

        elif user_input in quit_input:
            view.show_user_results('Thanks for playing.  Goodbye!')
            module_logger.info('User entered quit')
            switched_on = False
            # break
        else:
            view.show_user_results('Invalid input')
            msg = 'Valid actions are: [' + ','.join(valid_actions) + ']'
            view.show_user_results(msg)
コード例 #18
0
ファイル: setup.py プロジェクト: heliumpigs/snowball
def add_test_users(db):
    """Adds the users that are used in the test cases to the database"""
        
    for account in SAMPLE_DATA_ACCOUNTS:
        model.create_account(db, account, 'sandbox')