diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..eac1844 Binary files /dev/null and b/.DS_Store differ diff --git a/migrations/.DS_Store b/migrations/.DS_Store new file mode 100644 index 0000000..eeb6bc4 Binary files /dev/null and b/migrations/.DS_Store differ diff --git a/migrations/versions/85037413bcdb_soft_deletes.py b/migrations/versions/85037413bcdb_soft_deletes.py new file mode 100644 index 0000000..a6ef558 --- /dev/null +++ b/migrations/versions/85037413bcdb_soft_deletes.py @@ -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 ### diff --git a/print_service/.DS_Store b/print_service/.DS_Store new file mode 100644 index 0000000..38f7524 Binary files /dev/null and b/print_service/.DS_Store differ diff --git a/print_service/models/__init__.py b/print_service/models/__init__.py index d1ffcfe..86e382b 100644 --- a/print_service/models/__init__.py +++ b/print_service/models/__init__.py @@ -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') diff --git a/print_service/routes/.DS_Store b/print_service/routes/.DS_Store new file mode 100644 index 0000000..b9673b6 Binary files /dev/null and b/print_service/routes/.DS_Store differ diff --git a/print_service/routes/user.py b/print_service/routes/user.py index c8098f9..aaac6ac 100644 --- a/print_service/routes/user.py +++ b/print_service/routes/user.py @@ -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): @@ -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()