kopia lustrzana https://github.com/wagtail/wagtail
Fix bug with forcing a user to exist on request
Allow for testing views without having to mock a user on the request.pull/2985/head^2
rodzic
6c57aba8a2
commit
875d2fcbd4
|
@ -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(),
|
||||
|
|
Ładowanie…
Reference in New Issue