From 9bc4ed00e9eaec18a9b5baa369f97f6fc1d9cf72 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Thu, 23 Nov 2023 21:52:19 -0600 Subject: [PATCH] Improve code --- judge/models/profile.py | 6 +----- judge/views/user.py | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/judge/models/profile.py b/judge/models/profile.py index 3692e39..6d3b131 100644 --- a/judge/models/profile.py +++ b/judge/models/profile.py @@ -468,11 +468,7 @@ class Friend(models.Model): @classmethod def is_friend(self, current_user, new_friend): try: - return ( - current_user.following_users.get() - .users.filter(user=new_friend.user) - .exists() - ) + return current_user.following_users.filter(users=new_friend).exists() except: return False diff --git a/judge/views/user.py b/judge/views/user.py index db073f1..aa0eff4 100644 --- a/judge/views/user.py +++ b/judge/views/user.py @@ -100,12 +100,12 @@ class UserPage(TitleMixin, UserMixin, DetailView): def get_title(self): return ( _("My account") - if self.request.user == self.object.user - else _("User %s") % self.object.user.username + if self.request.profile == self.object + else _("User %s") % self.object.username ) def get_content_title(self): - username = self.object.user.username + username = self.object.username css_class = self.object.css_class return mark_safe(f'{username}')