Ejemplo n.º 1
0
def toggle_admin(username):
    acct = Account.from_username(username)
    if acct.admin == 1:
        view.admin_on(username)
    elif acct.admin == 0:
        view.admin_off(username)
    while True:
        choice = view.toggle()
        if choice == '1':
            acct.admin = 1
            acct.save()
            view.admin_switched_on(username)
        elif choice == '0':
            acct.admin = 0
            view.admin_switched_off(username)
            acct.save()
        elif choice == 'q':
            break
        else:
            invalid_admin_choice()
Ejemplo n.º 2
0
def create_account():
    view.intro_create_acc()
    first = view.input_first()
    last = view.input_last()
    username = view.input_username()
    password = view.input_password(
    )  #this is the start of what will become the password hash
    balance = 0
    email = view.input_email()
    new_account = Account(first=first,
                          last=last,
                          username=username,
                          balance=balance,
                          email=email)
    #password_hash=password_hash - not used b/c save in set pw fucntion
    new_account.set_password(
        password)  #creates the password has which is missing in the above line
    if Account.from_username(username) is None:
        new_account.save(
        )  #save function to put the new account into the sql db
    else:
        raise view.UsernameUnavailableError