]> git.openstreetmap.org Git - osqa.git/commitdiff
Simplify registry logic
authorAttila-Mihaly Balazs <dify.ltd@gmail.com>
Tue, 25 Mar 2014 10:41:00 +0000 (12:41 +0200)
committerAttila-Mihaly Balazs <dify.ltd@gmail.com>
Tue, 25 Mar 2014 10:41:00 +0000 (12:41 +0200)
forum/modules/ui_objects.py
forum/registry.py

index a51044ad527f3a9fe661880258c2060e389812dc..7fae3d43a8ef4bbf41c8056e73a4d53401fef799 100644 (file)
@@ -40,6 +40,7 @@ class Visibility(object):
         
 
 Visibility.PUBLIC = Visibility('public')
         
 
 Visibility.PUBLIC = Visibility('public')
+Visibility.ANONYMOUS = Visibility('authenticated', negated=True)
 Visibility.AUTHENTICATED = Visibility('authenticated')
 Visibility.STAFF = Visibility('staff')
 Visibility.SUPERUSER = Visibility('superuser')
 Visibility.AUTHENTICATED = Visibility('authenticated')
 Visibility.STAFF = Visibility('staff')
 Visibility.SUPERUSER = Visibility('superuser')
index 871f1e5d0eccf65f036106cb495b50d2b3346a4b..ad75b1abffe1fa8644eeb83d9e57995450f6966f 100644 (file)
@@ -25,10 +25,15 @@ ui.register(ui.HEADER_LINKS,
             ui.Link(_('about'), ui.Url('about'), weight=300, name='ABOUT'),
 
             ui.Link(
             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),
             ui.Link(
                     visibility=ui.Visibility.AUTHENTICATED,
                     text=lambda u, c: smart_unicode(u.username),