-
Notifications
You must be signed in to change notification settings - Fork 4
Добавление софт делитов в принтер #87
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
Open
gitfresnel
wants to merge
17
commits into
main
Choose a base branch
from
29-добавить-софт-делиты-в-принтер-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
The head ref may contain hidden characters: "29-\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C-\u0441\u043E\u0444\u0442-\u0434\u0435\u043B\u0438\u0442\u044B-\u0432-\u043F\u0440\u0438\u043D\u0442\u0435\u0440-1"
Open
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2115821
f
gitfresnel 2a6326b
f
gitfresnel afa9d5f
Merge branch 'main' into 29-добавить-софт-делиты-в-принтер-1
gitfresnel 5495e19
Delete migrations/versions/dddf1cc0c593_add_is_deleted_field_to_union…
gitfresnel dae0028
f
gitfresnel 4a3039f
Merge remote-tracking branch 'origin/29-добавить-софт-делиты-в-принте…
gitfresnel 64679c1
f
gitfresnel 6becd9e
f
gitfresnel 897ad47
f
gitfresnel 9fdb0e8
Delete migrations/versions/2b86076bf074_add_is_deleted_field_to_union…
gitfresnel 3cb4784
f
gitfresnel bbc7607
Merge remote-tracking branch 'origin/29-добавить-софт-делиты-в-принте…
gitfresnel 4a8981a
Delete migrations/versions/808f98fc21f5_add_is_deleted_field_to_union…
gitfresnel 77bca1a
f
gitfresnel b9ca32b
Merge remote-tracking branch 'origin/29-добавить-софт-делиты-в-принте…
gitfresnel f175205
f
gitfresnel 3357caf
Merge branch 'main' into 29-добавить-софт-делиты-в-принтер-1
gitfresnel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
32 changes: 32 additions & 0 deletions
32
migrations/versions/2b86076bf074_add_is_deleted_field_to_unionmember_.py
This file contains hidden or 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,32 @@ | ||
| """Add is_deleted field to UnionMember table | ||
|
|
||
| Revision ID: 2b86076bf074 | ||
| Revises: a68c6bb2972c | ||
| Create Date: 2024-10-30 19:08:15.473750 | ||
|
|
||
| """ | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = '2b86076bf074' | ||
| down_revision = 'a68c6bb2972c' | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade(): | ||
| op.alter_column('file', 'source', existing_type=sa.VARCHAR(), nullable=False) | ||
| op.add_column('union_member', sa.Column('is_deleted', sa.Boolean(), nullable=True)) | ||
| op.execute(f'UPDATE "union_member" SET is_deleted = False') | ||
| op.alter_column('union_member', 'is_deleted', 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 ### | ||
This file contains hidden or 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 hidden or 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,29 @@ | ||
| import re | ||
|
|
||
| import sqlalchemy | ||
| from sqlalchemy import Integer, not_ | ||
| from sqlalchemy.orm import Mapped, Query, Session, as_declarative, declared_attr, mapped_column | ||
|
|
||
|
|
||
| @as_declarative() | ||
| class Base: | ||
| """Base class for all database entities""" | ||
|
|
||
| @declared_attr | ||
| def __tablename__(cls) -> str: # pylint: disable=no-self-argument | ||
| """Generate database table name automatically. | ||
| Convert CamelCase class name to snake_case db table name. | ||
| """ | ||
| return re.sub(r"(?<!^)(?=[A-Z])", "_", cls.__name__).lower() | ||
|
|
||
|
|
||
| class BaseDbModel(Base): | ||
| __abstract__ = True | ||
| id: Mapped[int] = mapped_column(Integer, primary_key=True) | ||
|
gitfresnel marked this conversation as resolved.
Outdated
gitfresnel marked this conversation as resolved.
Outdated
|
||
|
|
||
| @classmethod | ||
| def query(cls, session: Session, with_deleted: bool = False) -> Query: | ||
|
gitfresnel marked this conversation as resolved.
Outdated
|
||
| objs = session.query(cls) | ||
| if not with_deleted and hasattr(cls, "is_deleted"): | ||
| objs = objs.filter(not_(cls.is_deleted)) | ||
| return objs | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.