def update_customer(id): name = request.form['name'] membership = request.form['membership'] gym_id = request.form['gym'] gym = gym_repository.select(gym_id) customer = Customer(name, membership, gym, id) customer_repository.update(customer) return redirect("/customers")
def select(id): customer = None sql = "SELECT * FROM customers WHERE id = %s" values = [id] result = run_sql(sql, values)[0] gym = gym_repository.select(result['gym_id']) customer = Customer(result["name"], result["membership"], gym, result["id"]) return customer
def update_activity(id): activity_type = request.form['activity_type'] duration = request.form['duration'] difficulty = request.form['difficulty'] gym_id = request.form['gym'] gym = gym_repository.select(gym_id) activity = Activity(gym, activity_type, duration, difficulty, id) activity_repository.update(activity) return redirect("/all-activities")
def select(id): activity = None sql = "SELECT * FROM activities WHERE id = %s" values = [id] result = run_sql(sql, values)[0] gym = gym_repository.select(result['gym_id']) activity = Activity(gym, result["activity"], result["duration"], result["difficulty"], result["id"]) return activity
def select_all(): customers = [] sql = "SELECT * FROM customers" results = run_sql(sql) for row in results: gym = gym_repository.select(row['gym_id']) customer = Customer(row['name'], row['membership'], gym, row['id']) customers.append(customer) return customers
def select_all(): activities = [] sql = "SELECT * FROM activities" results = run_sql(sql) for row in results: gym = gym_repository.select(row['gym_id']) activity = Activity(gym, row['activity'], row['duration'], row['difficulty'], row['id']) activities.append(activity) return activities