-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Eduard0803
committed
Nov 25, 2023
1 parent
df82778
commit 88744aa
Showing
7 changed files
with
75 additions
and
4 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
gestao/db/migrations/versions/2023-11-25-07-13_89f33fa986f8.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""rename column 'mother_date' to 'mother_name' and add columns 'password and 'religion' | ||
Revision ID: 89f33fa986f8 | ||
Revises: 0084e7dffc7c | ||
Create Date: 2023-11-25 07:13:16.617587 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '89f33fa986f8' | ||
down_revision = '0084e7dffc7c' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
with op.batch_alter_table("user") as batch_op: | ||
batch_op.alter_column('mother_date', new_column_name='mother_name', existing_type=sa.String(length=200)) | ||
batch_op.add_column( | ||
sa.Column("password", sa.String(200), nullable=True), | ||
) | ||
batch_op.add_column( | ||
sa.Column("religion", sa.String(200), nullable=True), | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
with op.batch_alter_table("user") as batch_op: | ||
batch_op.alter_column('mother_name', new_column_name='mother_date', existing_type=sa.String(length=200)) | ||
batch_op.drop_column("password") | ||
batch_op.drop_column("religion") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from gestao.web.api.login.views import router | ||
|
||
__all__ = ["router"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class AuthUserDTO(BaseModel): | ||
registration: str | ||
password: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import logging | ||
|
||
from fastapi import APIRouter, HTTPException | ||
|
||
from gestao.db.models.user import User | ||
from gestao.web.api.login.schemas import AuthUserDTO | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.post('/user') | ||
async def login_user(login_data: AuthUserDTO) -> User: | ||
try: | ||
return await User.objects.select_related(User.dependents).get(**login_data.dict()) | ||
except Exception: | ||
logging.error("User not found", exc_info=True) | ||
raise HTTPException( | ||
status_code=404, | ||
detail='User not found', | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
from fastapi.routing import APIRouter | ||
|
||
from gestao.web.api import echo, monitoring, user | ||
from gestao.web.api import echo, monitoring, user, login | ||
|
||
api_router = APIRouter() | ||
api_router.include_router(monitoring.router) | ||
api_router.include_router(echo.router, prefix="/echo", tags=["echo"]) | ||
api_router.include_router(user.router, prefix="/users", tags=["users"]) | ||
api_router.include_router(login.router, prefix="/login", tags=["login"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters