diff --git a/dash/admin/forms.py b/dash/admin/forms.py index b525f07..341d478 100644 --- a/dash/admin/forms.py +++ b/dash/admin/forms.py @@ -15,6 +15,7 @@ class EditUserAdminForm(Form): full_name = StringField('Full name', validators=[Required(), Length(1, 255)]) role = SelectField('Role', coerce=int) confirmed = BooleanField('Confirmed') + suspended = BooleanField('Suspended') def __init__(self, user, *args, **kwargs): super(EditUserAdminForm, self).__init__(*args, **kwargs) diff --git a/dash/admin/views.py b/dash/admin/views.py index 896099c..b3c1757 100644 --- a/dash/admin/views.py +++ b/dash/admin/views.py @@ -65,6 +65,7 @@ def edit_user_admin(id): user.full_name = form.full_name.data user.role = Role.query.get(form.role.data) user.confirmed = form.confirmed.data + user.suspended = form.suspended.data db.session.add(user) flash('The profile has been updated.') return redirect(url_for('.edit_user_admin', id=user.id)) diff --git a/dash/auth/views.py b/dash/auth/views.py index a20245a..03e177d 100644 --- a/dash/auth/views.py +++ b/dash/auth/views.py @@ -14,8 +14,13 @@ def before_request(): if current_user.is_authenticated \ and not current_user.confirmed \ and request.endpoint[:5] != 'auth.' \ - and request.endpoint != 'static': + and '/static/' not in request.path: return redirect(url_for('auth.unconfirmed')) + if current_user.is_authenticated \ + and current_user.suspended \ + and request.endpoint[:5] != 'auth.' \ + and '/static/' not in request.path: + return redirect(url_for('auth.suspended')) @auth.route('/unconfirmed') def unconfirmed(): @@ -23,6 +28,12 @@ def unconfirmed(): return redirect(url_for('main.index')) return render_template('auth/unconfirmed.html') +@auth.route('/suspended') +def suspended(): + if current_user.is_anonymous or not current_user.suspended: + return redirect(url_for('main.index')) + return render_template('auth/suspended.html') + @auth.route('/login', methods=['GET', 'POST']) def login(): form = LoginForm() diff --git a/dash/models.py b/dash/models.py index 8f187cb..84df808 100644 --- a/dash/models.py +++ b/dash/models.py @@ -35,6 +35,7 @@ class User(UserMixin, db.Model): created_at = db.Column(db.DateTime) role_id = db.Column(db.Integer, db.ForeignKey('roles.id')) confirmed = db.Column(db.Boolean, default=False) + suspended = db.Column(db.Boolean, default=False) @property def password(self): diff --git a/dash/templates/admin/edit_user.html b/dash/templates/admin/edit_user.html index 74a945d..69c2f3d 100644 --- a/dash/templates/admin/edit_user.html +++ b/dash/templates/admin/edit_user.html @@ -66,7 +66,7 @@ {% endif %}
-
+
+
+
+ + {% if form.suspended.errors %} +
+ {% for error in form.suspended.errors %} {{ error }} {% endfor %} + {% endif %} +
+
diff --git a/dash/templates/auth/suspended.html b/dash/templates/auth/suspended.html new file mode 100644 index 0000000..6b9f711 --- /dev/null +++ b/dash/templates/auth/suspended.html @@ -0,0 +1,30 @@ +{% extends "adminlte/base_without_nav.html" %} + +{% block title %}Confirm Account{% endblock %} +{% block description %}Your account has been suspended!{% endblock %} +{% block bodytag %}login-page{% endblock %} + +{% block body %} + + + +{% endblock %} diff --git a/dash/templates/index.html b/dash/templates/index.html index 16fa73f..6aea025 100644 --- a/dash/templates/index.html +++ b/dash/templates/index.html @@ -28,6 +28,7 @@ {% block content -%} diff --git a/main_plan.txt b/main_plan.txt index 41df861..c65a27b 100644 --- a/main_plan.txt +++ b/main_plan.txt @@ -64,13 +64,21 @@ Reseller == Support == == Admin Area == +--User Management-- -Create user -Delete user -Edit user -Suspend user -Unsuspend user +-List User --Config page +--Provider Management-- +-Create provider +-Edit provider +-Delete provider +-Disable provider +-Enable provider +-List providers == Reseller == diff --git a/migrations/versions/5cc72c718d14_.py b/migrations/versions/5cc72c718d14_.py new file mode 100644 index 0000000..c4e8baa --- /dev/null +++ b/migrations/versions/5cc72c718d14_.py @@ -0,0 +1,26 @@ +"""empty message + +Revision ID: 5cc72c718d14 +Revises: ad5c9cae2c6d +Create Date: 2016-08-24 22:56:39.588007 + +""" + +# revision identifiers, used by Alembic. +revision = '5cc72c718d14' +down_revision = 'ad5c9cae2c6d' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + ### commands auto generated by Alembic - please adjust! ### + op.add_column('users', sa.Column('suspended', sa.Boolean(), nullable=True)) + ### end Alembic commands ### + + +def downgrade(): + ### commands auto generated by Alembic - please adjust! ### + op.drop_column('users', 'suspended') + ### end Alembic commands ###