From 9da11b62ca99ceace1d602a30c6103fa323fe076 Mon Sep 17 00:00:00 2001 From: Eragon Date: Thu, 5 Dec 2019 11:40:28 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Fix=20du=20probl=C3=A8me=20de=20date=20diff?= =?UTF-8?q?=C3=A9rente=20au=20post=20initial?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La date de publication et la date de modification n'étaient pas les mêmes lors de la création du message. --- app/models/post.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/post.py b/app/models/post.py index eef1887..88daabb 100644 --- a/app/models/post.py +++ b/app/models/post.py @@ -2,6 +2,7 @@ from app import db from app.models.users import User from datetime import datetime + class Post(db.Model): """Contents created and published by Users.""" @@ -18,7 +19,7 @@ class Post(db.Model): # Post author author_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) - author = db.relationship('User', backref="posts",foreign_keys=author_id) + author = db.relationship('User', backref="posts", foreign_keys=author_id) # TODO: Post attachments? @@ -37,7 +38,7 @@ class Post(db.Model): self.author = author self.date_created = datetime.now() - self.date_modified = datetime.now() + self.date_modified = self.date_created def touch(self): """Touch a Post when it is edited.""" From 90ac25917750fc4119f89de6bc1b1d905ab84e11 Mon Sep 17 00:00:00 2001 From: Eragon Date: Thu, 5 Dec 2019 17:14:40 +0100 Subject: [PATCH 2/2] Ajout de la date de publication et de modification d'un post --- app/templates/forum/topic.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/templates/forum/topic.html b/app/templates/forum/topic.html index 78a9f27..456b34d 100644 --- a/app/templates/forum/topic.html +++ b/app/templates/forum/topic.html @@ -13,14 +13,20 @@ {{ widget_member.profile(t.author ) }} {{ t.thread.top_comment.text }} -
{% for i, c in enumerate(t.thread.comments) %} {% if c != t.thread.top_comment %} -
{{ widget_member.profile(c.author ) }}{{ c.text }} + + {% if c.date_created != c.date_modified %} + Le {{ c.date_created|date }} (Modifié le {{ c.date_modified|date }}) + {% elif c.date_created == c.date_modified %} + Le {{ c.date_created|date }} + {% endif %} +
+

{{ c.text }}

{% elif i != 0 %}
Ce message est le top comment
{% endif %}