Merge pull request #107 from UnKnoWn-Consortium/patch-2

Make profile page more profile
This commit is contained in:
Mart 2017-05-19 00:20:41 -04:00 committed by GitHub
commit 02fa705330
2 changed files with 24 additions and 21 deletions

View File

@ -462,7 +462,7 @@ def profile():
return flask.redirect('/profile')
user.email = form.email.data
flask.flash(flask.Markup(
'<strong>Email successfully changed!</strong>'), 'info')
'<strong>Email successfully changed!</strong>'), 'success')
if new_password:
if form.current_password.data != user.password_hash:
flask.flash(flask.Markup(
@ -470,7 +470,7 @@ def profile():
return flask.redirect('/profile')
user.password_hash = form.new_password.data
flask.flash(flask.Markup(
'<strong>Password successfully changed!</strong>'), 'info')
'<strong>Password successfully changed!</strong>'), 'success')
db.session.add(user)
db.session.commit()
@ -478,9 +478,11 @@ def profile():
flask.g.user = user
return flask.redirect('/profile')
current_email = models.User.by_id(flask.g.user.id).email
return flask.render_template('profile.html', form=form, email=current_email, level=level)
_user = models.User.by_id(flask.g.user.id)
username = _user.username
current_email = _user.email
return flask.render_template('profile.html', form=form, name=username, email=current_email, level=level)
@app.route('/user/activate/<payload>')

View File

@ -3,7 +3,20 @@
{% block body %}
{% from "_formhelpers.html" import render_field %}
<h1>Edit Profile</h1>
<h2 style="margin-bottom: 20px;">Profile of <strong>{{ name }}</strong></h2>
<div class="row">
<div class="col-sm-4 avatar" style="display: none;">
<!-- TO BE IMPLEMENTED -->
</div>
<div class="col-sm-8">
<dl class="row" style="margin: 20px 0 15px 0;">
<dt class="col-sm-3">User ID:</dt><dd class="col-sm-9">{{ g.user.id }}</dd>
<dt class="col-sm-3">User Class:</dt><dd class="col-sm-9">{{ level }}</dd>
<dt class="col-sm-3">User Created on:</dt><dd class="col-sm-9">{{ g.user.created_time }}</dd>
</dl>
</div>
</div>
<ul class="nav nav-tabs" id="profileTabs" role="tablist">
<li role="presentation" class="active">
@ -12,10 +25,8 @@
<li role="presentation">
<a href="#email-change" id="email-change-tab" role="tab" data-toggle="tab" aria-controls="profile" aria-expanded="false">Email</a>
</li>
<li role="presentation">
<a href="#general-info" id="general-info-tab" role="tab" data-toggle="tab" aria-controls="profile" aria-expanded="false">My Info</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade active in" role="tabpanel" id="password-change" aria-labelledby="password-change-tab">
<form method="POST">
@ -35,7 +46,6 @@
{{ render_field(form.password_confirm, class_='form-control', placeholder='New password (confirm)') }}
</div>
</div>
<br>
<div class="row">
<div class="col-md-4">
<input type="submit" value="Update" class="btn btn-primary">
@ -62,7 +72,6 @@
{{ render_field(form.current_password, class_='form-control', placeholder='Current password') }}
</div>
</div>
<br>
<div class="row">
<div class="col-md-4">
<input type="submit" value="Update" class="btn btn-primary">
@ -70,16 +79,8 @@
</div>
</form>
</div>
<div class="tab-pane fade" role="tabpanel" id="general-info" aria-labelledby="general-info-tab">
<dl class="dl-horizontal">
<dt>User ID:</dt>
<dd>{{g.user.id}}</dd>
<dt>Account created on:</dt>
<dd>{{g.user.created_time}}</dd>
<dt>User class:</dt>
<dd>{{level}}</dd><br>
</dl>
</div>
</div>
<hr>
{% endblock %}