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

Print api 29 soft deletes #74

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
Binary file added .DS_Store
Binary file not shown.
Binary file added migrations/.DS_Store
Binary file not shown.
30 changes: 30 additions & 0 deletions migrations/versions/85037413bcdb_soft_deletes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""soft_deletes

Revision ID: 85037413bcdb
Revises: a68c6bb2972c
Create Date: 2023-11-16 23:12:39.412182

"""
import sqlalchemy as sa
from alembic import op


# revision identifiers, used by Alembic.
revision = '85037413bcdb'
down_revision = 'a68c6bb2972c'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('file', 'source', existing_type=sa.VARCHAR(), nullable=False)
op.add_column('union_member', sa.Column('is_deleted', sa.Boolean(), nullable=False))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('union_member', 'is_deleted')
op.alter_column('file', 'source', existing_type=sa.VARCHAR(), nullable=True)
# ### end Alembic commands ###
Binary file added print_service/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions print_service/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class UnionMember(Model):
surname: Mapped[str] = mapped_column(String, nullable=False)
union_number: Mapped[str] = mapped_column(String, nullable=True)
student_number: Mapped[str] = mapped_column(String, nullable=True)
is_deleted: Mapped[bool] = mapped_column(Boolean)

files: Mapped[list[File]] = relationship('File', back_populates='owner')
print_facts: Mapped[list[PrintFact]] = relationship('PrintFact', back_populates='owner')
Expand Down
Binary file added print_service/routes/.DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions print_service/routes/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class UserCreate(BaseModel):
username: constr(strip_whitespace=True, to_upper=True, min_length=1)
union_number: Optional[constr(strip_whitespace=True, to_upper=True, min_length=1)]
student_number: Optional[constr(strip_whitespace=True, to_upper=True, min_length=1)]
is_deleted: bool = False


class UpdateUserList(BaseModel):
Expand Down Expand Up @@ -113,12 +114,14 @@ def update_list(
db_user.surname = user.username
db_user.union_number = user.union_number
db_user.student_number = user.student_number
db_user.is_deleted = user.is_deleted
else:
db.session.add(
UnionMember(
surname=user.username,
union_number=user.union_number,
student_number=user.student_number,
is_deleted=False,
)
)
db.session.flush()
Expand Down
Loading