diff --git a/smash/templates/latest.html b/smash/templates/latest.html
index f267c23..579ef15 100644
--- a/smash/templates/latest.html
+++ b/smash/templates/latest.html
@@ -3,17 +3,17 @@
{% if quotes %}
{% for quote in quotes %}
-#{{ quote[0] }}
-+ ({{quote[1]}}) -
+#{{ quote.id }}
++ ({{quote.rating}}) -
-
{{ quote[2]|safe }}
+
{{ quote.content|safe }}
diff --git a/smash/views.py b/smash/views.py
index 07e313c..51fb1fd 100644
--- a/smash/views.py
+++ b/smash/views.py
@@ -79,34 +79,21 @@ def latest():
@app.route('/quote/')
def quote(id):
- quote = db.select("quotes", "id, rating, content", "id='{}'".format(id))
- if len(quote)<1:
+ quote = Quote.query.filter_by(id=id).first()
+
+ if quote is None:
return render_template(
"message.html",
alertclass="alert-warning",
message="No such quote."
)
else:
-
- tags = db.select("tagsToQuotes", "tagid", "quoteid='{}'".format(quote[0][0]))
- tags_str = []
- for tag in tags:
- tags_str.append(db.select("tags", "name", "id='{}'".format(tag[0]))[0][0])
-
- quote = [
- (
- quote[0][0],
- quote[0][1],
- unicode(Markup.escape(quote[0][2])).replace('\n', ''),
- tags_str
- )
- ]
return render_template(
"latest.html",
appname=conf.config['APPNAME'],
appbrand=conf.config['APPBRAND'],
- title="Latest",
- quotes=quote
+ title="Quote #{}".format(quote.id),
+ quotes=[quote,]
)