Skip to content

Commit

Permalink
Update CSV setting parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
MWedl committed Nov 26, 2024
1 parent 58bb98f commit 362a6af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Upcoming
* Plugin: webhooks at certain events
* Plugin: automatically assign project numbers
* Run periodic tasks in background
* UI: fix line break in logo text on Firefox

Expand Down
14 changes: 9 additions & 5 deletions api/src/reportcreator_api/conf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

from reportcreator_api.conf.plugins import load_plugins


def remove_empty_items(lst=None):
return list(filter(None, lst or []))

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent.parent
MEDIA_ROOT = config('MEDIA_ROOT', default=BASE_DIR / 'data', cast=Path)
Expand Down Expand Up @@ -246,7 +250,7 @@


# Allowed Hosts
ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv(), default='*')
ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv(post_process=remove_empty_items), default='*')
if not MFA_FIDO2_RP_ID and len(ALLOWED_HOSTS) == 1 and '*' not in ALLOWED_HOSTS[0]:
MFA_FIDO2_RP_ID = ALLOWED_HOSTS[0]

Expand Down Expand Up @@ -669,7 +673,7 @@ def __bool__(self):

# Notifications
VERSION = config('VERSION', default='dev')
INSTANCE_TAGS = config('INSTANCE_TAGS', cast=Csv(delimiter=';'), default='on-premise')
INSTANCE_TAGS = config('INSTANCE_TAGS', cast=Csv(delimiter=';', post_process=remove_empty_items), default='on-premise')
NOTIFICATION_IMPORT_URL = config('NOTIFICATION_IMPORT_URL', default='https://cloud.sysreptor.com/api/v1/notifications/')

# License
Expand All @@ -688,12 +692,12 @@ def __bool__(self):


# Languages
PREFERRED_LANGUAGES = config('PREFERRED_LANGUAGES', cast=Csv(), default=None)
PREFERRED_LANGUAGES = config('PREFERRED_LANGUAGES', cast=Csv(post_process=remove_empty_items), default=None)


# Plugins
PLUGIN_DIRS = list(filter(None, config('PLUGIN_DIRS', cast=Csv(cast=Path), default='')))
ENABLED_PLUGINS = list(filter(None, config('ENABLED_PLUGINS', cast=Csv(), default='')))
PLUGIN_DIRS = config('PLUGIN_DIRS', cast=Csv(cast=Path, post_process=remove_empty_items), default='')
ENABLED_PLUGINS = config('ENABLED_PLUGINS', cast=Csv(post_process=remove_empty_items), default='')
INSTALLED_APPS += load_plugins(PLUGIN_DIRS, ENABLED_PLUGINS)


Expand Down

0 comments on commit 362a6af

Please sign in to comment.