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
|
* Jesse Legg
|
||||||
* Tim Leguijt
|
* Tim Leguijt
|
||||||
* Luiz Boaretto
|
* Luiz Boaretto
|
||||||
|
* Jonathon Moore
|
||||||
|
|
||||||
Translators
|
Translators
|
||||||
===========
|
===========
|
||||||
|
|
|
@ -36,8 +36,14 @@ def wagtailuserbar(context, position='bottom-right'):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return ''
|
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
|
# 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 ''
|
return ''
|
||||||
|
|
||||||
# Don't render if this is a preview. Since some routes can render the userbar without going through Page.serve(),
|
# 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