1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 19:30:00 +00:00

styled user info better, show user class on profile

This commit is contained in:
martstern 2017-05-16 00:20:40 -04:00
parent eb59116429
commit 8a87ca93a5
3 changed files with 46 additions and 26 deletions

View file

@ -452,6 +452,15 @@ def profile():
return flask.redirect('/') # so we dont get stuck in infinite loop when signing out return flask.redirect('/') # so we dont get stuck in infinite loop when signing out
form = forms.ProfileForm(flask.request.form) form = forms.ProfileForm(flask.request.form)
level = 'Regular'
if flask.g.user.is_admin:
level = 'Moderator'
if flask.g.user.is_superadmin: # check this second because we can be admin AND superadmin
level = 'Administrator'
elif flask.g.user.is_trusted:
level = 'Trusted'
if flask.request.method == 'POST' and form.validate(): if flask.request.method == 'POST' and form.validate():
user = flask.g.user user = flask.g.user
new_email = form.email.data new_email = form.email.data
@ -472,7 +481,7 @@ def profile():
flask.g.user = user flask.g.user = user
return flask.render_template('profile.html', form=form) return flask.render_template('profile.html', form=form, level=level)
@app.route('/user/activate/<payload>') @app.route('/user/activate/<payload>')

View file

@ -5,12 +5,16 @@
{% if g.user %} {% if g.user %}
<h1>My Account</h1> <h1>My Account</h1>
<div class="content"> <dl class="dl-horizontal">
<p>ID: {{g.user.id}}</p> <dt>User ID:</dt>
<p>Account created on: {{g.user.created_time}}</p> <dd>{{g.user.id}}</dd>
<p>Email address: {{g.user.email}}</p> <dt>Account created on:</dt>
<p>User class: {{level}}</p> <dd>{{g.user.created_time}}</dd>
</div> <dt>Email address:</dt>
<dd>{{g.user.email}}</dd>
<dt>User class:</dt>
<dd>{{level}}</dd><br>
</dl>
{% endif %} {% endif %}
<h2>Edit Profile</h2> <h2>Edit Profile</h2>

View file

@ -4,25 +4,32 @@
{% from "_formhelpers.html" import render_field %} {% from "_formhelpers.html" import render_field %}
{% if superadmin %} {% if superadmin %}
<h1>User Information</h1> <h2>User Information</h2><br>
<p>ID: {{user.id}}</p> <dl class="dl-horizontal">
<p>Account created on: {{user.created_time}}</p> <dt>User ID:</dt>
<p>Email address: {{user.email}}</p> <dd>{{user.id}}</dd>
<p>User class: {{level}}</p> <dt>Account created on:</dt>
<dd>{{user.created_time}}</dd>
<dt>Email address:</dt>
<dd>{{user.email}}</dd>
<dt>User class:</dt>
<dd>{{level}}</dd><br>
</dl>
<form method="POST"> <form method="POST">
{{ form.csrf_token }} {{ form.csrf_token }}
<div class="row">
<div class="form-group col-md-6"> <div class="form-group row">
<div class="col-md-6">
{{ render_field(form.user_class, class_='form-control')}} {{ render_field(form.user_class, class_='form-control')}}
</div> </div>
</div> </div>
<div class="row"> <div class="form-group">
<div class="form-group col-md-6"> <button type="submit" class="btn btn-primary">Apply</button>
<input type="submit" value="Apply" class="btn btn-primary">
</div>
</div> </div>
</form> </form>
<br>
{% endif %} {% endif %}
<h3> <h3>
Browsing {{user.username}}'s torrents Browsing {{user.username}}'s torrents
</h3> </h3>