split profile view and profile edit into seperate routes and templates
This commit is contained in:
@@ -122,3 +122,12 @@ input[name="openid"] {
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
|
||||
.red{
|
||||
color: red;
|
||||
}
|
||||
|
||||
.green{
|
||||
color: #329000;
|
||||
}
|
||||
|
||||
|
||||
44
refstack/templates/view_profile.html
Executable file
44
refstack/templates/view_profile.html
Executable file
@@ -0,0 +1,44 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block title %}View Profile{% endblock %}
|
||||
{% block body %}
|
||||
|
||||
<div class="panel panel-default unit one-of-two">
|
||||
<div class="panel-heading">
|
||||
<span class="glyphicon glyphicon-user"></span> {{ user.name }}'s profile
|
||||
|
||||
<a href="/profile/edit" style="float: right;">
|
||||
<span class="glyphicon glyphicon-pencil"></span>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td>
|
||||
E-Mail:
|
||||
</td>
|
||||
<td >
|
||||
{{ user.email }}
|
||||
{% if user.email_verified %}
|
||||
<span class="glyphicon glyphicon-ok-circle green" ></span>
|
||||
{% else %}
|
||||
<span class="glyphicon glyphicon-remove-circle red"></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Authorized by Vendor:
|
||||
</td>
|
||||
<td >
|
||||
{% if user.authorized %}
|
||||
<span class="glyphicon glyphicon-ok-circle green" ></span>
|
||||
{% else %}
|
||||
<span class="glyphicon glyphicon-remove-circle red"></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -123,7 +123,7 @@ def create_profile():
|
||||
'create_profile.html', next_url=oid.get_next_url())
|
||||
|
||||
|
||||
@app.route('/profile', methods=['GET', 'POST'])
|
||||
@app.route('/profile/edit', methods=['GET', 'POST'])
|
||||
def edit_profile():
|
||||
"""Updates a profile"""
|
||||
if g.user is None:
|
||||
@@ -131,8 +131,8 @@ def edit_profile():
|
||||
form = dict(name=g.user.name, email=g.user.email)
|
||||
if request.method == 'POST':
|
||||
if 'delete' in request.form:
|
||||
db.session.delete(g.user)
|
||||
db.session.commit()
|
||||
db.delete(g.user)
|
||||
db.commit()
|
||||
session['openid'] = None
|
||||
flash(u'Profile deleted')
|
||||
return redirect(url_for('index'))
|
||||
@@ -146,11 +146,20 @@ def edit_profile():
|
||||
flash(u'Profile successfully created')
|
||||
g.user.name = form['name']
|
||||
g.user.email = form['email']
|
||||
db.session.commit()
|
||||
db.commit()
|
||||
return redirect(url_for('edit_profile'))
|
||||
return render_template('edit_profile.html', form=form)
|
||||
|
||||
|
||||
@app.route('/profile', methods=['GET', 'POST'])
|
||||
def view_profile():
|
||||
"""Updates a profile"""
|
||||
if g.user is None:
|
||||
abort(401)
|
||||
|
||||
return render_template('view_profile.html', user=g.user)
|
||||
|
||||
|
||||
@app.route('/logout')
|
||||
def logout():
|
||||
"""logout route"""
|
||||
|
||||
Reference in New Issue
Block a user