mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-29 11:04:49 +00:00
Fix bug with forcing a user to exist on request
Allow for testing views without having to mock a user on the request.
This commit is contained in:
parent
6c57aba8a2
commit
875d2fcbd4
2 changed files with 8 additions and 1 deletions
|
|
@ -163,6 +163,7 @@ Contributors
|
|||
* Jesse Legg
|
||||
* Tim Leguijt
|
||||
* Luiz Boaretto
|
||||
* Jonathon Moore
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
|||
|
|
@ -36,8 +36,14 @@ def wagtailuserbar(context, position='bottom-right'):
|
|||
except KeyError:
|
||||
return ''
|
||||
|
||||
# Don't render without a user because we can't check their permissions
|
||||
try:
|
||||
user = request.user
|
||||
except AttributeError:
|
||||
return ''
|
||||
|
||||
# Don't render if user doesn't have permission to access the admin area
|
||||
if not request.user.has_perm('wagtailadmin.access_admin'):
|
||||
if not user.has_perm('wagtailadmin.access_admin'):
|
||||
return ''
|
||||
|
||||
# Don't render if this is a preview. Since some routes can render the userbar without going through Page.serve(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue