adding user/artist verification

master
lza_menace 2 years ago
parent d2092ab496
commit 4c5a2bc1d6

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

@ -29,7 +29,7 @@ class User(pw.Model):
challenge = pw.CharField(default=gen_challenge) challenge = pw.CharField(default=gen_challenge)
is_admin = pw.BooleanField(default=False) is_admin = pw.BooleanField(default=False)
is_mod = 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) is_banned = pw.BooleanField(default=False)
@property @property

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

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

@ -5,19 +5,23 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<h1>admins</h1> <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=""> <form method="post" action="">
{{ user_form.csrf_token }} {{ admin_form.csrf_token }}
<div class="row"> <div class="row">
<div class="two columns"> <div class="two columns">
{{ user_form.handle }} {{ admin_form.handle }}
</div> </div>
<div class="two columns"> <div class="two columns">
<input class="button-primary" type="submit" value="Submit"> <input class="button-primary" type="submit" value="Submit">
</div> </div>
</div> </div>
<ul> <ul>
{%- for field, errors in user_form.errors.items() %} {%- for field, errors in admin_form.errors.items() %}
<li>{{ ', '.join(errors) }}</li> <li>{{ ', '.join(errors) }}</li>
{%- endfor %} {%- endfor %}
</ul> </ul>
@ -28,6 +32,35 @@
{% endfor %} {% endfor %}
</ul> </ul>
</div> </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> </div>
{% endblock %} {% endblock %}

Loading…
Cancel
Save