Ejemplo n.º 1
0
def ban_link(context, ban_user, banner_user):
    """Returns a link to ban a user"""
    link = ''
    if ban_user.id != banner_user.id and banner_user.has_perm(
            'users.add_userban'):
        active_ban = ban_user.active_ban
        if active_ban:
            url = reverse('admin:users_userban_change', args=(active_ban.id, ))
            title = ugettext('Banned on %(ban_date)s by %(ban_admin)s.') % {
                'ban_date':
                datetimeformat(
                    context, active_ban.date, format='date', output='json'),
                'ban_admin':
                active_ban.by,
            }
            link = ('<a href="%s" class="button ban-link" title="%s">%s'
                    '<i aria-hidden="true" class="icon-ban"></i></a>' %
                    (url, title, ugettext('Banned')))
        else:
            url = '%s?user=%s&by=%s' % (reverse('admin:users_userban_add'),
                                        ban_user.id, banner_user.id)
            link = ('<a href="%s" class="button negative ban-link">%s'
                    '<i aria-hidden="true" class="icon-ban"></i></a>' %
                    (url, ugettext('Ban User')))
    return Markup(link)
Ejemplo n.º 2
0
def ban_link(context, ban_user, banner_user):
    """Returns a link to ban a user"""
    link = ''
    if ban_user.id != banner_user.id and banner_user.has_perm('users.add_userban'):
        if ban_user.profile.is_banned:
            active_ban = ban_user.profile.active_ban()
            url = reverse('admin:users_userban_change', args=(active_ban.id,))
            title = _('Banned on {ban_date} by {ban_admin}.').format(ban_date=datetimeformat(context, active_ban.date, format='date', output='json'), ban_admin=active_ban.by)
            link = '<a href="%s" class="button ban-link" title="%s">%s<i aria-hidden="true" class="icon-ban"></i></a>' % (url, title, _('Banned'))
        else:
            url = '%s?user=%s&by=%s' % (reverse('admin:users_userban_add'), ban_user.id, banner_user.id)
            link = '<a href="%s" class="button negative ban-link">%s<i aria-hidden="true" class="icon-ban"></i></a>' % (url, _('Ban User'))
    return Markup(link)
Ejemplo n.º 3
0
def ban_link(context, ban_user, banner_user):
    """Returns a link to ban a user"""
    link = ''
    if ban_user.id != banner_user.id and banner_user.has_perm('users.add_userban'):
        if ban_user.get_profile().is_banned:
            active_ban = ban_user.get_profile().active_ban()
            url = reverse('admin:users_userban_change', args=(active_ban.id,))
            title = _('Banned on {ban_date} by {ban_admin}.').format(ban_date=datetimeformat(context, active_ban.date, format='date', output='json'), ban_admin=active_ban.by )
            link = '<a href="%s" class="button ban-link" title="%s">%s<i aria-hidden="true" class="icon-ban"></i></a>' % (url, title, _('Banned'))
        else:
            url = '%s?user=%s&by=%s' % (reverse('admin:users_userban_add'), ban_user.id, banner_user.id)
            link = '<a href="%s" class="button negative ban-link">%s<i aria-hidden="true" class="icon-ban"></i></a>' % (url, _('Ban User'))
    return Markup(link)
Ejemplo n.º 4
0
def ban_link(context, ban_user, banner_user):
    """Returns a link to ban a user"""
    link = ""
    if ban_user.id != banner_user.id and banner_user.has_perm("users.add_userban"):
        active_ban = ban_user.active_ban
        if active_ban:
            url = reverse("admin:users_userban_change", args=(active_ban.id,))
            title = ugettext("Banned on {ban_date} by {ban_admin}.").format(
                ban_date=datetimeformat(context, active_ban.date, format="date", output="json"), ban_admin=active_ban.by
            )
            link = (
                '<a href="%s" class="button ban-link" title="%s">%s'
                '<i aria-hidden="true" class="icon-ban"></i></a>' % (url, title, ugettext("Banned"))
            )
        else:
            url = "%s?user=%s&by=%s" % (reverse("admin:users_userban_add"), ban_user.id, banner_user.id)
            link = (
                '<a href="%s" class="button negative ban-link">%s'
                '<i aria-hidden="true" class="icon-ban"></i></a>' % (url, ugettext("Ban User"))
            )
    return Markup(link)
Ejemplo n.º 5
0
def ban_link(context, ban_user, banner_user):
    """Returns a link to ban a user"""
    link = ''
    if ban_user.id != banner_user.id and banner_user.has_perm('users.add_userban'):
        active_ban = ban_user.active_ban
        if active_ban:
            url = reverse('admin:users_userban_change', args=(active_ban.id,))
            title = ugettext('Banned on %(ban_date)s by %(ban_admin)s.') % {
                'ban_date': datetimeformat(context, active_ban.date,
                                           format='date', output='json'),
                'ban_admin': active_ban.by,
            }
            link = ('<a href="%s" class="button ban-link" title="%s">%s'
                    '<i aria-hidden="true" class="icon-ban"></i></a>'
                    % (url, title, ugettext('Banned')))
        else:
            url = '%s?user=%s&by=%s' % (
                reverse('admin:users_userban_add'), ban_user.id,
                banner_user.id)
            link = ('<a href="%s" class="button negative ban-link">%s'
                    '<i aria-hidden="true" class="icon-ban"></i></a>'
                    % (url, ugettext('Ban User')))
    return Markup(link)