from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse
from forum.templatetags.extra_tags import get_score_badge
+from forum import settings
-ui.register_multi(ui.HEADER_LINKS,
- ui.UiLinkObject(_('faq'), 'faq', weight=400),
- ui.UiLinkObject(_('about'), 'about', weight=300),
+ui.register(ui.HEADER_LINKS,
+ ui.Link(_('faq'), ui.Url('faq'), weight=400),
+ ui.Link(_('about'), ui.Url('about'), weight=300),
- ui.UiLinkObject(
- text=lambda c: c['request'].user.is_authenticated() and _('logout') or _('login'),
- url=lambda c: c['request'].user.is_authenticated() and reverse('logout') or reverse('auth_signin'),
+ 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.UiLinkObject(
- user_level=ui.LoggedInUserUiObject(),
- text=lambda c: c['request'].user.username,
- url=lambda c: c['request'].user.get_profile_url(),
- post_code=lambda c: get_score_badge(c['request'].user),
+ 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.UiLinkObject(
- user_level=ui.SuperuserUiObject(),
+ ui.Link(
+ visibility=ui.Visibility.SUPERUSER,
text=_('administration'),
- url=lambda c: reverse('admin_index'),
+ url=lambda u, c: reverse('admin_index'),
weight=0)
)
+class SupportLink(ui.Link):
+ def can_render(self, context):
+ return bool(settings.SUPPORT_URL)
-ui.register_multi(ui.PAGE_TOP_TABS,
- ui.UiTopPageTabObject('questions', _('questions'), 'questions', weight=0),
- ui.UiTopPageTabObject('tags', _('tags'), 'tags', weight=100),
- ui.UiTopPageTabObject('users', _('users'), 'users', weight=200),
- ui.UiTopPageTabObject('badges', _('badges'), 'badges', weight=300),
- ui.UiTopPageTabObject('unanswered', _('unanswered questions'), 'unanswered', weight=400),
+
+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'), 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),
)
-#register.header_link(lambda c: (_('faq'), reverse('faq')))
+