forked from extern/django-helpdesk
validate that HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK is callable, if set
This commit is contained in:
parent
c0dd6ea075
commit
b7e8ae5ee5
@ -4,6 +4,7 @@ Default settings for django-helpdesk.
|
|||||||
"""
|
"""
|
||||||
import warnings
|
import warnings
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
|
|
||||||
|
|
||||||
try:
|
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.
|
# 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)
|
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:
|
if HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK and HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"The HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE and HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK settings cannot be both defined. "
|
"The HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE and HELPDESK_CUSTOM_STAFF_FILTER_CALLBACK settings cannot be both defined. "
|
||||||
|
Loading…
Reference in New Issue
Block a user