Skip to content
Snippets Groups Projects
Unverified Commit 642b7099 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Add decorators to simplify checking for role.

parent 561c3584
No related branches found
No related tags found
No related merge requests found
from django.contrib.auth.decorators import user_passes_test
def student_required(function=None):
actual_decorator = user_passes_test(lambda u: u.is_active and u.is_student)
return actual_decorator(function)
def teacher_required(function=None):
actual_decorator = user_passes_test(lambda u: u.is_active and u.is_teacher)
return actual_decorator(function)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment