Exemplo n.º 1
0
from forum.utils.html import cleanup_urls
from forum import settings


try:
    from django.template import get_templatetags_modules
    modules_template_tags = get_modules_script('templatetags')
    django_template_tags = get_templatetags_modules()

    for m in modules_template_tags:
        django_template_tags.append(m.__name__)
except:
    pass

ui.register(ui.HEADER_LINKS,
            ui.Link(_('faq'), ui.Url('faq'), weight=400, name='FAQ'),
            ui.Link(_('about'), ui.Url('about'), weight=300, name='ABOUT'),

            ui.Link(
                    text=lambda u, c: u.is_authenticated() and _('logout') or _('login'),
                    url=lambda u, c: u.is_authenticated() and reverse('logout') or reverse('auth_signin'),
                    weight=200, name='LOGIN/OUT'),

            ui.Link(
                    visibility=ui.Visibility.AUTHENTICATED,
                    text=lambda u, c: smart_unicode(u.username),
                    url=lambda u, c: u.get_profile_url(),
                    post_code=lambda u, c: get_score_badge(u),
                    weight=100, name='ACCOUNT'),

            ui.Link(
Exemplo n.º 2
0
    def can_render(self, context):
        return bool(settings.SUPPORT_URL)


ui.register(
    ui.FOOTER_LINKS,
    ui.Link(text=_('contact'),
            url=lambda u, c: settings.CONTACT_URL and settings.CONTACT_URL or
            "%s?next=%s" %
            (reverse('feedback'), cleanup_urls(c['request'].path)),
            weight=400),
    SupportLink(_('support'),
                settings.SUPPORT_URL,
                attrs={'target': '_blank'},
                weight=300),
    ui.Link(_('privacy'), ui.Url('privacy'), weight=200),
    ui.Link(_('faq'), ui.Url('faq'), weight=100),
    ui.Link(_('about'), ui.Url('about'), weight=0),
)


class ModerationMenuGroup(ui.AjaxMenuGroup):
    def can_render(self, context):
        return context['user'] != context['viewer'] and super(
            ModerationMenuGroup, self).can_render(context)


class SuperUserSwitchMenuItem(ui.UserMenuItem):
    def can_render(self, context):
        return context[
            'viewer'].is_siteowner or not context['user'].is_superuser
Exemplo n.º 3
0
#encoding=utf-8
from forum.modules import ui
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse
from django.template.defaultfilters import slugify
from forum.templatetags.extra_tags import get_score_badge
from forum.utils.html import cleanup_urls
from forum import settings

ui.register(
    ui.HEADER_LINKS, ui.Link(_('faq'), ui.Url('faq'), weight=400),
    ui.Link(_('about'), ui.Url('about'), weight=300),
    ui.Link(
        text=lambda u, c: u.is_authenticated() and _('logout') or _('login'),
        url=lambda u, c: u.is_authenticated() and reverse('logout') or reverse(
            'auth_signin'),
        weight=200),
    ui.Link(visibility=ui.Visibility.AUTHENTICATED,
            text=lambda u, c: u.username,
            url=lambda u, c: u.get_profile_url(),
            post_code=lambda u, c: get_score_badge(u),
            weight=100),
    ui.Link(visibility=ui.Visibility.SUPERUSER,
            text=_('administration'),
            url=lambda u, c: reverse('admin_index'),
            weight=0))


class SupportLink(ui.Link):
    def can_render(self, context):
        return bool(settings.SUPPORT_URL)
Exemplo n.º 4
0
from forum import settings

from unidecode import unidecode

try:
    from django.template import get_templatetags_modules
    modules_template_tags = get_modules_script('templatetags')
    django_template_tags = get_templatetags_modules()

    for m in modules_template_tags:
        django_template_tags.append(m.__name__)
except:
    pass

ui.register(
    ui.HEADER_LINKS, ui.Link(_('faq'), ui.Url('faq'), weight=100, name='FAQ'),
    ui.Link(_('about'), ui.Url('about'), weight=0, name='ABOUT'),
    ui.Link(
        text=lambda u, c: u.is_authenticated() and _('logout') or _('login'),
        url=lambda u, c: u.is_authenticated() and reverse('logout') or reverse(
            'auth_signin'),
        weight=400,
        name='LOGIN/OUT'),
    ui.Link(visibility=ui.Visibility.AUTHENTICATED,
            text=lambda u, c: smart_unicode(u.username),
            url=lambda u, c: u.get_profile_url(),
            post_code=lambda u, c: get_score_badge(u),
            weight=300,
            name='ACCOUNT'),
    ui.Link(visibility=ui.Visibility.SUPERUSER,
            text=_('administration'),