added recon method

This commit is contained in:
2024-02-22 14:04:35 +01:00
parent 2d6b5ae823
commit 0d7314b3bd
8 changed files with 13 additions and 39 deletions

View File

@@ -15,12 +15,12 @@ Requires-Dist: pyramid
Requires-Dist: pyramid_jinja2
Requires-Dist: pyramid_debugtoolbar
Requires-Dist: waitress
Requires-Dist: alembic
Requires-Dist: alembic==1.4.2
Requires-Dist: pyramid_retry
Requires-Dist: pyramid_layout
Requires-Dist: pyramid_tm
Requires-Dist: python-magic
Requires-Dist: SQLAlchemy
Requires-Dist: SQLAlchemy==1.4.49
Requires-Dist: transaction
Requires-Dist: zope.sqlalchemy
Requires-Dist: wtforms

View File

@@ -3,12 +3,12 @@ pyramid
pyramid_jinja2
pyramid_debugtoolbar
waitress
alembic
alembic==1.4.2
pyramid_retry
pyramid_layout
pyramid_tm
python-magic
SQLAlchemy
SQLAlchemy==1.4.49
transaction
zope.sqlalchemy
wtforms

Binary file not shown.

View File

@@ -25,13 +25,13 @@ class BlogRecordService(object):
return query.get(_id)
@classmethod
def get_last_created(cls, request):
# gest the 10 last created posts
def get_last_edited(cls, request):
# gest the 10 last edited posts
query = request.dbsession.query(BlogRecord)
if request.authenticated_userid == None:
# if user is anonym, display only published posts
query = query.filter(BlogRecord.status == 'publié')
query = query.order_by(sa.desc(BlogRecord.created)).limit(10).all()
query = query.order_by(sa.desc(BlogRecord.edited)).limit(10).all()
return query
@classmethod

View File

@@ -83,7 +83,7 @@ h3, h4 {
.navbar {
font-family: Montserrat, sans-serif;
margin-bottom: 0;
background-color: #bc2131;
background-color: #2F4F4F;
border: 0;
font-size: 14px !important;
letter-spacing: 4px;
@@ -103,7 +103,7 @@ h3, h4 {
border-color: transparent;
}
footer {
background-color: #bc2131;
background-color: #2F4F4F;
color: #f5f5f5;
padding: 32px;
}

View File

@@ -11,7 +11,7 @@
<table id="posts_list" class="table table-condensed">
{% for entry in last_ten %}
<tr>
<td>{{ entry.created.strftime("%d.%m.%Y") }}</td>
<td>{{ entry.edited.strftime("%d.%m.%Y") }}</td>
<td>
<a href="{{ request.route_url('blog', id=entry.id, slug=entry.slug) }}">{{ entry.title }}</a>
</td>
@@ -27,28 +27,6 @@
{% endfor %}
</table>
<!-- formulaire de recherche -->
<hr>
<br>
<br>
<div class="well">
<form id="search-form" role="form" action="/blog_search" method="post">
<div class="form-group">
<label for="criteria">{{ form.criteria.label }}</label>
<div class="input-group">
{{ form.criteria(class_='form-control') }}
<span class="input-group-btn">
<button class="btn btn-primary" type="submit" name="form.submitted">
Rechercher
</button>
</span>
</div>
{% for error in form.criteria.errors %}
<div class="text-danger">{{ error }}</div>
{% endfor %}
</div>
</form>
</div>
{% endblock %}

View File

@@ -16,16 +16,12 @@ import magic
@view_config(route_name='home', renderer='../templates/home.jinja2', permission='view')
def home(request):
# get the last created posts
last_ten = BlogRecordService.get_last_created(request)
last_ten = BlogRecordService.get_last_edited(request)
criteria = ''
form = BlogSearchForm(request.POST)
return {
'page_title': "",
'last_ten': last_ten,
'form': form,
'criteria': criteria,
}

View File

@@ -14,12 +14,12 @@ requires = [
'pyramid_jinja2',
'pyramid_debugtoolbar',
'waitress',
'alembic',
'alembic==1.4.2',
'pyramid_retry',
'pyramid_layout',
'pyramid_tm',
'python-magic',
'SQLAlchemy',
'SQLAlchemy==1.4.49',
'transaction',
'zope.sqlalchemy',
'wtforms', # form library 2.2.1