Add setting HELPDESK_ACTIVATE_API_ENDPOINT and document it

This commit is contained in:
Benbb96 2022-04-15 00:05:51 +02:00
parent 3e331c08fb
commit dc60d8a7f9
5 changed files with 21 additions and 6 deletions

View File

@ -117,6 +117,9 @@ HELPDESK_KB_ENABLED = True
# Allow users to change their passwords
HELPDESK_SHOW_CHANGE_PASSWORD = True
# Activate the API
HELPDESK_ACTIVATE_API_ENDPOINT = True
# Instead of showing the public web portal first,
# we can instead redirect users straight to the login page.
HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT = False

View File

@ -3,6 +3,10 @@ API
A REST API (built with ``djangorestframework``) is available in order to list, create, update and delete tickets from other tools thanks to HTTP requests.
If you wish to use it, you have to add this line in your settings::
HELPDESK_ACTIVATE_API_ENDPOINT = True
You must be authenticated to access the API, the URL endpoint is ``/api/tickets/``. You can configure how you wish to authenticate to the API by customizing the ``DEFAULT_AUTHENTICATION_CLASSES`` key in the ``REST_FRAMEWORK`` setting (more information on this page : https://www.django-rest-framework.org/api-guide/authentication/)
GET

View File

@ -168,6 +168,10 @@ Staff Ticket Creation Settings
**Default:** ``HELPDESK_CREATE_TICKET_HIDE_ASSIGNED_TO = False``
- **HELPDESK_ACTIVATE_API_ENDPOINT** Activate the API endpoint to manage tickets thanks to Django REST Framework. See the API section in documentation for more information.
**Default:** ``HELPDESK_ACTIVATE_API_ENDPOINT = False``
Staff Ticket View Settings
------------------------------

View File

@ -172,6 +172,9 @@ HELPDESK_MAX_EMAIL_ATTACHMENT_SIZE = getattr(settings, 'HELPDESK_MAX_EMAIL_ATTAC
HELPDESK_CREATE_TICKET_HIDE_ASSIGNED_TO = getattr(
settings, 'HELPDESK_CREATE_TICKET_HIDE_ASSIGNED_TO', False)
# Activate the API endpoint to manage tickets thanks to Django REST Framework
HELPDESK_ACTIVATE_API_ENDPOINT = getattr(settings, 'HELPDESK_ACTIVATE_API_ENDPOINT', False)
#################
# email options #

View File

@ -219,12 +219,13 @@ urlpatterns += [
]
# API
router = DefaultRouter()
router.register(r'tickets', TicketViewSet, basename='ticket')
urlpatterns += [
url(r'^api/', include(router.urls))
]
# API is added to url conf based on the setting (False by default)
if helpdesk_settings.HELPDESK_ACTIVATE_API_ENDPOINT:
router = DefaultRouter()
router.register(r'tickets', TicketViewSet, basename='ticket')
urlpatterns += [
url(r'^api/', include(router.urls))
]
urlpatterns += [