Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add user crud #1

Merged
merged 3 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ ignore =
WPS473,
; too many no-cover comments.
WPS403,
D101,
D104,
D103,
WPS432,
WPS442,
C815,

per-file-ignores =
; all tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
--health-timeout=5s
--health-retries=5
ports:
- 5433:5432
- 5432:5432
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand Down
1 change: 0 additions & 1 deletion gestao/db/dao/__init__.py

This file was deleted.

40 changes: 0 additions & 40 deletions gestao/db/dao/dummy_dao.py

This file was deleted.

22 changes: 0 additions & 22 deletions gestao/db/migrations/versions/2021-08-16-16-53_819cbf6e030b.py

This file was deleted.

32 changes: 0 additions & 32 deletions gestao/db/migrations/versions/2021-08-16-16-55_2b7380507a71.py

This file was deleted.

67 changes: 67 additions & 0 deletions gestao/db/migrations/versions/2023-10-21-23-53_071cefd86342.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""user table

Revision ID: 071cefd86342
Revises:
Create Date: 2023-10-21 23:53:52.242776

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "071cefd86342"
down_revision = None
branch_labels = None
depends_on = None


def upgrade() -> None:
op.create_table(
"user",
sa.Column("id", sa.String(length=200), primary_key=True, nullable=False),
sa.Column("name", sa.String(length=200), nullable=False),
sa.Column("address", sa.String(length=200), nullable=False),
sa.Column("neighborhood", sa.String(length=200), nullable=False),
sa.Column("city", sa.String(length=100), nullable=False),
sa.Column("state", sa.String(length=100), nullable=False),
sa.Column("zipcode", sa.String(length=100), nullable=False),
sa.Column("cpf", sa.String(length=200), unique=True, nullable=False),
sa.Column("rg", sa.String(length=200), unique=True, nullable=False),
sa.Column("birth_date", sa.Date(), nullable=False),
sa.Column("place_of_birth", sa.String(length=200), nullable=False),
sa.Column("blood_type", sa.String(length=200), nullable=False),
sa.Column("gender", sa.String(length=200), nullable=False),
sa.Column("father_name", sa.String(length=200), nullable=False),
sa.Column("mother_date", sa.String(length=200), nullable=False),
sa.Column("position", sa.String(length=200), nullable=False),
sa.Column("occupancy", sa.String(length=200), nullable=False),
sa.Column("admission_date", sa.Date(), nullable=False),
sa.Column("situation", sa.String(length=200), nullable=False),
sa.Column("phone", sa.String(length=200), nullable=False),
sa.Column("email", sa.String(length=200), nullable=False),
sa.Column("marital_status", sa.String(length=200), nullable=False),
sa.Column("education", sa.String(length=200), nullable=False),
sa.Column("registration", sa.String(length=200), unique=True, nullable=False),
sa.Column("role", sa.String(length=200), nullable=False),
sa.Column("category", sa.String(length=200), nullable=False),
sa.Column("pattern", sa.String(length=200), nullable=False),
sa.Column("dispatcher", sa.String(length=200), nullable=False),
sa.Column("dispatched_date", sa.Date(), nullable=False),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
server_default=sa.func.now(),
nullable=False,
),
sa.Column(
"updated_at",
sa.DateTime(timezone=True),
server_default=sa.func.now(),
nullable=False,
),
schema="public",
)


def downgrade() -> None:
op.drop_table("user")
13 changes: 0 additions & 13 deletions gestao/db/models/dummy_model.py

This file was deleted.

46 changes: 46 additions & 0 deletions gestao/db/models/user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from datetime import date, datetime

import ormar

from gestao.db.base import BaseMeta


class User(ormar.Model):
class Meta(BaseMeta):
tablename = "user"

id: str = ormar.String(max_length=200, primary_key=True)
name: str = ormar.String(max_length=200)
address: str = ormar.String(max_length=200)
neighborhood: str = ormar.String(max_length=200)
city: str = ormar.String(max_length=100)
state: str = ormar.String(max_length=100)
zipcode: str = ormar.String(max_length=100)
cpf: str = ormar.String(max_length=200, unique=True)
rg: str = ormar.String(max_length=200, unique=True)
birth_date: date = ormar.Date()
place_of_birth: str = ormar.String(max_length=200)
blood_type: str = ormar.String(max_length=200)
gender: str = ormar.String(max_length=200)
father_name: str = ormar.String(max_length=200)
mother_date: str = ormar.String(max_length=200)
position: str = ormar.String(max_length=200)
occupancy: str = ormar.String(max_length=200)
admission_date: date = ormar.Date()
situation: str = ormar.String(max_length=200)
phone: str = ormar.String(max_length=200)
email: str = ormar.String(max_length=200)
marital_status: str = ormar.String(max_length=200)
education: str = ormar.String(max_length=200)
registration: str = ormar.String(max_length=200, unique=True)
role: str = ormar.String(max_length=200)
category: str = ormar.String(max_length=200)
pattern: str = ormar.String(max_length=200)
dispatcher: str = ormar.String(max_length=200)
dispatched_date: date = ormar.Date()
created_at: datetime = ormar.DateTime(timezone=True, default=datetime.now)
updated_at: datetime = ormar.DateTime(
timezone=True,
default=datetime.now,
onupdate=datetime.now,
)
46 changes: 0 additions & 46 deletions gestao/tests/test_dummy.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@

@pytest.mark.anyio
async def test_health(client: AsyncClient, fastapi_app: FastAPI) -> None:
"""
Checks the health endpoint.

:param client: client for the app.
:param fastapi_app: current FastAPI application.
"""
url = fastapi_app.url_path_for("health_check")
response = await client.get(url)
assert response.status_code == status.HTTP_200_OK
4 changes: 0 additions & 4 deletions gestao/web/api/dummy/__init__.py

This file was deleted.

21 changes: 0 additions & 21 deletions gestao/web/api/dummy/schema.py

This file was deleted.

41 changes: 0 additions & 41 deletions gestao/web/api/dummy/views.py

This file was deleted.

4 changes: 2 additions & 2 deletions gestao/web/api/router.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from fastapi.routing import APIRouter

from gestao.web.api import dummy, echo, monitoring
from gestao.web.api import echo, monitoring, user

api_router = APIRouter()
api_router.include_router(monitoring.router)
api_router.include_router(echo.router, prefix="/echo", tags=["echo"])
api_router.include_router(dummy.router, prefix="/dummy", tags=["dummy"])
api_router.include_router(user.router, prefix="/user", tags=["user"])
3 changes: 3 additions & 0 deletions gestao/web/api/user/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from gestao.web.api.user.views import router

__all__ = ["router"]
Loading
Loading