add user.can_use_custom_domain, user.can_use_api_key

This commit is contained in:
Son NK 2019-11-28 23:03:11 +00:00
parent efd0e97ebd
commit 7bedd40966
5 changed files with 42 additions and 4 deletions

View File

@ -98,6 +98,10 @@ class User(db.Model, ModelMixin, UserMixin):
profile_picture_id = db.Column(db.ForeignKey(File.id), nullable=True)
# feature flag
can_use_api_key = db.Column(db.Boolean, nullable=False, default=False)
can_use_custom_domain = db.Column(db.Boolean, nullable=False, default=False)
profile_picture = db.relationship(File)
@classmethod

View File

@ -60,7 +60,7 @@ def stats():
today = arrow.now().format()
email_utils.notify_admin(
f"Stats for {today}",
f"SimpleLogin Stats for {today}",
f"""
Stats for {today} <br>
nb_user: {nb_user} <br>

View File

@ -0,0 +1,31 @@
"""empty message
Revision ID: c5851f120b96
Revises: e505cb517589
Create Date: 2019-11-28 23:02:45.781149
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c5851f120b96'
down_revision = 'e505cb517589'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('users', sa.Column('can_use_api_key', sa.Boolean(), nullable=False))
op.add_column('users', sa.Column('can_use_custom_domain', sa.Boolean(), nullable=False))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('users', 'can_use_custom_domain')
op.drop_column('users', 'can_use_api_key')
# ### end Alembic commands ###

View File

@ -103,6 +103,7 @@ def fake_data():
password="password",
activated=True,
is_admin=True,
can_use_api_key=True,
)
db.session.commit()

View File

@ -46,9 +46,11 @@
<i class="dropdown-icon fe fe-settings"></i> Settings
</a>
<a class="dropdown-item" href="{{ url_for('dashboard.api_key') }}">
<i class="dropdown-icon fe fe-chrome"></i> API Key
</a>
{% if current_user.can_use_api_key %}
<a class="dropdown-item" href="{{ url_for('dashboard.api_key') }}">
<i class="dropdown-icon fe fe-chrome"></i> API Key
</a>
{% endif %}
{% if current_user.is_premium() %}
<a class="dropdown-item" href="{{ url_for('dashboard.billing') }}">