Changed settings to support simple enable/disable of teams.

This commit is contained in:
Christopher Broderick 2023-11-15 00:41:56 +00:00
parent 4c0c6b7fca
commit 9147cb16d5
2 changed files with 26 additions and 19 deletions

View File

@ -1,14 +1,8 @@
""" """
Django settings for django-helpdesk demodesk project. Django settings for django-helpdesk demodesk project.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
""" """
import os import os
@ -39,9 +33,10 @@ ALLOWED_HOSTS = []
# an internal demo you don't need such security, but please # an internal demo you don't need such security, but please
# remember when setting up your own development / production server! # remember when setting up your own development / production server!
# Default teams mode to enabled unless overridden by an environment variable set to "false"
HELPDESK_TEAMS_MODE_ENABLED=False if "false" == os.getenv("HELPDESK_TEAMS_MODE_ENABLED", "true").lower() else True
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
@ -52,13 +47,16 @@ INSTALLED_APPS = [
'django.contrib.sites', 'django.contrib.sites',
'django.contrib.humanize', 'django.contrib.humanize',
'bootstrap4form', 'bootstrap4form',
'account', # Required by pinax-teams
'pinax.invitations', # required by pinax-teams
'pinax.teams', # team support
'reversion', # required by pinax-teams
'helpdesk', # This is us! 'helpdesk', # This is us!
'rest_framework', # required for the API 'rest_framework', # required for the API
] ]
if HELPDESK_TEAMS_MODE_ENABLED:
INSTALLED_APPS.extend([
'account', # Required by pinax-teams
'pinax.invitations', # required by pinax-teams
'pinax.teams', # team support
'reversion', # required by pinax-teams
])
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',

View File

@ -60,9 +60,6 @@ HELPDESK_ANON_ACCESS_RAISES_404 = getattr(settings,
'HELPDESK_ANON_ACCESS_RAISES_404', 'HELPDESK_ANON_ACCESS_RAISES_404',
False) False)
# show knowledgebase links?
HELPDESK_KB_ENABLED = getattr(settings, 'HELPDESK_KB_ENABLED', True)
# Disable Timeline on ticket list # Disable Timeline on ticket list
HELPDESK_TICKETS_TIMELINE_ENABLED = getattr( HELPDESK_TICKETS_TIMELINE_ENABLED = getattr(
settings, 'HELPDESK_TICKETS_TIMELINE_ENABLED', True) settings, 'HELPDESK_TICKETS_TIMELINE_ENABLED', True)
@ -231,12 +228,24 @@ HELPDESK_ENABLE_PER_QUEUE_STAFF_PERMISSION = getattr(
HELPDESK_USE_HTTPS_IN_EMAIL_LINK = getattr( HELPDESK_USE_HTTPS_IN_EMAIL_LINK = getattr(
settings, 'HELPDESK_USE_HTTPS_IN_EMAIL_LINK', settings.SECURE_SSL_REDIRECT) settings, 'HELPDESK_USE_HTTPS_IN_EMAIL_LINK', settings.SECURE_SSL_REDIRECT)
HELPDESK_TEAMS_MODEL = getattr( # Default to True for backwards compatibility
settings, 'HELPDESK_TEAMS_MODEL', 'pinax_teams.Team') HELPDESK_TEAMS_MODE_ENABLED = False if hasattr(settings, 'HELPDESK_TEAMS_MODE_ENABLED') and getattr(
HELPDESK_TEAMS_MIGRATION_DEPENDENCIES = getattr(settings, 'HELPDESK_TEAMS_MIGRATION_DEPENDENCIES', [ settings, 'HELPDESK_TEAMS_MODE_ENABLED', True) is False else True
if HELPDESK_TEAMS_MODE_ENABLED:
HELPDESK_TEAMS_MODEL = getattr(
settings, 'HELPDESK_TEAMS_MODEL', 'pinax_teams.Team')
HELPDESK_TEAMS_MIGRATION_DEPENDENCIES = getattr(settings, 'HELPDESK_TEAMS_MIGRATION_DEPENDENCIES', [
('pinax_teams', '0004_auto_20170511_0856')]) ('pinax_teams', '0004_auto_20170511_0856')])
HELPDESK_KBITEM_TEAM_GETTER = getattr( HELPDESK_KBITEM_TEAM_GETTER = getattr(
settings, 'HELPDESK_KBITEM_TEAM_GETTER', lambda kbitem: kbitem.team) settings, 'HELPDESK_KBITEM_TEAM_GETTER', lambda kbitem: kbitem.team)
else:
HELPDESK_TEAMS_MODEL = settings.AUTH_USER_MODEL
HELPDESK_TEAMS_MIGRATION_DEPENDENCIES = []
HELPDESK_KBITEM_TEAM_GETTER = lambda _: None
# show knowledgebase links?
# If Teams mode is enabled then it has to be on
HELPDESK_KB_ENABLED = True if HELPDESK_TEAMS_MODE_ENABLED else getattr(settings, 'HELPDESK_KB_ENABLED', True)
# Include all signatures and forwards in the first ticket message if set # Include all signatures and forwards in the first ticket message if set
# Useful if you get forwards dropped from them while they are useful part # Useful if you get forwards dropped from them while they are useful part