Added Achievement display
This commit is contained in:
parent
d0fa5d0375
commit
a65e2c48cb
3 changed files with 15 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
from app import app, db
|
||||
from models import Achievement
|
||||
|
||||
from flask import render_template
|
||||
from flask_login import current_user, login_required
|
||||
|
||||
import json
|
||||
|
@ -9,8 +10,8 @@ import json
|
|||
def get_achievement(id):
|
||||
achievement = Achievement.query.filter_by(id=id).first()
|
||||
if not achievement:
|
||||
return "{}"
|
||||
return json.dumps(achievement.to_obj())
|
||||
return "Unknown achievement"
|
||||
return render_template("achievement.html", data=achievement)
|
||||
|
||||
@app.route("/achievement/<id>/endorse")
|
||||
@login_required
|
||||
|
|
11
templates/achievement.html
Normal file
11
templates/achievement.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<html>
|
||||
<body>
|
||||
<h2>{{data.name}}</h2>
|
||||
<ul>
|
||||
{% for endorser in data.endorsed_by -%}
|
||||
<li> <a href="{{url_for('get_user', id=endorser.id)}}">{{ endorser.id }} </a></li>
|
||||
{% endfor -%}
|
||||
<li> <a href="{{url_for('endorse_achievement', id=data.id)}}">Endorse</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -3,7 +3,7 @@
|
|||
<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>
|
||||
<li> <a href="{{url_for('get_achievement', id=achievement.id)}}">{{ achievement.name }}</a>: {{ 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>
|
||||
|
|
Loading…
Reference in a new issue