def who(self, comment):
"""
Who made this comment. If it is a user, link to their profile in the
admin; otherwise show their name and email address.
"""
if comment.user:
user = comment.user
user_display = user.get_full_name() \
or getattr(user, user.USERNAME_FIELD)
try:
# Just incase someone is running a minimal install without
# wagtailusers installed.
return format_html('<a href="{url}">{name}</a>'.format(
url=reverse('wagtailusers_users:edit', args=[user.pk]),
name=user_display))
except NoReverseMatch:
return user_display
else:
return '{name} ({email})'.format(name=comment.user_name,
email=comment.user_email)
评论列表
文章目录