From: Attila-Mihaly Balazs Date: Tue, 25 Mar 2014 10:41:00 +0000 (+0200) Subject: Simplify registry logic X-Git-Tag: live~19^2~1 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/da341d29226325536f58fb520e0e9c497bacd55d Simplify registry logic --- diff --git a/forum/modules/ui_objects.py b/forum/modules/ui_objects.py index a51044a..7fae3d4 100644 --- a/forum/modules/ui_objects.py +++ b/forum/modules/ui_objects.py @@ -40,6 +40,7 @@ class Visibility(object): Visibility.PUBLIC = Visibility('public') +Visibility.ANONYMOUS = Visibility('authenticated', negated=True) Visibility.AUTHENTICATED = Visibility('authenticated') Visibility.STAFF = Visibility('staff') Visibility.SUPERUSER = Visibility('superuser') diff --git a/forum/registry.py b/forum/registry.py index 871f1e5..ad75b1a 100644 --- a/forum/registry.py +++ b/forum/registry.py @@ -25,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=_('login'), + url=lambda u, c: reverse('logout'), + weight=200, name='LOGOUT'), ui.Link( visibility=ui.Visibility.AUTHENTICATED, text=lambda u, c: smart_unicode(u.username),