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
|
@classmethod
|
||||||
def is_friend(self, current_user, new_friend):
|
def is_friend(self, current_user, new_friend):
|
||||||
try:
|
try:
|
||||||
return (
|
return current_user.following_users.filter(users=new_friend).exists()
|
||||||
current_user.following_users.get()
|
|
||||||
.users.filter(user=new_friend.user)
|
|
||||||
.exists()
|
|
||||||
)
|
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -100,12 +100,12 @@ class UserPage(TitleMixin, UserMixin, DetailView):
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
return (
|
return (
|
||||||
_("My account")
|
_("My account")
|
||||||
if self.request.user == self.object.user
|
if self.request.profile == self.object
|
||||||
else _("User %s") % self.object.user.username
|
else _("User %s") % self.object.username
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_content_title(self):
|
def get_content_title(self):
|
||||||
username = self.object.user.username
|
username = self.object.username
|
||||||
css_class = self.object.css_class
|
css_class = self.object.css_class
|
||||||
return mark_safe(f'<span class="{css_class}">{username}</span>')
|
return mark_safe(f'<span class="{css_class}">{username}</span>')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue