def homebay(): action = request.args.get('action', '') bay = request.args.get('bay', '') # Handle if the user didn't give a bay or an action # Action is either update or remove if (action == '' or bay == ''): page['bar'] = False flash("Error, no bay or action submitted.") return (redirect(url_for('index'))) if (action == 'update'): # Update the homebay outcome = database.update_homebay(user_details['email'], bay) # Is it successful? if (outcome): user_details['homebay'] = bay page['bar'] = True flash("Success, homebay updated!") else: page['bar'] = False flash("There was an error adding your homebay.") return (redirect('{}?bay={}'.format(url_for('list_bays'), bay))) else: page['bar'] = False flash("Error, invalid action") return (redirect(url_for('index')))
def homebay(): action = request.args.get('action', '') bay = request.args.get('bay', '') # Handle if the user didn't give a bay or an action # Action is either update or remove if(action == '' or bay == ''): page['bar'] = False flash("Error, no bay or action submitted.") return(redirect(url_for('index'))) if(action == 'update'): # Update the homebay outcome = database.update_homebay(user_details['email'], bay) # Is it successful? if(outcome): page['bar'] = True user_details['homebay'] = outcome[0] # update user_details with new homebay flash("Success, homebay updated!") else: page['bar'] = False flash("There was an error adding your homebay.") return(redirect('{}?bay={}'.format(url_for('list_bays'), bay))) else: page['bar'] = False flash("Error, invalid action") return(redirect(url_for('index')))