Exemple #1
0
 def user_account(self, instance):
     user = instance.user
     html = '<a href="{url}">{account}</a>'.format(
         url=get_admin_url(user),
         account=user.email
     ) if user else 'Orphan profile'
     return format_html(html)
Exemple #2
0
 def entries(self, instance):
     entries = Entry.objects.filter(published_by=instance)
     rows = [
         '<tr><td><a href="{url}">{title} (id={id})</a></td></tr>'.format(
             url=get_admin_url(entry), id=entry.id, title=entry.title)
         for entry in entries
     ]
     return format_html('<table>{rows}</table>'.format(rows=''.join(rows)))
Exemple #3
0
    def user_profile(self, instance):
        """
        Link to this user's profile
        """
        profile = instance.profile

        html = '<a href="{url}">Click here for this user\'s profile</a>'.format(
            url=get_admin_url(profile))

        return format_html(html)
Exemple #4
0
    def profile(self, instance):
        """
        Link to this user's profile
        """
        profile = UserProfile.objects.get(user=instance)

        html = '<a href="{url}">Click here for this user\'s profile</a>'.format(
            url=get_admin_url(profile))

        return format_html(html)
Exemple #5
0
    def user_profile(self, instance):
        """
        Link to this user's profile
        """

        try:
            profile = instance.profile
            html = '<a href="{url}">Click here for this user\'s profile</a>'.format(
                url=get_admin_url(profile)
            )
        except AttributeError:
            html = '<p>No profile found for this user.</p>'

        return format_html(html)
Exemple #6
0
 def user_account(self, instance):
     html = '<a href="{url}">{account}</a>'.format(
         url=get_admin_url(instance.user), account=instance.user.email)
     return format_html(html)