From 3a46f8046c0e91698cd9c21c5df75afd973d26b0 Mon Sep 17 00:00:00 2001 From: Darks Date: Thu, 23 Jul 2020 20:19:03 +0200 Subject: [PATCH] =?UTF-8?q?topics:=20ADD=20une=20relationship=20dans=20`Me?= =?UTF-8?q?mber`=20Et=20une=20relation=20`comments`=20vers=20les=20comment?= =?UTF-8?q?aires.=20Moins=20utile,=20mais=20=C3=A7a=20coute=20rien.=20Corr?= =?UTF-8?q?ige=20par=20la=20m=C3=AAme=20occasion=20les=20probl=C3=A8mes=20?= =?UTF-8?q?de=20perfs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/users.py | 5 ++++- app/templates/account/user.html | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/users.py b/app/models/users.py index 36ea44a..807f847 100644 --- a/app/models/users.py +++ b/app/models/users.py @@ -32,7 +32,8 @@ class User(UserMixin, db.Model): # User type (polymorphic discriminator) type = db.Column(db.String(30)) - # Also a [posts] relationship populated from the Post class. + # Other fields populated automatically through relations: + # relationship populated from the Post class. __mapper_args__ = { 'polymorphic_identity': __tablename__, @@ -106,6 +107,8 @@ class Member(User): # Relations trophies = db.relationship('Trophy', secondary=TrophyMember, back_populates='owners') + topics = db.relationship('Topic') + comments = db.relationship('Comment') # Displayed title # title_id = db.Column(db.Integer, db.ForeignKey('title.id')) diff --git a/app/templates/account/user.html b/app/templates/account/user.html index dc80ac9..147bc76 100644 --- a/app/templates/account/user.html +++ b/app/templates/account/user.html @@ -69,7 +69,7 @@ Création Commentaires - {% for t in member.posts if t.type == "topic" %} + {% for t in member.topics %} {{ t.title }} {{ t.forum.name }}