validate that HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK is callable, if set

This commit is contained in:
Stefano Brentegani 2014-07-30 06:35:52 +02:00
parent c0dd6ea075
commit b7e8ae5ee5

View File

@ -4,6 +4,7 @@ Default settings for django-helpdesk.
"""
import warnings
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
try:
@ -66,6 +67,8 @@ HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE = getattr(settings, 'HELPDESK_ALLOW_NON_S
# apply a custom authorisation logic when defining 'helpdesk_staff_member_required' in staff.py.
HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK = getattr(settings, 'HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK', None)
if not (HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK is None or callable(HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK)):
raise ImproperlyConfigured("HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK must be a callable or None")
if HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK and HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE:
warnings.warn(
"The HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE and HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK settings cannot be both defined. "