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()
|
||||
return results
|
||||
|
||||
def get_docs_bycritere(request, critere):
|
||||
query = "SELECT * FROM docs WHERE texte like :critere;"
|
||||
def get_docs_bycritere(request, critere, logged_in):
|
||||
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()
|
||||
return results
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ def includeme(config):
|
||||
config.add_static_view('static', 'static', cache_max_age=3600)
|
||||
config.add_route('home', '/')
|
||||
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_view', '/doc_view/{doc_id}')
|
||||
config.add_route('doc_search', '/doc_search')
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
<div metal:use-macro="load: global_layout.pt">
|
||||
<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">
|
||||
<p tal:condition="not layout.isAnonymous()">
|
||||
<a href="${request.application_url}/doc_edit/0">Créer un nouveau post</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<tr tal:repeat="ligne docs">
|
||||
<td><a href="/doc_view/${ligne.doc_id}"><b>${ligne.intitule}</b></a></td>
|
||||
|
||||
@@ -69,8 +69,6 @@
|
||||
<footer class="container-fluid bg-footer">
|
||||
<div class="row">
|
||||
<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">
|
||||
<img src="${request.static_url('caotek_mesavoirs:static/img/instagram.png')}" /></a><br />
|
||||
</p>
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<h3>Derniers posts</h3>
|
||||
<p tal:condition="not layout.isAnonymous()">
|
||||
<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>
|
||||
<p>
|
||||
| <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>
|
||||
|
||||
<table class="table">
|
||||
@@ -21,20 +22,6 @@
|
||||
</table>
|
||||
</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>
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
<li class="divider"></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}/portfolio">Porfolio</a></li>
|
||||
|
||||
<li class="divider"></li>
|
||||
<li><a href="${request.application_url}/logout">
|
||||
|
||||
@@ -85,7 +85,13 @@ def home(request):
|
||||
|
||||
@view_config(route_name='archives', renderer='../templates/archives.pt')
|
||||
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
|
||||
docs = get_docs_bytheme(request, theme)
|
||||
@@ -93,6 +99,8 @@ def archives(request):
|
||||
return {
|
||||
'page_title': "Archives de %s" % theme,
|
||||
'docs': docs,
|
||||
'themes': themes,
|
||||
'theme': theme,
|
||||
}
|
||||
|
||||
@view_config(route_name='doc_edit', renderer='../templates/doc_edit.pt', permission='view')
|
||||
|
||||
Reference in New Issue
Block a user