-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
[Moderation] Add User Status Checks on Endpoints #352
Merged
Merged
Changes from all commits
Commits
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 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 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 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 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 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 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 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,54 @@ | ||
"""Add user status | ||
|
||
Revision ID: 99379162619e | ||
Revises: bc48af5ec2e6 | ||
Create Date: 2022-09-11 17:20:02.341713 | ||
|
||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy import orm | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "99379162619e" | ||
down_revision = "bc48af5ec2e6" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
Base = orm.declarative_base() | ||
|
||
|
||
class User(Base): | ||
__tablename__ = "users" | ||
id = sa.Column(sa.Integer, primary_key=True) | ||
is_deleted = sa.Column(sa.Boolean, nullable=False, default=False) | ||
is_banned = sa.Column(sa.Boolean, nullable=False, default=False) | ||
is_verified = sa.Column(sa.Boolean, nullable=False, default=False) | ||
|
||
|
||
def upgrade() -> None: | ||
op.add_column("users", sa.Column("is_deleted", sa.Boolean, nullable=True)) | ||
op.add_column("users", sa.Column("is_banned", sa.Boolean, nullable=True)) | ||
op.add_column("users", sa.Column("is_verified", sa.Boolean, nullable=True)) | ||
|
||
bind = op.get_bind() | ||
session = orm.Session(bind=bind) | ||
for user in session.query(User).all(): | ||
user.is_deleted = False | ||
user.is_banned = False | ||
user.is_verified = False | ||
session.add(user) | ||
session.commit() | ||
|
||
with op.batch_alter_table("users") as batch_op: | ||
batch_op.alter_column("is_deleted", existing_type=sa.BOOLEAN(), nullable=False) | ||
batch_op.alter_column("is_banned", existing_type=sa.BOOLEAN(), nullable=False) | ||
batch_op.alter_column("is_verified", existing_type=sa.BOOLEAN(), nullable=False) | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("users", "is_deleted") | ||
op.drop_column("users", "is_banned") | ||
op.drop_column("users", "is_verified") | ||
# ### end Alembic commands ### |
This file contains 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 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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use setters instead of
user.is_deleted = True
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with
set_password
as a property that is modified after-the-fact (and I'm biased with my previous Java experience haha). I can remove it if it's too verbose.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_password
is kind of a special case to abstract away the password hashing logic. Otherwise I think plain attributes are more manageable long-term