Skip to content

Commit

Permalink
avoid AttributeError in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
bbonf committed Nov 11, 2024
1 parent 4189fdb commit fe6777b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions main/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@
Menu.add_item("main", MenuItem(_('mainmenu:login'),
reverse('main:login'),
exact_url=True,
check=lambda x: not x.user.is_authenticated
check=lambda x: not hasattr(x, 'user') or not x.user.is_authenticated
))

Menu.add_item("main", MenuItem(_('mainmenu:experiments'),
reverse('experiments:home'),
exact_url=True,
check=lambda x: x.user.is_authenticated
check=lambda x: hasattr(x, 'user') and x.user.is_authenticated
))

Menu.add_item("main", MenuItem(_('mainmenu:help'),
reverse('main:help'),
exact_url=False,
check=lambda x: x.user.is_authenticated
check=lambda x: hasattr(x, 'user') and x.user.is_authenticated
))

Menu.add_item("main", MenuItem(_('mainmenu:administration'),
reverse('administration:home'),
exact_url=True,
check=lambda x: x.user.is_staff
check=lambda x: hasattr(x, 'user') and x.user.is_staff
))

Menu.add_item("footer", MenuItem(_('footermenu:login'),
reverse('main:login'),
check=lambda x: not x.user.is_authenticated
check=lambda x: not hasattr(x, 'user') or not x.user.is_authenticated
))

Menu.add_item("footer", MenuItem(_('main:globals:logout'),
reverse('main:logout'),
check=lambda x: x.user.is_authenticated
))
check=lambda x: hasattr(x, 'user') and x.user.is_authenticated
))

0 comments on commit fe6777b

Please sign in to comment.