Added user display page
This commit is contained in:
parent
79711f1423
commit
d0fa5d0375
2 changed files with 14 additions and 3 deletions
11
templates/user.html
Normal file
11
templates/user.html
Normal 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>
|
6
user.py
6
user.py
|
@ -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():
|
||||
|
|
Loading…
Reference in a new issue