diff --git a/app/config.py.example b/app/config.py.example index d296d02e..82440a28 100644 --- a/app/config.py.example +++ b/app/config.py.example @@ -114,5 +114,8 @@ LOG_FORMAT = ("{level: <8}" " - {name}:{function}" " - {message}") +# EXERCISE_FILE_PATH +EXERCISE_FILE = "web_page/exercises/Exercise_{num}.htm" + # RESOURCES RESOURCES_DIR = pathlib.Path(__file__).parent / 'resources' diff --git a/app/database/models.py b/app/database/models.py index 390896c4..226b7583 100644 --- a/app/database/models.py +++ b/app/database/models.py @@ -57,6 +57,7 @@ class User(Base): avatar = Column(String, default="profile.png") telegram_id = Column(String, unique=True) is_active = Column(Boolean, default=False) + is_active_exercise = Column(Boolean, default=False) disabled = Column(Boolean, default=False, nullable=False) privacy = Column(String, default="Private", nullable=False) is_manager = Column(Boolean, default=False) @@ -101,6 +102,18 @@ async def get_by_username(db: Session, username: str) -> User: return db.query(User).filter(User.username == username).first() +class UserExercise(Base): + """ + Table name user exercise + Save when user start his exercise + """ + __tablename__ = "user_exercise" + + id = Column(Integer, primary_key=True, index=True) + user_id = Column(Integer, ForeignKey("users.id")) + start_date = Column(DateTime, nullable=False) + + class Feature(Base): __tablename__ = "features" diff --git a/app/main.py b/app/main.py index 67136680..47543472 100644 --- a/app/main.py +++ b/app/main.py @@ -70,6 +70,7 @@ def create_tables(engine, psql_environment): dayview, email, event, + exercise, export, features, four_o_four, @@ -124,6 +125,7 @@ async def swagger_ui_redirect(): dayview.router, email.router, event.router, + exercise.router, export.router, features.router, four_o_four.router, diff --git a/app/routers/event.py b/app/routers/event.py index edc28a2f..c50b2b2b 100644 --- a/app/routers/event.py +++ b/app/routers/event.py @@ -416,7 +416,8 @@ def is_fields_types_valid(to_check: Dict[str, Any], types: Dict[str, Any]): """validate dictionary values by dictionary of types""" errors = [] for field_name, field_type in to_check.items(): - if types[field_name] and not isinstance(field_type, types[field_name]): + if types[field_name] and not isinstance(field_type, + (types[field_name])): errors.append( f"{field_name} is '{type(field_type).__name__}' and" + f"it should be from type '{types[field_name].__name__}'", diff --git a/app/routers/exercise.py b/app/routers/exercise.py new file mode 100644 index 00000000..bcbdeb35 --- /dev/null +++ b/app/routers/exercise.py @@ -0,0 +1,47 @@ +from fastapi import APIRouter, Depends, Request +from app.database.models import User +from app.dependencies import get_db, templates +from app.routers.user_exercise import get_user_exercise +from datetime import datetime +from app import config +from sqlalchemy.orm import Session + +router = APIRouter( + prefix="/exercise", + tags=["exercise"], + responses={404: {"description": "Not found"}}, +) + + +@router.get("/") +async def exercise( + request: Request, + session: Session = Depends(get_db), + ): + """ + If is active exercise = True + Show user exercise for a specific day if is_active_exercise is ture. + """ + user = session.query(User).filter_by(id=1).first() + if not user: + # create empty default user + user = User( + username='', + password='', + email='' + ) + # Get user exercise + user_exercise = get_user_exercise(session, user_id=user.id) + if user_exercise: + # Get exercise day + delta = datetime.now() - user_exercise[0].start_date + # All exercises split to 30 days + day = (delta.days % 30) + 1 + else: + day = 1 + exercise_day = str(config.EXERCISE_FILE.format(num=day)) + return templates.TemplateResponse("exercise.html", { + "request": request, + "user": user, + "exercise": exercise_day + }) diff --git a/app/routers/profile.py b/app/routers/profile.py index d69822dc..8d314df1 100644 --- a/app/routers/profile.py +++ b/app/routers/profile.py @@ -18,7 +18,8 @@ from app.internal.on_this_day_events import get_on_this_day_events from app.internal.privacy import PrivacyKinds from app.internal.showevent import get_upcoming_events - +from app.routers.user_exercise import create_user_exercise +from sqlalchemy.orm import Session PICTURE_EXTENSION = config.PICTURE_EXTENSION PICTURE_SIZE = config.AVATAR_SIZE FIVE_EVENTS = 5 @@ -39,6 +40,7 @@ def get_placeholder_user(): full_name="My Name", language_id=1, telegram_id="", + is_active_exercise=False, ) @@ -88,6 +90,32 @@ async def profile( ) +@router.get("/exercise/start") +async def start_exercise(session: Session = Depends(get_db)): + user = session.query(User).filter_by(id=1).first() + + # Update database + user.is_active_exercise = True + session.commit() + + # create user exercise + create_user_exercise(session, user) + url = router.url_path_for("profile") + return RedirectResponse(url=url, status_code=HTTP_302_FOUND) + + +@router.get("/exercise/stop") +async def stop_exercise(session=Depends(get_db)): + user = session.query(User).filter_by(id=1).first() + + # Update database + user.is_active_exercise = False + session.commit() + + url = router.url_path_for("profile") + return RedirectResponse(url=url, status_code=HTTP_302_FOUND) + + @router.post("/update_user_fullname") async def update_user_fullname(request: Request, session=Depends(get_db)): user = session.query(User).filter_by(id=1).first() diff --git a/app/routers/user_exercise.py b/app/routers/user_exercise.py new file mode 100644 index 00000000..d260b9a1 --- /dev/null +++ b/app/routers/user_exercise.py @@ -0,0 +1,51 @@ +from sqlalchemy.exc import SQLAlchemyError +from sqlalchemy.orm import Session +from datetime import datetime +from app.database.models import Base, User, UserExercise + + +def save(session: Session, instance: Base) -> bool: + """Commits an instance to the db. + source: app.database.models.Base""" + + if issubclass(instance.__class__, Base): + session.add(instance) + session.commit() + return True + return False + + +def create_user_exercise(session: Session, user: User) -> UserExercise: + """Create and save new user exercise""" + if not does_user_exercise_exist(session=session, user_id=user.id): + user_exercise = UserExercise( + user_id=user.id, + start_date=datetime.now() + ) + save(session=session, instance=user_exercise) + else: + user_exercise = update_user_exercise(session=session, user=user) + return user_exercise + + +def does_user_exercise_exist(session: Session, user_id: int) -> bool: + """Check if a user exercise for user id exists.""" + return get_user_exercise(session=session, user_id=user_id) + + +def get_user_exercise(session: Session, **param) -> list: + """Returns user exercise filter by param.""" + try: + user_exercise = list(session.query(UserExercise).filter_by(**param)) + except SQLAlchemyError: + return [] + else: + return user_exercise + + +def update_user_exercise(session: Session, user: User) -> UserExercise: + user_ex = session.query(UserExercise).filter_by(user_id=user.id).first() + # Update database + user_ex.start_date = datetime.now() + session.commit() + return user_ex diff --git a/app/static/style.css b/app/static/style.css index 170d9999..b92687d6 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -114,8 +114,13 @@ p { } .profile-modal-header { - border: none; - background-color: whitesmoke; + border: none; + background-color: whitesmoke; +} + +.exercise { + font-family: 'Assistant', sans-serif; + text-align: center; } #on, diff --git a/app/static/web_page/exercises/Exercise_1.htm b/app/static/web_page/exercises/Exercise_1.htm new file mode 100644 index 00000000..2ae07224 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_1.htm @@ -0,0 +1,1078 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 1

+ +

1. Blanket push-ups

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Blanket push-ups

+ +

2. Reverse Snow Angels:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Reverse Snow Angels

+ +

3. Squat

+ +

3.1. 3 sets

+ +

3.2. 15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do +it: Squat

+ +

4. Sit Ups

+ +

4.1. 3 sets

+ +

4.2. 15 repetitions

+ +

4.3. 45 +seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Sit Ups

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_10.htm b/app/static/web_page/exercises/Exercise_10.htm new file mode 100644 index 00000000..32d9308a --- /dev/null +++ b/app/static/web_page/exercises/Exercise_10.htm @@ -0,0 +1,1052 @@ + + + + + + + + + + + + + + + + + + + +
+ +

Day - 10

+ + + + +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_11.htm b/app/static/web_page/exercises/Exercise_11.htm new file mode 100644 index 00000000..9ea5d244 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_11.htm @@ -0,0 +1,1138 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 11

+ +

1. Push +Ups:

+ +

1.1. 3 sets

+ +

1.2. 20 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Push Ups

+ +

2. Lying +Pull Downs:

+ +

2.1. 3 sets

+ +

2.2. 20 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Lying pull downs

+ +

3. Sit Ups

+ +

3.1. 3 sets

+ +

3.2. 15 +repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Sit Ups

+ +

4. +Diamond Push-Ups

+ +

4.1. 3 sets

+ +

4.2. 20 repetitions

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Diamond Push-Ups

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_12.htm b/app/static/web_page/exercises/Exercise_12.htm new file mode 100644 index 00000000..db9a7466 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_12.htm @@ -0,0 +1,1135 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 12

+ +

1. Chair +Push Ups:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Chair Push Ups

+ +

2. Mountain Climber:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Mountain Climber

+ +

3. Twisting Side Plank

+ +

3.1. 3 sets

+ +

3.2. 15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Twisting Side Plank

+ +

4. +Plank Hip Dips

+ +

4.1. 3 sets

+ +

4.2. Stay 40 seconds each set

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Plank Hip Dips

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_13.htm b/app/static/web_page/exercises/Exercise_13.htm new file mode 100644 index 00000000..7658b303 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_13.htm @@ -0,0 +1,1185 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 13

+ + + +

1. Squat:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Squat

+ +

2. Plank Side, In & +Cross:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Plank Side, In & Cross

+ +

3. Sitting Twists

+ +

3.1. 3 sets

+ +

3.2. 15 +repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Sitting Twists

+ +

4. +Hip Abduction

+ +

4.1. 3 sets

+ +

4.2. 15 repetitions

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Hip Abduction

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_14.htm b/app/static/web_page/exercises/Exercise_14.htm new file mode 100644 index 00000000..8af78729 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_14.htm @@ -0,0 +1,1133 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 14

+ + + +

1. T-Rotational:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: T-Rotational

+ +

2. Wall Sit:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Wall Sit

+ +

3. Opposite Arm Opposite Leg

+ +

3.1. 3 sets

+ +

3.2. 15 +repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Opposite Arm Opposite Leg

+ +

4. +Single Leg Chair Plank

+ +

4.1. 3 sets

+ +

4.2. 15 repetitions

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Single Leg Chair Plank

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_15.htm b/app/static/web_page/exercises/Exercise_15.htm new file mode 100644 index 00000000..263dcbea --- /dev/null +++ b/app/static/web_page/exercises/Exercise_15.htm @@ -0,0 +1,1052 @@ + + + + + + + + + + + + + + + + + + + +
+ +

Day +- 15

+ + + + +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_16.htm b/app/static/web_page/exercises/Exercise_16.htm new file mode 100644 index 00000000..12e5892b --- /dev/null +++ b/app/static/web_page/exercises/Exercise_16.htm @@ -0,0 +1,1134 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 16

+ + + +

1. Burpees +Push Ups:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Burpees Push Ups

+ +

2. Step-up onto Chair:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Step-up onto Chair

+ +

3. Squat Jacks

+ +

3.1. 3 sets

+ +

3.2. 15 +repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Squat Jacks

+ +

4. +Ballerina Sit Up

+ +

4.1. 3 sets

+ +

4.2. 15 repetitions

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Ballerina Sit Up

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_17.htm b/app/static/web_page/exercises/Exercise_17.htm new file mode 100644 index 00000000..11e94d03 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_17.htm @@ -0,0 +1,1133 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 17

+ + + +

1. Single-Leg Hip +Lift:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Single-Leg Hip Lift

+ +

2. Back Extensions:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Back Extensions

+ +

3. Leg Lifts

+ +

3.1. 3 sets

+ +

3.2.15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Leg Lifts

+ +

4. +Elbow Plank with Extras

+ +

4.1. 3 sets

+ +

4.2. Stay 40 seconds each set

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Elbow Plank with Extras

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_18.htm b/app/static/web_page/exercises/Exercise_18.htm new file mode 100644 index 00000000..e6cf10f4 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_18.htm @@ -0,0 +1,1139 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 18

+ + + + +

1. Triceps +Dip on Chair:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Triceps Dip on Chair

+ +

2. Lunge:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Lunge

+ +

3. Opposite Arm Opposite Leg

+ +

3.1. 3 sets

+ +

3.2. 15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Opposite Arm Opposite Leg

+ +

4. +Elbow Plank

+ +

4.1. 3 sets

+ +

4.2. Stay 40 seconds each set

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Elbow Plank

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_19.htm b/app/static/web_page/exercises/Exercise_19.htm new file mode 100644 index 00000000..833c9a96 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_19.htm @@ -0,0 +1,1149 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 19

+ + + + +

1. One-Leg +Push-Ups:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: One-Leg Push-Ups

+ +

2. Lying Pull Downs:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Lying Pull Downs

+ +

3. Squat with Cross High Knee

+ +

3.1. 3 sets

+ +

3.2. 15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Squat with Cross High Knee

+ +

4. Up & Down Plank

+ +

4.1. 3 sets

+ +

4.2. 20 repetitions

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Up & Down Plank

+ +

 

+ +

 

+ +

 

+ +

 

+ +

2.   + 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_2.htm b/app/static/web_page/exercises/Exercise_2.htm new file mode 100644 index 00000000..f73a765b --- /dev/null +++ b/app/static/web_page/exercises/Exercise_2.htm @@ -0,0 +1,1130 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 2

+ + +Dip On Chair + +

1. Triceps dip on chair:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Triceps Dip on Chair

+ +

2. Lunge:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Lunge

+ +

3. Opposite Arm Opposite Leg

+ +

3.1. 3 sets

+ +

3.2. 15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Opposite Arm Opposite Leg

+ +

4. Elbow Plank

+ +

4.1. 3 sets

+ +

4.2. Stay 40 seconds each set

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Elbow Plank

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_20.htm b/app/static/web_page/exercises/Exercise_20.htm new file mode 100644 index 00000000..d669e521 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_20.htm @@ -0,0 +1,1051 @@ + + + + + + + + + + + + + + + + + + + +
+ +

Day - 20

+ + + + +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_21.htm b/app/static/web_page/exercises/Exercise_21.htm new file mode 100644 index 00000000..fcb18146 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_21.htm @@ -0,0 +1,1145 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 21

+ + + + +

1. Hip +Lift:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Hip Lift

+ +

2. Plank Jump-Ins:

+ +

2.1. 2 sets

+ +

2.2. 20 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Plank Jump-Ins

+ +

3. Crossover Crunch

+ +

3.1. 2 sets

+ +

3.2. 20 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Crossover Crunch

+ +

4. Elbow Plank

+ +

4.1. 3 sets

+ +

4.2. Stay 40 seconds each set

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Elbow Plank

+ +

 

+ +

 

+ +

 

+ +

 

+ +

2.   + 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_22.htm b/app/static/web_page/exercises/Exercise_22.htm new file mode 100644 index 00000000..520b92f6 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_22.htm @@ -0,0 +1,1148 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 22

+ + + + +

1. Push +Ups Different Types:

+ +

1.1. 3 sets

+ +

1.2. 20 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Push Ups Different +Types

+ +

2. Reverse Snow Angels:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Reverse Snow Angels

+ +

3. Calf Raise Squat

+ +

3.1. 3 sets

+ +

3.2. 15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Calf Raise Squat

+ +

4. Decline Push-Ups

+ +

4.1. 3 sets

+ +

4.2. 15 +repetitions

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Decline Push-Ups

+ +

 

+ +

 

+ +

 

+ +

 

+ +

2.   + 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_23.htm b/app/static/web_page/exercises/Exercise_23.htm new file mode 100644 index 00000000..f7d37298 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_23.htm @@ -0,0 +1,1145 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 23

+ + + + +

1. Reverse +Crunch to Sit-Up:

+ +

1.1. 2 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Reverse Crunch to Sit-Up

+ +

2. Side Lying Triceps +Extension:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Side Lying Triceps Extension

+ +

3. Wall Sit

+ +

3.1. 3 sets

+ +

3.2. 15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Wall Sit

+ +

4. Elbow Plank

+ +

4.1. 2 sets

+ +

4.2. Stay 50 seconds each set

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Elbow Plank

+ +

 

+ +

 

+ +

 

+ +

 

+ +

2.   + 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_24.htm b/app/static/web_page/exercises/Exercise_24.htm new file mode 100644 index 00000000..f3deec2a --- /dev/null +++ b/app/static/web_page/exercises/Exercise_24.htm @@ -0,0 +1,1145 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 24

+ + + + +

1. Push +Ups with Rotation:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Push Ups with Rotation

+ +

2. Reverse Snow Angels:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Reverse Snow Angels

+ +

3. Wide Grip Push-Ups

+ +

3.1. 3 sets

+ +

3.2. 15 +repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Wide Grip Push-Ups

+ +

4. Lunge

+ +

4.1. 3 sets

+ +

4.2. 20 repetitions

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Lunge

+ +

 

+ +

 

+ +

 

+ +

 

+ +

2.   + 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_25.htm b/app/static/web_page/exercises/Exercise_25.htm new file mode 100644 index 00000000..0dc16829 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_25.htm @@ -0,0 +1,1058 @@ + + + + + + + + + + + + + + + + + + + +
+ +

Day +- 25

+ + + + +

1.   +

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_26.htm b/app/static/web_page/exercises/Exercise_26.htm new file mode 100644 index 00000000..233d991f --- /dev/null +++ b/app/static/web_page/exercises/Exercise_26.htm @@ -0,0 +1,1146 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 26

+ + + + +

1. Push +Ups:

+ +

1.1. 3 sets

+ +

1.2. 20 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Push Ups

+ +

2. Lying +Pull Downs:

+ +

2.1. 3 sets

+ +

2.2. 20 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Lying pull downs

+ +

3. Sit Ups

+ +

3.1. 3 sets

+ +

3.2. 15 +repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Sit Ups

+ +

4. Diamond Push-Ups

+ +

4.1. 3 sets

+ +

4.2. 20 repetitions

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Diamond Push-Ups

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_27.htm b/app/static/web_page/exercises/Exercise_27.htm new file mode 100644 index 00000000..e58e3726 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_27.htm @@ -0,0 +1,1141 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 27

+ + + + +

1. Chair +Push Ups:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Chair Push Ups

+ +

2. Mountain Climber:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Mountain Climber

+ +

3. Twisting Side Plank

+ +

3.1. 3 sets

+ +

3.2. 15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Twisting Side Plank

+ +

4. Plank Hip Dips

+ +

4.1. 3 sets

+ +

4.2. Stay 40 seconds each set

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Plank Hip Dips

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_28.htm b/app/static/web_page/exercises/Exercise_28.htm new file mode 100644 index 00000000..e05b9b25 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_28.htm @@ -0,0 +1,1141 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 28

+ + + + +

1. Squat:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Squat

+ +

2. Plank Side, In & +Cross:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Plank Side, In & Cross

+ +

3. Sitting Twists

+ +

3.1. 3 sets

+ +

3.2. 15 +repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Sitting Twists

+ +

4. Hip Abduction

+ +

4.1. 3 sets

+ +

4.2. 15 repetitions

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Hip Abduction

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_29.htm b/app/static/web_page/exercises/Exercise_29.htm new file mode 100644 index 00000000..210bdae2 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_29.htm @@ -0,0 +1,1138 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 29

+ + + + +

1. Single-Leg Hip Lift:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Single-Leg Hip Lift

+ +

2. Back Extensions:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Back Extensions

+ +

3. Leg Lifts

+ +

3.1. 3 sets

+ +

3.2.15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Leg Lifts

+ +

4. Elbow Plank with Extras

+ +

4.1. 3 sets

+ +

4.2. Stay 40 seconds each set

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Elbow Plank with Extras

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_3.htm b/app/static/web_page/exercises/Exercise_3.htm new file mode 100644 index 00000000..1b54e833 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_3.htm @@ -0,0 +1,1137 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 3

+ + + +

1. One-Leg +Push-Ups:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: One-Leg Push-Ups

+ +

2. Lying Pull Downs:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Lying Pull Downs

+ +

3. Squat with Cross High Knee

+ +

3.1. 3 sets

+ +

3.2. 15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Squat with Cross High Knee

+ +

4. Up & Down Plank

+ +

4.1. 3 sets

+ +

4.2. 20 +repetitions

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Up & Down Plank

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_30.htm b/app/static/web_page/exercises/Exercise_30.htm new file mode 100644 index 00000000..6a99cacb --- /dev/null +++ b/app/static/web_page/exercises/Exercise_30.htm @@ -0,0 +1,1064 @@ + + + + + + + + + + + + + + + + + + + +
+ +

Day +- 30

+ + + + +

1.   + + + + + + + + + + +
+ +
 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_4.htm b/app/static/web_page/exercises/Exercise_4.htm new file mode 100644 index 00000000..fb00c3d2 --- /dev/null +++ b/app/static/web_page/exercises/Exercise_4.htm @@ -0,0 +1,1129 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 4

+ + +

1. Hip +Lift:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Hip Lift

+ +

2. Plank Jump-Ins:

+ +

2.1. 2 sets

+ +

2.2. 20 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Plank Jump-Ins

+ +

3. Crossover Crunch

+ +

3.1. 2 sets

+ +

3.2. 20 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Crossover Crunch

+ +

4. Elbow Plank

+ +

4.1. 3 sets

+ +

4.2. Stay 40 seconds each set

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Elbow Plank

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_5.htm b/app/static/web_page/exercises/Exercise_5.htm new file mode 100644 index 00000000..7bf781cc --- /dev/null +++ b/app/static/web_page/exercises/Exercise_5.htm @@ -0,0 +1,1045 @@ + + + + + + + + + + + + + + + + + + + + +
+ +

Day - 5

+ +
+ + + diff --git a/app/static/web_page/exercises/Exercise_6.htm b/app/static/web_page/exercises/Exercise_6.htm new file mode 100644 index 00000000..c8c54fcd --- /dev/null +++ b/app/static/web_page/exercises/Exercise_6.htm @@ -0,0 +1,1137 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 6

+ + + +

1. Push +Ups Different Types:

+ +

1.1. 3 sets

+ +

1.2. 20 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Push Ups Different +Types

+ +

2. Reverse Snow Angels:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Reverse Snow Angels

+ +

3. Calf Raise +Squat

+ +

3.1. 3 sets

+ +

3.2. 15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Calf Raise Squat

+ +

4. +Decline Push-Ups

+ +

4.1. 3 sets

+ +

4.2. 15 repetitions

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Decline Push-Ups

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_7.htm b/app/static/web_page/exercises/Exercise_7.htm new file mode 100644 index 00000000..caef87cb --- /dev/null +++ b/app/static/web_page/exercises/Exercise_7.htm @@ -0,0 +1,1132 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 7

+ + + +

1. Reverse +Crunch to Sit-Up:

+ +

1.1. 2 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Reverse Crunch to Sit-Up

+ +

2. Side Lying Triceps +Extension:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Side Lying Triceps Extension

+ +

3. Wall Sit

+ +

3.1. 3 sets

+ +

3.2. 15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Wall Sit

+ +

4. +Elbow Plank

+ +

4.1. 2 sets

+ +

4.2. Stay 50 seconds each set

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Elbow Plank

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_8.htm b/app/static/web_page/exercises/Exercise_8.htm new file mode 100644 index 00000000..00b0aeee --- /dev/null +++ b/app/static/web_page/exercises/Exercise_8.htm @@ -0,0 +1,1132 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 8

+ + + +

1. Push +Ups with Rotation:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Push Ups with Rotation

+ +

2. Reverse Snow Angels:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Reverse Snow Angels

+ +

3. Wide Grip Push-Ups

+ +

3.1. 3 sets

+ +

3.2. 15 +repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Wide Grip Push-Ups

+ +

4. +Lunge

+ +

4.1. 3 sets

+ +

4.2. 20 repetitions

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Lunge

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/Exercise_9.htm b/app/static/web_page/exercises/Exercise_9.htm new file mode 100644 index 00000000..62aa254f --- /dev/null +++ b/app/static/web_page/exercises/Exercise_9.htm @@ -0,0 +1,1137 @@ + + + + + + + + + + + + + + + + + + +
+ +

Day +- 9

+ + + +

1. Sphinx +& Plank:

+ +

1.1. 3 sets

+ +

1.2. 15 repetitions

+ +

1.3. 45 seconds rest between sets

+ +

1.4. Link to YouTube How to do it: Sphinx & Plank

+ +

2. Hamstring Curl on Chair:

+ +

2.1. 3 sets

+ +

2.2. 15 repetitions

+ +

2.3. 45 seconds rest between sets

+ +

2.4. Link to YouTube How to do it: Hamstring Curl on Chair

+ +

3. Cycling Cross Crunches

+ +

3.1. 3 sets

+ +

3.2. 15 repetitions

+ +

3.3. 45 seconds rest between sets

+ +

3.4. Link to YouTube How to do it: Cycling Cross Crunches

+ +

4. +Elbow Plank

+ +

4.1. 2 sets

+ +

4.2. Stay 50 seconds each set

+ +

4.3. 45 seconds rest between sets

+ +

4.4. Link to YouTube How to do it: Elbow Plank

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + diff --git a/app/static/web_page/exercises/dayoff.jpg b/app/static/web_page/exercises/dayoff.jpg new file mode 100644 index 00000000..188cb59e Binary files /dev/null and b/app/static/web_page/exercises/dayoff.jpg differ diff --git a/app/templates/base.html b/app/templates/base.html index eadfc9c1..f124b070 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -59,6 +59,9 @@ Friend View + + diff --git a/app/templates/partials/user_profile/sidebar_left/features_card.html b/app/templates/partials/user_profile/sidebar_left/features_card.html index 946d1040..2e42d71f 100644 --- a/app/templates/partials/user_profile/sidebar_left/features_card.html +++ b/app/templates/partials/user_profile/sidebar_left/features_card.html @@ -14,7 +14,15 @@ {% endif %} - + {% if not user.is_active_exercise %} +
  • + Start Exercise +
  • + {% else %} +
  • + Stop Exercise +
  • + {% endif %}
  • Add diff --git a/tests/fixtures/user_fixture.py b/tests/fixtures/user_fixture.py index e2a7ad26..e4c72ed9 100644 --- a/tests/fixtures/user_fixture.py +++ b/tests/fixtures/user_fixture.py @@ -1,9 +1,10 @@ +from datetime import datetime from typing import Generator import pytest from sqlalchemy.orm import Session -from app.database.models import User +from app.database.models import User, UserExercise from app.database.schemas import UserCreate from app.internal.utils import create_model, delete_instance from app.routers.register import create_user @@ -26,6 +27,17 @@ async def user(session: Session) -> Generator[User, None, None]: delete_instance(session, mock_user) +@pytest.fixture +def user_exercise(session: Session, user: User) -> UserExercise: + test_user_exercise = create_model( + session, UserExercise, + user_id=11, + start_date=datetime.now() + ) + yield test_user_exercise + delete_instance(session, test_user_exercise) + + @pytest.fixture def sender(session: Session) -> Generator[User, None, None]: mock_user = create_model( diff --git a/tests/test_user_exercise.py b/tests/test_user_exercise.py new file mode 100644 index 00000000..43407868 --- /dev/null +++ b/tests/test_user_exercise.py @@ -0,0 +1,39 @@ +from app.routers.user_exercise import create_user_exercise,\ + does_user_exercise_exist, get_user_exercise +from app.internal.user.user import _create_user + + +class TestUserExercise: + + def test_create_user_exercise(self, session): + user = _create_user( + session=session, + username="new_test_username", + password="new_test_password", + email="new_test.email@gmail.com", + language_id=1, + full_name="test_full_name", + description="test_description", + ) + user_exercise = create_user_exercise( + session=session, + user=user + ) + assert user_exercise.user_id == user.id + session.delete(user_exercise) + session.delete(user) + session.commit() + + def test_get_users_exercise_success(self, user_exercise, session): + assert get_user_exercise(user_id=user_exercise.user_id, + session=session) == [user_exercise] + + def test_get_user_exercise_failure(self, user_exercise, session): + assert get_user_exercise(user_id=100, session=session) == [] + + def test_does_user_exercise_exist_success(self, user_exercise, session): + assert does_user_exercise_exist(session=session, + user_id=user_exercise.user_id) + + def test_does_user_exercise_exist_failure(self, session): + assert not does_user_exercise_exist(session=session, user_id=100)