]> git.openstreetmap.org Git - osqa.git/blob - forum/startup.py
Various improvements in module functionality, and a couple of migrations to fix some...
[osqa.git] / forum / startup.py
1 import sys
2 import os
3 sys.path.append(os.path.join(os.path.dirname(__file__),'markdownext'))
4
5
6 from forum.modules import get_modules_script, ui
7
8 get_modules_script('settings')
9 get_modules_script('startup')
10
11
12 import forum.badges
13 import forum.subscriptions
14
15
16 from django.utils.translation import ugettext as _
17 from django.core.urlresolvers import reverse
18 from forum.templatetags.extra_tags import get_score_badge
19 from forum import settings
20
21
22 ui.register(ui.HEADER_LINKS,
23             ui.Link(_('faq'), ui.Url('faq'), weight=400),
24             ui.Link(_('about'), ui.Url('about'), weight=300),
25
26             ui.Link(
27                     text=lambda u, c: u.is_authenticated() and _('logout') or _('login'),
28                     url=lambda u, c: u.is_authenticated() and reverse('logout') or reverse('auth_signin'),
29                     weight=200),
30
31             ui.Link(
32                     visibility=ui.Visibility.AUTHENTICATED,
33                     text=lambda u, c: u.username,
34                     url=lambda u, c: u.get_profile_url(),
35                     post_code=lambda u, c: get_score_badge(u),
36                     weight=100),
37
38             ui.Link(
39                     visibility=ui.Visibility.SUPERUSER,
40                     text=_('administration'),
41                     url=lambda u, c: reverse('admin_index'),
42                     weight=0)
43
44 )
45
46 class SupportLink(ui.Link):    
47     def can_render(self, context):
48         return bool(settings.SUPPORT_URL)
49
50
51 ui.register(ui.FOOTER_LINKS,
52             ui.Link(
53                     text=_('contact'),
54                     url=lambda u, c: settings.CONTACT_URL and settings.CONTACT_URL or "%s?next=%s" % (reverse('feedback'), c['request'].path),
55                     weight=400),
56             SupportLink(_('support'), settings.SUPPORT_URL, attrs={'target': '_blank'}, weight=300),
57             ui.Link(_('privacy'), ui.Url('privacy'), weight=200),
58             ui.Link(_('faq'), ui.Url('faq'), weight=100),
59             ui.Link(_('about'), ui.Url('about'), weight=0),
60 )
61
62
63
64
65