Added user display page

This commit is contained in:
Robbe Van Herck 2018-07-17 09:34:36 +02:00
parent 79711f1423
commit d0fa5d0375
No known key found for this signature in database
GPG key ID: 4D1C8E8FBD1C7188
2 changed files with 14 additions and 3 deletions

11
templates/user.html Normal file
View file

@ -0,0 +1,11 @@
<html>
<body>
<h2>{{data.id}}</h2>
<ul>
{% for achievement in data.achievements -%}
<li> {{ achievement.name }}: {{ achievement.endorsed_by|length }} endorsement{{ "s" if (achievement.endorsed_by|length != 1) else "" }}</li>
{% endfor -%}
<li> <a href="{{url_for('add_achievement', id=data.id)}}">Add achievement</a></li>
</ul>
</body>
</html>

View file

@ -1,7 +1,7 @@
from app import app, db
from models import User, Achievement
from flask import request
from flask import request, render_template
from flask_login import current_user, login_required
import json
@ -22,8 +22,8 @@ def add_achievement(id):
def get_user(id):
user = User.query.filter_by(id=id).first()
if not user:
return "{}"
return json.dumps(user.to_obj())
return "Unknown user"
return render_template("user.html", data=user.to_obj())
@app.route("/users/")
def all_users():