finalized topic.jinja2
This commit is contained in:
@@ -11,13 +11,10 @@ class BlogRecordService(object):
|
||||
|
||||
@classmethod
|
||||
def by_topic(cls, request, topic):
|
||||
query = """SELECT entries.*, entries.slug, topics.topic_name, tags.tag_name FROM entries
|
||||
JOIN topics ON topics.topic = entries.topic_id
|
||||
JOIN tags ON tags.topic = entries.topic_id AND tags.tag = entries.tag
|
||||
WHERE entries.topic_id = :topic ORDER BY tags.tag, entries.title
|
||||
"""
|
||||
results = request.dbsession.execute(query, {'topic': topic}).fetchall()
|
||||
return results
|
||||
# get posts by topic
|
||||
query = request.dbsession.query(BlogRecord).filter(BlogRecord.topic_id == topic)
|
||||
query = query.order_by(BlogRecord.tag, BlogRecord.title).all()
|
||||
return query
|
||||
|
||||
@classmethod
|
||||
def by_criteria(cls, request, criteria):
|
||||
@@ -34,7 +31,7 @@ class BlogRecordService(object):
|
||||
@classmethod
|
||||
def get_last_five(cls, request):
|
||||
# gest the last 5 items modified
|
||||
query = request.dbsession.query(BlogRecord.id, BlogRecord.title, BlogRecord.edited, Topics.topic_name).join(Topics, Topics.topic == BlogRecord.topic_id)
|
||||
query = request.dbsession.query(BlogRecord)
|
||||
query = query.order_by(sa.desc(BlogRecord.edited)).limit(5).all()
|
||||
return query
|
||||
|
||||
|
||||
@@ -152,26 +152,23 @@
|
||||
|
||||
<h2 class="text-center">DERNIERES PUBLICATIONS</h2>
|
||||
|
||||
<ul>
|
||||
{% for entry in last_five %}
|
||||
<div class="col-xs-10">
|
||||
<li>
|
||||
{{ entry.edited.strftime("%d-%m-%Y") }}
|
||||
<a href="{{ request.route_url('blog', id=entry.id, slug=entry.slug) }}">
|
||||
<span class="glyphicon glyphicon-triangle-right"></span> {{ entry.title }}
|
||||
<span class="glyphicon glyphicon-menu-right"></span> {{ entry.title }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
[ {{ entry.topic_name }} ]
|
||||
</div>
|
||||
</li>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
<br>
|
||||
<p class="text-center">---</p>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<!-- Container (Contact Section) -->
|
||||
<div id="contact">
|
||||
<br >
|
||||
<h2 class="text-center">CONTACT</h2>
|
||||
<p class="text-center"><em>Laissez nous un message!</em></p>
|
||||
|
||||
|
||||
@@ -7,19 +7,17 @@
|
||||
[Nouveau post]</a>
|
||||
</p>
|
||||
{% endif%}
|
||||
<div class="row">
|
||||
{% for entry in items %}
|
||||
<div class="col-xs-9">
|
||||
<li>
|
||||
<a href="{{ request.route_url('blog', id=entry.id, slug=entry.slug) }}">{{ entry.title }}</a>
|
||||
</li>
|
||||
</div>
|
||||
<div class="col-xs-3">
|
||||
{{ entry.edited[:10] }} -
|
||||
{{ entry.tag_name }}
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
{% for entry in items %}
|
||||
<li>
|
||||
{{ entry.edited.strftime("%d-%m-%Y") }}
|
||||
<a href="{{ request.route_url('blog', id=entry.id, slug=entry.slug) }}">
|
||||
<span class="glyphicon glyphicon-menu-right"></span> {{ entry.title }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user