Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Sovraska committed Dec 23, 2023
2 parents 1009c1f + e78adf0 commit c73f1f7
Show file tree
Hide file tree
Showing 41 changed files with 279 additions and 308 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Django-app workflow

on:
push:
branches: [ "develop" ]
branches: [ "develop"]
pull_request:
branches: [ "develop" ]
workflow_dispatch:
Expand All @@ -22,4 +22,5 @@ jobs:
- name: flake8 Lint
uses: py-actions/flake8@v2
with:
path: "app"
path: "app"
- uses: isort/isort-action@master
2 changes: 1 addition & 1 deletion alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import os
from logging.config import fileConfig

from alembic import context
from dotenv import load_dotenv
from sqlalchemy import pool
from sqlalchemy.ext.asyncio import async_engine_from_config

from alembic import context
from app.core.base import Base

config = context.config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
Create Date: 2023-12-15 11:49:39.453458
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = '043420d3cabe'
Expand Down
3 changes: 1 addition & 2 deletions alembic/versions/12ebaaa6044c_course_tariff_relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
Create Date: 2023-12-15 19:02:40.113127
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = '12ebaaa6044c'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
Create Date: 2023-12-15 12:15:12.153616
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = '3a82c343b806'
Expand Down
3 changes: 1 addition & 2 deletions alembic/versions/4098f76764d4_initial_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
Create Date: 2023-12-07 23:54:47.680798
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = '4098f76764d4'
Expand Down
3 changes: 1 addition & 2 deletions alembic/versions/b6230f9d49dc_course_user_relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
Create Date: 2023-12-15 18:51:03.288013
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = 'b6230f9d49dc'
Expand Down
3 changes: 1 addition & 2 deletions alembic/versions/d1e8da8e858b_course_task_relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
Create Date: 2023-12-15 19:21:08.180548
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = 'd1e8da8e858b'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
Create Date: 2023-12-15 10:55:10.899967
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = 'da73f8287221'
Expand Down
10 changes: 5 additions & 5 deletions app/api/endpoints/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .user import router as user_router # noqa
from .achievement import router as achievement_router # noqa
from .course import router as course_router # noqa
from .examination import router as examination_router # noqa
from .group import router as group_router # noqa
from .notification import router as notification_router # noqa
from .profile import router as profile_router # noqa
from .tariff import router as tariff_router # noqa
from .notification import router as notification_router # noqa
from .examination import router as examination_router # noqa
from .achievement import router as achievement_router # noqa
from .course import router as course_router # noqa
from .task import router as task_router # noqa
from .user import router as user_router # noqa
22 changes: 10 additions & 12 deletions app/api/endpoints/achievement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,36 @@
from sqlalchemy.ext.asyncio import AsyncSession

from app.api.validators import check_name_duplicate
from app.schemas.achievement import AchievementRead, AchievementCreate
from app.core.db import get_async_session
from app.crud import achievement_crud
from app.schemas.achievement import AchievementCreate, AchievementRead
from app.services.endpoints_services import delete_obj

router = APIRouter()


@router.get('/', response_model=list[AchievementRead])
@router.get("/", response_model=list[AchievementRead])
async def get_all_achievements(
session: AsyncSession = Depends(get_async_session)
session: AsyncSession = Depends(get_async_session),
) -> list[AchievementRead]:
"""Возвращает все achievement."""
return await achievement_crud.get_multi(session)


@router.post('/', response_model=AchievementRead)
@router.post("/", response_model=AchievementRead)
async def create_achievement(
achievement: AchievementCreate,
session: AsyncSession = Depends(get_async_session)
achievement: AchievementCreate,
session: AsyncSession = Depends(get_async_session)
):
"""Создать Achievement"""
await check_name_duplicate(achievement.name, achievement_crud, session)
return await achievement_crud.create(
obj_in=achievement, session=session
)
return await achievement_crud.create(obj_in=achievement, session=session)


@router.delete('/{obj_id}')
@router.delete("/{obj_id}")
async def delete_achievement(
obj_id: int,
session: AsyncSession = Depends(get_async_session),
obj_id: int,
session: AsyncSession = Depends(get_async_session),
):
"""Удалить объект"""
return await delete_obj(
Expand Down
21 changes: 9 additions & 12 deletions app/api/endpoints/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,35 @@
from sqlalchemy.ext.asyncio import AsyncSession

from app.api.validators import check_name_duplicate
from app.schemas.course import CourseCreate, CourseRead
from app.core.db import get_async_session
from app.crud import course_crud
from app.schemas.course import CourseCreate, CourseRead
from app.services.endpoints_services import delete_obj

router = APIRouter()


@router.get('/', response_model=list[CourseRead])
@router.get("/", response_model=list[CourseRead])
async def get_all_courses(
session: AsyncSession = Depends(get_async_session)
session: AsyncSession = Depends(get_async_session),
) -> list[CourseRead]:
"""Возвращает все courses."""
return await course_crud.get_multi(session)


@router.post('/', response_model=CourseRead)
@router.post("/", response_model=CourseRead)
async def create_course(
course: CourseCreate,
session: AsyncSession = Depends(get_async_session)
course: CourseCreate, session: AsyncSession = Depends(get_async_session)
):
"""Создать Course"""
await check_name_duplicate(course.name, course_crud, session)
return await course_crud.create(
obj_in=course, session=session
)
return await course_crud.create(obj_in=course, session=session)


@router.delete('/{obj_id}')
@router.delete("/{obj_id}")
async def delete_course(
obj_id: int,
session: AsyncSession = Depends(get_async_session),
obj_id: int,
session: AsyncSession = Depends(get_async_session),
):
"""Удалить объект"""
return await delete_obj(obj_id=obj_id, crud=course_crud, session=session)
18 changes: 9 additions & 9 deletions app/api/endpoints/examination.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
from sqlalchemy.ext.asyncio import AsyncSession

from app.api.validators import check_name_duplicate
from app.schemas.examination import ExaminationRead, ExaminationCreate
from app.core.db import get_async_session
from app.crud import examination_crud
from app.schemas.examination import ExaminationCreate, ExaminationRead
from app.services.endpoints_services import delete_obj

router = APIRouter()


@router.get('/', response_model=list[ExaminationRead])
@router.get("/", response_model=list[ExaminationRead])
async def get_all_examinations(
session: AsyncSession = Depends(get_async_session)
session: AsyncSession = Depends(get_async_session),
) -> list[ExaminationRead]:
"""Возвращает все Examination."""
return await examination_crud.get_multi(session)


@router.post('/', response_model=ExaminationRead)
@router.post("/", response_model=ExaminationRead)
async def create_examination(
examination: ExaminationCreate,
session: AsyncSession = Depends(get_async_session)
examination: ExaminationCreate,
session: AsyncSession = Depends(get_async_session)
):
"""Создать Examination"""
await check_name_duplicate(examination.name, examination_crud, session)
Expand All @@ -30,10 +30,10 @@ async def create_examination(
)


@router.delete('/{obj_id}')
@router.delete("/{obj_id}")
async def delete_examination(
obj_id: int,
session: AsyncSession = Depends(get_async_session),
obj_id: int,
session: AsyncSession = Depends(get_async_session),
):
"""Удалить объект"""
return await delete_obj(
Expand Down
23 changes: 10 additions & 13 deletions app/api/endpoints/group.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession

from app.schemas.group import GroupRead, GroupCreate
from app.api.validators import check_name_duplicate
from app.core.db import get_async_session
from app.crud import group_crud
from app.api.validators import check_name_duplicate
from app.schemas.group import GroupCreate, GroupRead
from app.services.endpoints_services import delete_obj

router = APIRouter()


@router.get('/', response_model=list[GroupRead])
@router.get("/", response_model=list[GroupRead])
async def get_all_groups(
session: AsyncSession = Depends(get_async_session)
session: AsyncSession = Depends(get_async_session),
) -> list[GroupRead]:
"""Возвращает все группы."""
return await group_crud.get_multi(session)


@router.post('/', response_model=GroupRead)
@router.post("/", response_model=GroupRead)
async def create_group(
group: GroupCreate,
session: AsyncSession = Depends(get_async_session)
group: GroupCreate, session: AsyncSession = Depends(get_async_session)
):
"""Создать группу"""
await check_name_duplicate(group.name, group_crud, session)
return await group_crud.create(
obj_in=group, session=session
)
return await group_crud.create(obj_in=group, session=session)


@router.delete('/{obj_id}')
@router.delete("/{obj_id}")
async def delete_group(
obj_id: int,
session: AsyncSession = Depends(get_async_session),
obj_id: int,
session: AsyncSession = Depends(get_async_session),
):
"""Удалить объект"""
return await delete_obj(obj_id=obj_id, crud=group_crud, session=session)
9 changes: 4 additions & 5 deletions app/api/endpoints/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
from app.crud import notification_crud
from app.schemas.notification import NotificationCreate, NotificationRead


router = APIRouter()


@router.post('/')
@router.post("/")
async def create_notification(
notification: NotificationCreate,
session: AsyncSession = Depends(get_async_session)
session: AsyncSession = Depends(get_async_session)
):
return await notification_crud.create(notification, session)


@router.get('/', response_model=list[NotificationRead])
@router.get("/", response_model=list[NotificationRead])
async def get_all_notifications(
session: AsyncSession = Depends(get_async_session)
session: AsyncSession = Depends(get_async_session)
):
return await notification_crud.get_multi(session)
31 changes: 15 additions & 16 deletions app/api/endpoints/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,28 @@
from sqlalchemy.ext.asyncio import AsyncSession

from app.api.validators import check_obj_exists
from app.models import User
from app.schemas.profile import ProfileRead, ProfileCreate
from app.core.db import get_async_session
from app.crud import profile_crud, user_crud
from app.core.user import current_user
from app.crud import profile_crud, user_crud
from app.models import User
from app.schemas.profile import ProfileCreate, ProfileRead
from app.services.endpoints_services import delete_obj

router = APIRouter()


@router.get('/', response_model=list[ProfileRead])
@router.get("/", response_model=list[ProfileRead])
async def get_all_profiles(
session: AsyncSession = Depends(get_async_session),
user: User = Depends(current_user)
session: AsyncSession = Depends(get_async_session),
user: User = Depends(current_user),
) -> list[ProfileRead]:
"""Возвращает все profile юзера."""
return await profile_crud.get_users_obj(
user_id=user.id, session=session
)
return await profile_crud.get_users_obj(user_id=user.id, session=session)


@router.post('/', response_model=ProfileRead)
@router.post("/", response_model=ProfileRead)
async def create_profile(
profile: ProfileCreate,
session: AsyncSession = Depends(get_async_session)
profile: ProfileCreate, session: AsyncSession = Depends(get_async_session)
):
"""Создать Profile"""
await check_obj_exists(
Expand All @@ -37,10 +34,12 @@ async def create_profile(
)


@router.delete('/{obj_id}')
@router.delete("/{obj_id}")
async def delete_profile(
obj_id: int,
session: AsyncSession = Depends(get_async_session),
obj_id: int,
session: AsyncSession = Depends(get_async_session),
):
"""Удалить объект"""
return await delete_obj(obj_id=obj_id, crud=profile_crud, session=session)
return await delete_obj(
obj_id=obj_id, crud=profile_crud, session=session
)
Loading

0 comments on commit c73f1f7

Please sign in to comment.