parent
95df3228fc
commit
9f70e2b843
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-8 col-xs-offset-0">
|
||||
<div class="col-xs-4 col-xs-offset-0">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="confirmed" {% if user.confirmed %} checked {% endif %} > Confirmed?
|
||||
|
@ -77,6 +77,17 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4 col-xs-offset-0">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="suspended" {% if user.suspended %} checked {% endif %} > Suspended?
|
||||
</label>
|
||||
{% if form.suspended.errors %}
|
||||
<br />
|
||||
<span class="text-red">{% for error in form.suspended.errors %} {{ error }} {% endfor %}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-xs-4">
|
||||
<button type="submit" name="submit" class="btn btn-primary btn-block btn-flat" value="Update">Update</button>
|
||||
|
|
|
@ -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 %}
|
||||
|
||||
<div class="login-box">
|
||||
<div class="login-logo">
|
||||
<strong>-</strong> stack
|
||||
</div>
|
||||
<div class="login-box-body">
|
||||
{# Display errors (if there are any). #}
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<ul>
|
||||
{% for message in messages %}
|
||||
<li>{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<h3>Hello {{ current_user.username }}</h3>
|
||||
<h4>Your account has been suspended!</h4>
|
||||
<p>Please contact our support department for details.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -28,6 +28,7 @@
|
|||
{% block content -%}
|
||||
<h4 class="page-header">
|
||||
AdminLTE Small Boxes
|
||||
{{ current_user.suspended }}
|
||||
<small>Small boxes are used for viewing statistics. To create a small box use the <code>widgets.small_box</code> widget.</small>
|
||||
</h4>
|
||||
<!-- Small boxes (Stat box) -->
|
||||
|
|
|
@ -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 ==
|
||||
|
|
|
@ -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 ###
|
Loading…
Reference in New Issue