From bc05ceda5e1e9ac799116019b8b9fc3be39bc8eb Mon Sep 17 00:00:00 2001 From: fireworks88 Date: Sat, 24 Jul 2021 21:54:34 +0200 Subject: [PATCH] sneed --- drama/classes/user.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drama/classes/user.py b/drama/classes/user.py index 414d0df88..478f1e642 100644 --- a/drama/classes/user.py +++ b/drama/classes/user.py @@ -154,6 +154,11 @@ class User(Base, Stndrd, Age_times): lazy="dynamic", primaryjoin="User.id==SaveRelationship.user_id") + awards = relationship( + "AwardRelationship", + primaryjoin="User.id==AwardRelationship.user_id" + ) + # properties defined as SQL server-side functions referral_count = deferred(Column(Integer, server_default=FetchedValue())) follower_count = deferred(Column(Integer, server_default=FetchedValue())) @@ -613,6 +618,9 @@ class User(Base, Stndrd, Age_times): pic = random.randint(1, 50) return f"/assets/images/defaultpictures/{pic}.png" + def has_award(self, kind): + return bool(len([x for x in self.awards if x.kind == kind])) + @property def profile_url(self): if self.has_profile and self.profileurl: