mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 12:31:22 -05:00
good stuff
This commit is contained in:
16
moderation/context_processors.py
Normal file
16
moderation/context_processors.py
Normal file
@@ -0,0 +1,16 @@
|
||||
def moderation_access(request):
|
||||
"""Add moderation access check to template context"""
|
||||
context = {
|
||||
'has_moderation_access': False,
|
||||
'has_admin_access': False,
|
||||
'has_superuser_access': False,
|
||||
'user_role': None
|
||||
}
|
||||
|
||||
if request.user.is_authenticated:
|
||||
context['user_role'] = request.user.role
|
||||
context['has_moderation_access'] = request.user.role in ['MODERATOR', 'ADMIN', 'SUPERUSER']
|
||||
context['has_admin_access'] = request.user.role in ['ADMIN', 'SUPERUSER']
|
||||
context['has_superuser_access'] = request.user.role == 'SUPERUSER'
|
||||
|
||||
return context
|
||||
Reference in New Issue
Block a user