adding user/artist verification

master
lza_menace 2 years ago
parent d2092ab496
commit 4c5a2bc1d6

@ -105,7 +105,7 @@ def cli(app):
u = User(
handle=user,
wallet_address=data[user]['wallet'],
is_approved=True
is_verified=True
)
u.save()
_user = u

@ -29,7 +29,7 @@ class User(pw.Model):
challenge = pw.CharField(default=gen_challenge)
is_admin = pw.BooleanField(default=False)
is_mod = pw.BooleanField(default=False)
is_approved = pw.BooleanField(default=False)
is_verified = pw.BooleanField(default=False)
is_banned = pw.BooleanField(default=False)
@property

@ -12,12 +12,18 @@ bp = Blueprint('admin', 'admin', url_prefix='/admin')
@login_required
@admin_required
def main():
user_form = UserForm()
if user_form.validate_on_submit():
u = User.select().where(User.handle == user_form.handle.data).first()
admin_form = UserForm()
artist_form = UserForm()
if admin_form.validate_on_submit():
u = User.select().where(User.handle == admin_form.handle.data).first()
u.is_admin = True
u.save()
return redirect(request.referrer)
if artist_form.validate_on_submit():
u = User.select().where(User.handle == artist_form.handle.data).first()
u.is_verified = True
u.save()
return redirect(request.referrer)
if request.args.get('remove'):
a = User.select().where(User.handle == request.args.get('remove')).first()
if a == current_user:
@ -27,11 +33,20 @@ def main():
a.is_admin = False
a.save()
return redirect(url_for('admin.main'))
if request.args.get('unverify'):
a = User.select().where(User.handle == request.args.get('unverify')).first()
if a:
a.is_verified = False
a.save()
return redirect(url_for('admin.main'))
admins = User.select().where(User.is_admin == True).order_by(User.register_date.desc())
artists = User.select().where(User.is_verified == True).order_by(User.register_date.desc())
return render_template(
'admin/main.html',
admins=admins,
user_form=user_form
artists=artists,
admin_form=admin_form,
artist_form=artist_form
)
# approve artwork

@ -11,7 +11,7 @@ bp = Blueprint('main', 'main')
@bp.route('/')
def index():
users = User.select().where(
User.is_approved == True
User.is_verified == True
).order_by(User.register_date.desc()).limit(10)
artwork = Artwork.select().where(
Artwork.approved == True,

@ -5,19 +5,23 @@
<div class="container">
<div class="row">
<h1>admins</h1>
<p>Add a homie</p>
<p>
Add a homie to be an admin. <br />
Admins can manage other admins as well as hide artwork, <br />
approve/reject artwork, ban artists, and verify artists.
</p>
<form method="post" action="">
{{ user_form.csrf_token }}
{{ admin_form.csrf_token }}
<div class="row">
<div class="two columns">
{{ user_form.handle }}
{{ admin_form.handle }}
</div>
<div class="two columns">
<input class="button-primary" type="submit" value="Submit">
</div>
</div>
<ul>
{%- for field, errors in user_form.errors.items() %}
{%- for field, errors in admin_form.errors.items() %}
<li>{{ ', '.join(errors) }}</li>
{%- endfor %}
</ul>
@ -28,6 +32,35 @@
{% endfor %}
</ul>
</div>
<hr>
<div class="row">
<h1>artists</h1>
<p>
Verified artists will skip the queue <br />
and have their artwork displayed immediately.
</p>
<form method="post" action="">
{{ artist_form.csrf_token }}
<div class="row">
<div class="two columns">
{{ artist_form.handle }}
</div>
<div class="two columns">
<input class="button-primary" type="submit" value="Submit">
</div>
</div>
<ul>
{%- for field, errors in artist_form.errors.items() %}
<li>{{ ', '.join(errors) }}</li>
{%- endfor %}
</ul>
</form>
<ul>
{% for artist in artists %}
<li><h6>{{ artist.handle }} - <a href="?unverify={{ artist.handle }}">remove</a></h6></li>
{% endfor %}
</ul>
</div>
</div>
{% endblock %}

Loading…
Cancel
Save