Пример #1
0
def create_workout():
    # Form data
    name        = request.form['name']
    category    = request.form['category']
    capacity    = request.form['capacity']
    # Format date
    date        = request.form['date']
    # Split the date into a list
    split_date = date.split('-')
    # create a new date object
    date = datetime.date(int(split_date[0]), int(split_date[1]), int(split_date[2]))

    # Format time
    start_time  = request.form['start_time']
    # Split the time into a list
    split_start_time = start_time.split(':')
    # create new time object
    start_time = datetime.time(int(split_start_time[0]), int(split_start_time[1]))

    # Create new Workout object
    workout = Workout(name, category, date, start_time, capacity)
    # Save to db
    workout_repository.save(workout)
    # Redirect
    return redirect('/workouts')
def create_workout():
    activity_id = request.form['activity_id']
    day = request.form['day']
    time = request.form['time']
    capacity = request.form['capacity']
    activity = activity_repository.select(activity_id)
    workout = Workout(activity, day, time, capacity)
    workout_repository.save(workout)
    return redirect('/workouts')
Пример #3
0
def create_workout():
    name = request.form['name']
    type = request.form['type']
    duration = request.form['duration']
    date = request.form['date']
    capacity = request.form['capacity']
    workout = Workout(name, type, duration, date, capacity)
    workout_repository.save(workout)
    return redirect('/workouts')
member_repository.save(member_3)

member_test = member_repository.select_all()
print(member_test[1].name)

#MEMBER_REPOSITORY
#Save function - working
#Select all function - working
#Select by id function - working
#Delete all functon - working
#Delete by id function - working
#Update function - working

#Default Workouts
workout_1 = Workout("Fuego", "HIIT", 45, "5th December 2020", 5)
workout_repository.save(workout_1)

workout_2 = Workout("Stretch", "Yoga", 70, "6th December 2020", 3)
workout_repository.save(workout_2)

workout_3 = Workout("Spin", "Cycle", 30, "7th December 2020", 15)
workout_repository.save(workout_3)

workout_test = workout_repository.select_all()
print(workout_test[2].name)

#WORKOUT_REPOSITORY
#Save function - working
#Select all function - working
#Select by id function - working
#Delete all functon - working
Пример #5
0
activity7 = Activity("Chess", "class_chess.jpg", "Bernie")
activity_repository.save(activity7)

activity8 = Activity("Irish Dancing", "class_irishdancing.jpg", "Siobhan")
activity_repository.save(activity8)

activity9 = Activity("Rubiks Cube", "class_rubiks.jpg", "Sergiei")
activity_repository.save(activity9)

activity10 = Activity("Salsa", "class_salsa.jpg", "Rocio")
activity_repository.save(activity10)

activity11 = Activity("Step", "class_step.jpg", "Angie")
activity_repository.save(activity11)

activity12 = Activity("Swimming", "class_swimming.jpg", "Donald")
activity_repository.save(activity12)

workout1 = Workout(activity1, "Monday", "10", 20)
workout_repository.save(workout1)

workout2 = Workout(activity2, "Tuesday", "14", 10)
workout_repository.save(workout2)

booking1 = Booking(member1, workout1)
booking_repository.save(booking1)

booking2 = Booking(member2, workout2)
booking_repository.save(booking2)

pdb.set_trace()