From eaff8b7ff340f25d1df3ec0091a18ec2ce57d96a Mon Sep 17 00:00:00 2001 From: Son Date: Mon, 15 Nov 2021 11:16:03 +0100 Subject: [PATCH] remove User.can_use_subdomain column, make subdomain available to all users --- app/dashboard/views/subdomain.py | 2 +- app/models.py | 5 ---- .../versions/2021_111511_11ba83e2dd71_.py | 29 +++++++++++++++++++ templates/menu.html | 2 +- 4 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 migrations/versions/2021_111511_11ba83e2dd71_.py diff --git a/app/dashboard/views/subdomain.py b/app/dashboard/views/subdomain.py index 01f5ebcc..11ec9018 100644 --- a/app/dashboard/views/subdomain.py +++ b/app/dashboard/views/subdomain.py @@ -10,7 +10,7 @@ from app.models import CustomDomain, Mailbox, SLDomain @dashboard_bp.route("/subdomain", methods=["GET", "POST"]) @login_required def subdomain_route(): - if not current_user.can_use_subdomain or not current_user.subdomain_is_available(): + if not current_user.subdomain_is_available(): flash("Unknown error, redirect to the home page", "error") return redirect(url_for("dashboard.index")) diff --git a/app/models.py b/app/models.py index f3672198..b20a7ae2 100644 --- a/app/models.py +++ b/app/models.py @@ -387,11 +387,6 @@ class User(Base, ModelMixin, UserMixin, PasswordOracle): sa.Boolean, default=False, nullable=False, server_default="0" ) - # subdomain access is limited at the beginning - can_use_subdomain = sa.Column( - sa.Boolean, default=False, nullable=False, server_default="0" - ) - # automatically include the website name when user creates an alias via the SimpleLogin icon in the email field include_website_in_one_click_alias = sa.Column( sa.Boolean, diff --git a/migrations/versions/2021_111511_11ba83e2dd71_.py b/migrations/versions/2021_111511_11ba83e2dd71_.py new file mode 100644 index 00000000..5d4df135 --- /dev/null +++ b/migrations/versions/2021_111511_11ba83e2dd71_.py @@ -0,0 +1,29 @@ +"""empty message + +Revision ID: 11ba83e2dd71 +Revises: 5639ad89ee50 +Create Date: 2021-11-15 11:15:14.060491 + +""" +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '11ba83e2dd71' +down_revision = '5639ad89ee50' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('users', 'can_use_subdomain') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('users', sa.Column('can_use_subdomain', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False)) + # ### end Alembic commands ### diff --git a/templates/menu.html b/templates/menu.html index 8133b6d6..81b48c79 100644 --- a/templates/menu.html +++ b/templates/menu.html @@ -28,7 +28,7 @@ - {% if current_user.can_use_subdomain and current_user.subdomain_is_available() %} + {% if current_user.subdomain_is_available() %}