Migrate quote page to use SQLAlchemy
This commit is contained in:
parent
c07b2a6695
commit
5d1e6b62aa
2 changed files with 10 additions and 23 deletions
|
@ -3,17 +3,17 @@
|
|||
|
||||
{% if quotes %}
|
||||
{% for quote in quotes %}
|
||||
<a class="quote-link" href="quote/{{ quote[0] }}">#{{ quote[0] }}</a>
|
||||
<a class="rate-positive">+</a> ({{quote[1]}}) <a class="rate-negative">-</a></br>
|
||||
<a class="quote-link" href="quote/{{ quote[0] }}">#{{ quote.id }}</a>
|
||||
<a class="rate-positive">+</a> ({{quote.rating}}) <a class="rate-negative">-</a></br>
|
||||
<div class="quote">
|
||||
<p>{{ quote[2]|safe }}</p>
|
||||
<p>{{ quote.content|safe }}</p>
|
||||
</div>
|
||||
|
||||
<div class="tags">
|
||||
|
||||
Tags:
|
||||
{% for tag in quote[3] %}
|
||||
<a href="tag/{{tag}}" class="badge"> {{tag}} </a>
|
||||
{% for tag in quote.tags %}
|
||||
<a href="tag/{{tag}}" class="badge"> {{tag.name}} </a>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
|
|
|
@ -79,34 +79,21 @@ def latest():
|
|||
|
||||
@app.route('/quote/<int:id>')
|
||||
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', '</br>'),
|
||||
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,]
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue