takahe/users/decorators.py

12 lines
340 B
Python
Raw Normal View History

from django.contrib.auth.decorators import user_passes_test
2022-12-20 01:01:54 -08:00
def moderator_required(function):
return user_passes_test(
lambda user: user.is_authenticated and (user.admin or user.moderator)
)(function)
def admin_required(function):
return user_passes_test(lambda user: user.is_authenticated and user.admin)(function)