def select(id): sql = 'SELECT * FROM activities WHERE id = %s' values = [id] results = run_sql(sql, values)[0] trainer = trainer_repository.select(results['trainer_id']) activity = Activity(results['name'], results['date'], results['time'], trainer, results['capacity'], results['id']) return activity
def update_activity(id): name = request.form['name'] date = request.form['date'] time = request.form['time'] capacity = request.form['capacity'] trainer = trainer_repository.select(request.form['trainer_id']) activity = Activity(name, date, time, trainer, capacity, id) activity_repository.update(activity) return redirect("/activities")
def create_activity(): name = request.form['name'] date = request.form['date'] time = request.form['time'] trainer = trainer_repository.select(request.form['trainer']) capacity = request.form['capacity'] activity = Activity(name, date, time, trainer, capacity) activity_repository.save(activity) return redirect("/activities")
def select(id): sql = "SELECT * FROM exercise_classes WHERE id = %s" values = [id] result = run_sql(sql, values)[0] trainer = trainer_repository.select(result["trainer_id"]) exercise_class = ExerciseClass(result['name'], result['type'], result['duration'], result['schedule'], trainer, result['id']) return exercise_class
def select_all(): activities = [] sql = 'SELECT * FROM activities' results = run_sql(sql) for row in results: trainer = trainer_repository.select(row['trainer_id']) activity = Activity(row['name'], row['date'], row['time'], trainer, row['capacity'], row['id']) activities.append(activity) return activities
def select_all(): pokemons = [] sql = "SELECT * FROM pokemons" results = run_sql(sql) for row in results: nurse = nurse_repository.select(row['nurse_id']) trainer = trainer_repository.select(row['trainer_id']) pokemon = Pokemon(row['nickname'], row['species'], row['type'], row['dob'], trainer, row['status'], row['id']) pokemon.assign_nurse(nurse) pokemons.append(pokemon) return (pokemons)
def select_all(): exercise_classes = [] sql = "SELECT * FROM exercise_classes" results = run_sql(sql) for result in results: trainer = trainer_repository.select(result["trainer_id"]) exercise_class = ExerciseClass(result['name'], result['type'], result['duration'], result['schedule'], trainer, result['id']) exercise_classes.append(exercise_class) # print(vars(exercise_class)) return exercise_classes
def select(id): pokemon = None sql = "SELECT * FROM pokemons WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: nurse = nurse_repository.select(result['nurse_id']) trainer = trainer_repository.select(result['trainer_id']) pokemon = Pokemon(result['nickname'], result['species'], result['type'], result['dob'], trainer, result['status'], result['id']) pokemon.assign_nurse(nurse) return pokemon
def edit_pokemon(id): nickname = request.form['nickname'] species = request.form['species'] type = request.form['type'] dob = request.form['dob'] trainer_id = request.form['trainer_id'] status = request.form['status'] nurse_id = request.form['nurse_id'] trainer = trainer_repository.select(trainer_id) nurse = nurse_repository.select(nurse_id) pokemon = Pokemon(nickname, species, type, dob, trainer, status, id) pokemon.assign_nurse(nurse) pokemon_repository.update(pokemon) return redirect('/pokemon')
def search(category, search): pokemons = [] if category == "nickname": sql = "SELECT * FROM pokemons WHERE nickname = %s" elif category == "type": sql = "SELECT * FROM pokemons WHERE type = %s" elif category == "species": sql = "SELECT * FROM pokemons WHERE species = %s" elif category == "status": sql = "SELECT * FROM pokemons WHERE status = %s" values = [search] results = run_sql(sql, values) for row in results: nurse = nurse_repository.select(row['nurse_id']) trainer = trainer_repository.select(row['trainer_id']) pokemon = Pokemon(row['nickname'], row['species'], row['type'], row['dob'], trainer, row['status'], row['id']) pokemon.assign_nurse(nurse) pokemons.append(pokemon) return pokemons
def show_trainers_pokemon(id): pokemons = pokemon_repository.select_all() trainer = trainer_repository.select(id) return render_template("/trainers/pokemon.html", pokemons = pokemons, trainer = trainer)
def edit_page(id): trainer = trainer_repository.select(id) return render_template("/trainers/edit.html", trainer = trainer)
def show_trainer(id): trainer = trainer_repository.select(id) activities = trainer_repository.activities(id) return render_template("trainers/show.html", trainer=trainer, activities=activities)
def show(id): trainer = trainer_repository.select(id) classes = trainer_repository.get_classes(trainer) return render_template("trainers/show.html", trainer=trainer, classes=classes)