Skip to content

Commit

Permalink
Merge branch 'update-settings-csv-parsing' into 'main'
Browse files Browse the repository at this point in the history
Update CSV setting parsing

See merge request reportcreator/reportcreator!779
MWedl committed Nov 27, 2024
2 parents 504bc05 + 362a6af commit 61a302c
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
@@ -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

14 changes: 9 additions & 5 deletions api/src/reportcreator_api/conf/settings.py
Original file line number Diff line number Diff line change
@@ -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)
@@ -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]

@@ -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
@@ -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)


0 comments on commit 61a302c

Please sign in to comment.