X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/554564294a9a644a3a6723c386f5eb009e23ce98..refs/heads/master:/forum/registry.py diff --git a/forum/registry.py b/forum/registry.py index ec97389..7fb8292 100644 --- a/forum/registry.py +++ b/forum/registry.py @@ -4,6 +4,7 @@ from django.utils.encoding import smart_unicode from django.core.urlresolvers import reverse from django.template.defaultfilters import slugify +from forum.models import User from forum.templatetags.extra_tags import get_score_badge from forum.utils.html import cleanup_urls from forum import settings @@ -24,10 +25,15 @@ ui.register(ui.HEADER_LINKS, 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'), - + visibility=ui.Visibility.ANONYMOUS, + text=_('login'), + url=lambda u, c: reverse('auth_signin'), + weight=200, name='LOGIN'), + ui.Link( + visibility=ui.Visibility.AUTHENTICATED, + text=_('logout'), + url=lambda u, c: reverse('logout'), + weight=200, name='LOGOUT'), ui.Link( visibility=ui.Visibility.AUTHENTICATED, text=lambda u, c: smart_unicode(u.username), @@ -70,7 +76,10 @@ class SuperUserSwitchMenuItem(ui.UserMenuItem): ui.register(ui.USER_MENU, ui.UserMenuItem( label=_("edit profile"), - url=lambda u, c: reverse('edit_user', kwargs={'id': c['user'].id}), + url=lambda u, c: reverse('edit_user', kwargs={ + 'id': c['user'].id, + 'slug' : slugify(c['user'].username) + }), span_attrs={'class': 'user-edit'}, weight=0, name='EDIT_PROFILE' @@ -84,7 +93,7 @@ ui.register(ui.USER_MENU, ), ui.UserMenuItem( label=_("email notification settings"), - url=lambda u, c: reverse('user_subscriptions', kwargs={'id': c['user'].id, 'slug': slugify(c['user'].username)}), + url=lambda u, c: User.objects.get(id=int(c['user'].id)).get_user_subscriptions_url(), span_attrs={'class': 'user-subscriptions'}, weight=200, name='EMAIL_SETTINGS'