added update created date in blog_edit

This commit is contained in:
2023-03-25 11:23:10 +01:00
parent fca4cd35dc
commit 2da0f86399
2 changed files with 11 additions and 5 deletions

View File

@@ -36,11 +36,11 @@
</div> </div>
<p> <p>
Topic : <strong>{{ entry.topic_id }}</strong> Topic : <strong>{{ entry.topic_id }}</strong><br>
{% if blog_id != '0' %} {% if blog_id != '0' %}
&nbsp;|&nbsp;
Créé le : <strong>{{ entry.created.strftime("%d-%m-%Y - %H:%M") }}</strong> Créé le : <strong>{{ entry.created.strftime("%d-%m-%Y - %H:%M") }}</strong>
&nbsp;|&nbsp; <button class="btn btn-link" type="submit" name="form.update_created">[ Mettre à jour ]</button>
<br>
Modifié le : <strong>{{ entry.edited.strftime("%d-%m-%Y - %H:%M") }}</strong> Modifié le : <strong>{{ entry.edited.strftime("%d-%m-%Y - %H:%M") }}</strong>
{% endif %} {% endif %}
</p> </p>

View File

@@ -103,6 +103,12 @@ def blog_edit(request):
entry.editor = request.authenticated_userid entry.editor = request.authenticated_userid
return HTTPFound(location=request.route_url('blog', id=entry.id, slug=entry.slug)) return HTTPFound(location=request.route_url('blog', id=entry.id, slug=entry.slug))
if 'form.update_created' in request.params and form.validate():
del form.id # SECURITY: prevent overwriting of primary key
form.populate_obj(entry)
entry.created = datetime.datetime.now()
return HTTPFound(location=request.route_url('blog', id=entry.id, slug=entry.slug))
if 'form.deleted' in request.params: if 'form.deleted' in request.params:
BlogRecordService.delete(request, blog_id) BlogRecordService.delete(request, blog_id)
request.session.flash("La page a été supprimée avec succès.", 'success') request.session.flash("La page a été supprimée avec succès.", 'success')