Improve code
This commit is contained in:
parent
d21e24dd6c
commit
9bc4ed00e9
2 changed files with 4 additions and 8 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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'<span class="{css_class}">{username}</span>')
|
||||
|
||||
|
|
Loading…
Reference in a new issue