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

Adiciona novos campos de user/dependent e rota de desabilitar filiado #8

Merged
merged 2 commits into from
Oct 29, 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
4 changes: 0 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ indent_size = 2
[Makefile]
indent_style = tab

[.flake8]
indent_style = space
indent_size = 2

[*.py]
indent_style = space
indent_size = 4
Expand Down
121 changes: 0 additions & 121 deletions .flake8

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,6 @@ jobs:
POETRY_VIRTUALENVS_CREATE: false
- name: Run black check
run: poetry run black --check .
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install deps
uses: knowsuchagency/poetry-install@v1
env:
POETRY_VIRTUALENVS_CREATE: false
- name: Run flake8 check
run: poetry run flake8 --count .
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install deps
uses: knowsuchagency/poetry-install@v1
env:
POETRY_VIRTUALENVS_CREATE: false
- name: Run mypy check
run: poetry run mypy .
pytest:
runs-on: ubuntu-latest
services:
Expand Down
9 changes: 0 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,3 @@ repos:
language: system
types: [python]
exclude: metrics/

- id: flake8
name: Check with Flake8
entry: poetry run flake8
language: system
pass_filenames: false
types: [python]
args: [--count, .]
exclude: metrics/
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ It's configured using .pre-commit-config.yaml file.

By default it runs:
* black (formats your code);
* mypy (validates types);
* isort (sorts imports in all files);
* flake8 (spots possible bugs);


You can read more about pre-commit here: https://pre-commit.com/
Expand Down
35 changes: 35 additions & 0 deletions gestao/db/migrations/versions/2023-10-28-21-20_05258d089f10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""add user workstation and nickname

Revision ID: 05258d089f10
Revises: 532e4deb3c37
Create Date: 2023-10-28 21:20:43.696192

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "05258d089f10"
down_revision = "532e4deb3c37"
branch_labels = None
depends_on = None


def upgrade():
with op.batch_alter_table("user") as batch_op:
batch_op.add_column(
sa.Column("workstation", sa.String(200), nullable=True),
)
batch_op.add_column(
sa.Column("nickname", sa.String(200), nullable=True),
)
batch_op.add_column(
sa.Column("status", sa.String(200), default="active"),
)


def downgrade():
with op.batch_alter_table("user") as batch_op:
batch_op.drop_column("workstation")
batch_op.drop_column("nickname")
batch_op.drop_column("status")
39 changes: 39 additions & 0 deletions gestao/db/migrations/versions/2023-10-28-21-23_0084e7dffc7c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""add dependent cof gender and pensioner

Revision ID: 0084e7dffc7c
Revises: 05258d089f10
Create Date: 2023-10-28 21:23:57.809923

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "0084e7dffc7c"
down_revision = "05258d089f10"
branch_labels = None
depends_on = None


def upgrade():
with op.batch_alter_table("dependent") as batch_op:
batch_op.add_column(
sa.Column("cpf", sa.String(200), nullable=True, unique=True),
)
batch_op.add_column(
sa.Column("gender", sa.String(200), nullable=True),
)
batch_op.add_column(
sa.Column("phone", sa.String(200), nullable=True),
)
batch_op.add_column(
sa.Column("pensioner", sa.Boolean(), default=False),
)


def downgrade():
with op.batch_alter_table("dependent") as batch_op:
batch_op.drop_column("cpf")
batch_op.drop_column("gender")
batch_op.drop_column("phone")
batch_op.drop_column("pensioner")
4 changes: 4 additions & 0 deletions gestao/db/models/dependent.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ class Meta(BaseMeta):
user_id: User = ormar.ForeignKey(User, ondelete=ormar.ReferentialAction.CASCADE)
name: str = ormar.String(max_length=200)
birth_date: date = ormar.Date()
cpf: str = ormar.String(max_length=200, unique=True)
gender: str = ormar.String(max_length=200)
phone: str = ormar.String(max_length=200)
relationship: str = ormar.String(max_length=200)
pensioner: bool = ormar.Boolean(default=False)
created_at: datetime = ormar.DateTime(timezone=True, default=datetime.now)
updated_at: datetime = ormar.DateTime(
timezone=True,
Expand Down
4 changes: 4 additions & 0 deletions gestao/db/models/user.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import date, datetime
from typing import Optional

import ormar

Expand Down Expand Up @@ -36,6 +37,9 @@ class Meta(BaseMeta):
role: str = ormar.String(max_length=200)
category: str = ormar.String(max_length=200)
pattern: str = ormar.String(max_length=200)
status: str = ormar.String(max_length=200, default="active")
workstation: Optional[str] = ormar.String(max_length=200, nullable=True)
nickname: Optional[str] = ormar.String(max_length=200, unique=True, nullable=True)
dispatcher: str = ormar.String(max_length=200)
dispatched_date: date = ormar.Date()
created_at: datetime = ormar.DateTime(timezone=True, default=datetime.now)
Expand Down
6 changes: 6 additions & 0 deletions gestao/web/api/user/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from enum import Enum


class UserStatus(str, Enum):
active = "active"
inactive = "inactive"
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class CreateUserDependentDTO(BaseModel):
name: str
birth_date: date
relationship: str
cpf: str
gender: str
phone: str
pensioner: Optional[str]


class CreateUserDTO(BaseModel):
Expand Down Expand Up @@ -40,6 +44,8 @@ class CreateUserDTO(BaseModel):
dispatcher: str
dispatched_date: date
dependents: Optional[List[CreateUserDependentDTO]]
workstation: Optional[str]
nickname: Optional[str]


class UpdateUserDTO(BaseModel):
Expand Down Expand Up @@ -71,3 +77,6 @@ class UpdateUserDTO(BaseModel):
pattern: Optional[str]
dispatcher: Optional[str]
dispatched_date: Optional[date]
workstation: Optional[str]
nickname: Optional[str]
status: Optional[str]
Loading
Loading