2014-07-28 11:46:02 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from django.contrib.auth.decorators import user_passes_test
|
2014-07-30 13:25:57 +02:00
|
|
|
from helpdesk import settings
|
2014-07-28 11:46:02 +02:00
|
|
|
|
2014-07-30 13:25:57 +02:00
|
|
|
if settings.HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK:
|
2014-07-28 11:46:02 +02:00
|
|
|
# apply a custom user validation condition
|
2014-07-30 13:25:57 +02:00
|
|
|
is_helpdesk_staff = settings.HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK
|
|
|
|
elif settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE:
|
2014-07-28 11:46:02 +02:00
|
|
|
# treat 'normal' users like 'staff'
|
2014-07-29 20:55:25 +02:00
|
|
|
is_helpdesk_staff = lambda u: u.is_authenticated() and u.is_active
|
2014-07-28 11:46:02 +02:00
|
|
|
else:
|
2014-07-29 20:55:25 +02:00
|
|
|
is_helpdesk_staff = lambda u: u.is_authenticated() and u.is_active and u.is_staff
|
2014-07-28 11:46:02 +02:00
|
|
|
|
2014-07-29 20:55:25 +02:00
|
|
|
helpdesk_staff_member_required = user_passes_test(is_helpdesk_staff)
|
2014-07-28 11:46:02 +02:00
|
|
|
helpdesk_superuser_required = user_passes_test(lambda u: u.is_authenticated() and u.is_active and u.is_superuser)
|