From f394beb2ef180f9fe64b3c72fd415712b369914e Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sun, 29 Jan 2023 07:22:54 -0800 Subject: [PATCH] config: Fix showing the value of the default home page Closes: #2314. Tests: - On a fresh testing container, verify that the file /etc/apache2/conf-available/freedombox-apache-homepage.conf is not present. Visit the config app and notice that home page shows as 'Apache Default'. - Apply the patch and refresh the page. The page now shows 'FreedomBox Service (Plinth)' as the home page. - Functional tests work. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/config/__init__.py | 6 ++++++ plinth/modules/config/tests/test_config.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plinth/modules/config/__init__.py b/plinth/modules/config/__init__.py index b3ee55574..c2ebd046a 100644 --- a/plinth/modules/config/__init__.py +++ b/plinth/modules/config/__init__.py @@ -105,6 +105,12 @@ def get_hostname(): def home_page_url2scid(url): """Return the shortcut ID of the given home page url.""" + # url is None when the freedombox-apache-homepage configuration file does + # not exist. In this case, the default redirect in /plinth from the shipped + # configuration file is effective. + if url is None: + return 'plinth' + if url in ('/plinth/', '/plinth', 'plinth'): return 'plinth' diff --git a/plinth/modules/config/tests/test_config.py b/plinth/modules/config/tests/test_config.py index 265512e25..d03adc412 100644 --- a/plinth/modules/config/tests/test_config.py +++ b/plinth/modules/config/tests/test_config.py @@ -76,7 +76,7 @@ def test_domainname_field(): def test_homepage_mapping(): """Basic tests for homepage functions.""" func = home_page_url2scid - assert func(None) is None + assert func(None) == 'plinth' assert func('/unknown/url') is None assert func('/plinth/') == 'plinth' assert func('/plinth') == 'plinth'