-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add user status checks for moderation
1/3 PRs for #224, ensuring that a user who has been banned/deleted recently will no longer be able to interact with the site. The next 2 PRs will be to (1) Update all views for other users so they no longer see the usernames of deleted/banned users and (2) Add support for banning + deleting users (as admin or yourself).
- Loading branch information
1 parent
05ae73b
commit 55948de
Showing
11 changed files
with
187 additions
and
2 deletions.
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