diff --git a/lizmap_server/get_legend_graphic.py b/lizmap_server/get_legend_graphic.py index 5ecde19a..6a6e75c6 100644 --- a/lizmap_server/get_legend_graphic.py +++ b/lizmap_server/get_legend_graphic.py @@ -83,7 +83,7 @@ def responseComplete(self): if not style: style = params.get('STYLE', '') - show_feature_count = to_bool(params.get('SHOWFEATURECOUNT'), default_value=False) + show_feature_count = to_bool(params.get('SHOWFEATURECOUNT')) current_style = '' layer = find_layer(layer_name, project) diff --git a/lizmap_server/plausible.py b/lizmap_server/plausible.py index 6e0c00eb..7eac34d4 100644 --- a/lizmap_server/plausible.py +++ b/lizmap_server/plausible.py @@ -39,11 +39,11 @@ def __init__(self): def request_stat_event(self) -> bool: """ Request to send an event to the API. """ - if to_bool(os.getenv(ENV_SKIP_STATS), default_value=False): + if to_bool(os.getenv(ENV_SKIP_STATS)): # Disabled by environment variable return False - if to_bool(os.getenv("CI"), default_value=False): + if to_bool(os.getenv("CI")): # If running on CI, do not send stats return False diff --git a/lizmap_server/tools.py b/lizmap_server/tools.py index 5a647415..7b3d2b5f 100755 --- a/lizmap_server/tools.py +++ b/lizmap_server/tools.py @@ -15,16 +15,13 @@ """ -def to_bool(val: Union[str, int, float, bool], default_value: bool = True) -> bool: +def to_bool(val: Union[str, int, float, bool, None]) -> bool: """ Convert lizmap config value to boolean """ if isinstance(val, str): # For string, compare lower value to True string return val.lower() in ('yes', 'true', 't', '1') - elif not val: - # For value like False, 0, 0.0, None, empty list or dict returns False - return False else: - return default_value + return bool(val) def version() -> str: @@ -49,7 +46,7 @@ def version() -> str: def check_environment_variable() -> bool: """ Check the server configuration. """ - if not to_bool(os.environ.get('QGIS_SERVER_LIZMAP_REVEAL_SETTINGS', ''), default_value=False): + if not to_bool(os.environ.get('QGIS_SERVER_LIZMAP_REVEAL_SETTINGS', '')): QgsMessageLog.logMessage( 'The Lizmap API is currently not enabled. Please read the documentation how to enable the Lizmap API ' 'on QGIS server side '