2022-11-05 20:17:27 +00:00
|
|
|
from functools import wraps
|
|
|
|
|
2022-11-17 04:14:05 +00:00
|
|
|
from django.contrib.auth.decorators import user_passes_test
|
2022-11-05 20:17:27 +00:00
|
|
|
from django.contrib.auth.views import redirect_to_login
|
|
|
|
from django.http import HttpResponseRedirect
|
|
|
|
|
|
|
|
|
2022-12-20 09:01:54 +00:00
|
|
|
def moderator_required(function):
|
|
|
|
return user_passes_test(
|
|
|
|
lambda user: user.is_authenticated and (user.admin or user.moderator)
|
|
|
|
)(function)
|
|
|
|
|
|
|
|
|
2022-11-17 04:14:05 +00:00
|
|
|
def admin_required(function):
|
2022-11-26 01:37:09 +00:00
|
|
|
return user_passes_test(lambda user: user.is_authenticated and user.admin)(function)
|