refined archives templates by thmes
This commit is contained in:
@@ -46,8 +46,11 @@ def get_docs_themes(request):
|
|||||||
results = request.dbsession.execute(query).fetchall()
|
results = request.dbsession.execute(query).fetchall()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def get_docs_bycritere(request, critere):
|
def get_docs_bycritere(request, critere, logged_in):
|
||||||
query = "SELECT * FROM docs WHERE texte like :critere;"
|
if logged_in == None:
|
||||||
|
query = "SELECT * FROM docs JOIN docs_themes ON docs.theme = docs_themes.theme WHERE (docs.texte like :critere) OR (docs.intitule like :critere) AND docs_themes.visible = 'oui';"
|
||||||
|
else:
|
||||||
|
query = "SELECT * FROM docs JOIN docs_themes ON docs.theme = docs_themes.theme WHERE (docs.texte like :critere) OR (docs.intitule like :critere);"
|
||||||
results = request.dbsession.execute(query, {'critere': '%' + critere + '%'}).fetchall()
|
results = request.dbsession.execute(query, {'critere': '%' + critere + '%'}).fetchall()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ def includeme(config):
|
|||||||
config.add_static_view('static', 'static', cache_max_age=3600)
|
config.add_static_view('static', 'static', cache_max_age=3600)
|
||||||
config.add_route('home', '/')
|
config.add_route('home', '/')
|
||||||
config.add_route('apropos', 'apropos')
|
config.add_route('apropos', 'apropos')
|
||||||
config.add_route('archives', '/archives/{theme}')
|
config.add_route('archives', '/archives')
|
||||||
config.add_route('doc_edit', '/doc_edit/{doc_id}')
|
config.add_route('doc_edit', '/doc_edit/{doc_id}')
|
||||||
config.add_route('doc_view', '/doc_view/{doc_id}')
|
config.add_route('doc_view', '/doc_view/{doc_id}')
|
||||||
config.add_route('doc_search', '/doc_search')
|
config.add_route('doc_search', '/doc_search')
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
<div metal:use-macro="load: global_layout.pt">
|
<div metal:use-macro="load: global_layout.pt">
|
||||||
<div metal:fill-slot="content">
|
<div metal:fill-slot="content">
|
||||||
|
|
||||||
|
<div class="row" tal:condition="not layout.isAnonymous()">
|
||||||
|
<form method="post" id="frm">
|
||||||
|
<div class="form-group col-xs-4">
|
||||||
|
|
||||||
|
<select class="form-control" name="theme" onChange="$('#frm').submit()">
|
||||||
|
<div tal:repeat="item themes">
|
||||||
|
<option value="${item.theme}" tal:attributes="selected theme == item.theme and 'selected' or None">
|
||||||
|
${item.theme}
|
||||||
|
</option>
|
||||||
|
</div>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-8">
|
||||||
|
<a role="button" class="btn btn-success" href="${request.application_url}/doc_edit/0">Créer un nouveau post</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<p tal:condition="not layout.isAnonymous()">
|
|
||||||
<a href="${request.application_url}/doc_edit/0">Créer un nouveau post</a>
|
|
||||||
</p>
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr tal:repeat="ligne docs">
|
<tr tal:repeat="ligne docs">
|
||||||
<td><a href="/doc_view/${ligne.doc_id}"><b>${ligne.intitule}</b></a></td>
|
<td><a href="/doc_view/${ligne.doc_id}"><b>${ligne.intitule}</b></a></td>
|
||||||
|
|||||||
@@ -69,8 +69,6 @@
|
|||||||
<footer class="container-fluid bg-footer">
|
<footer class="container-fluid bg-footer">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<p class="text-center">
|
<p class="text-center">
|
||||||
Restructured Text cheat sheet <a href="https://github.com/ralsina/rst-cheatsheet/blob/master/rst-cheatsheet.rst" target="_blank">(reST)</a><br />
|
|
||||||
Markdown basic syntax <a href="https://www.markdownguide.org/basic-syntax/" target="_blank">(md)</a><br />
|
|
||||||
<a href="https://www.instagram.com/ctphuoc/" alt="instagram" target="_blank">
|
<a href="https://www.instagram.com/ctphuoc/" alt="instagram" target="_blank">
|
||||||
<img src="${request.static_url('caotek_mesavoirs:static/img/instagram.png')}" /></a><br />
|
<img src="${request.static_url('caotek_mesavoirs:static/img/instagram.png')}" /></a><br />
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -9,8 +9,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<h3>Derniers posts</h3>
|
<h3>Derniers posts</h3>
|
||||||
<p tal:condition="not layout.isAnonymous()">
|
<p>
|
||||||
<a href="${request.application_url}/archives/blog">Voir les archives</a> | <a href="${request.application_url}/doc_edit/0">Créer un nouveau post</a>
|
| <a href="${request.application_url}/archives">Voir les archives</a> |
|
||||||
|
<a tal:condition="not layout.isAnonymous()" href="${request.application_url}/doc_edit/0">Créer un nouveau post |</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
@@ -21,20 +22,6 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row well text-center" tal:condition="not layout.isAnonymous()">
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<a href="${request.application_url}/portfolio"><span class="glyphicon glyphicon-piggy-bank logo-primary"></span></a>
|
|
||||||
<h4>EPARGNE</h4>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<a href="${request.application_url}/archives/memo"><span class="glyphicon glyphicon-list-alt logo-primary"></span></a>
|
|
||||||
<h4>MEMOS</h4>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<a href="${request.application_url}/archives/article"><span class="glyphicon glyphicon-duplicate logo-primary"></span></a>
|
|
||||||
<h4>ARTICLES</h4>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div><!-- content -->
|
</div><!-- content -->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
|
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li><a href="${request.application_url}/preferences">Mes préférences</a></li>
|
<li><a href="${request.application_url}/preferences">Mes préférences</a></li>
|
||||||
|
<li><a href="https://www.markdownguide.org/basic-syntax/">Markdown syntax</a></li>
|
||||||
<li tal:condition="layout.isAdmin()"><a href="${request.application_url}/users_list">Gestion des membres</a></li>
|
<li tal:condition="layout.isAdmin()"><a href="${request.application_url}/users_list">Gestion des membres</a></li>
|
||||||
|
<li tal:condition="layout.isAdmin()"><a href="${request.application_url}/portfolio">Porfolio</a></li>
|
||||||
|
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li><a href="${request.application_url}/logout">
|
<li><a href="${request.application_url}/logout">
|
||||||
|
|||||||
@@ -85,7 +85,13 @@ def home(request):
|
|||||||
|
|
||||||
@view_config(route_name='archives', renderer='../templates/archives.pt')
|
@view_config(route_name='archives', renderer='../templates/archives.pt')
|
||||||
def archives(request):
|
def archives(request):
|
||||||
theme = request.matchdict['theme']
|
theme = 'blog'
|
||||||
|
|
||||||
|
if 'theme' in request.params:
|
||||||
|
theme = request.params["theme"]
|
||||||
|
|
||||||
|
# lire la table des themes
|
||||||
|
themes = get_docs_themes(request)
|
||||||
|
|
||||||
# lire toutes les docs du theme
|
# lire toutes les docs du theme
|
||||||
docs = get_docs_bytheme(request, theme)
|
docs = get_docs_bytheme(request, theme)
|
||||||
@@ -93,6 +99,8 @@ def archives(request):
|
|||||||
return {
|
return {
|
||||||
'page_title': "Archives de %s" % theme,
|
'page_title': "Archives de %s" % theme,
|
||||||
'docs': docs,
|
'docs': docs,
|
||||||
|
'themes': themes,
|
||||||
|
'theme': theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
@view_config(route_name='doc_edit', renderer='../templates/doc_edit.pt', permission='view')
|
@view_config(route_name='doc_edit', renderer='../templates/doc_edit.pt', permission='view')
|
||||||
|
|||||||
Reference in New Issue
Block a user