From 722da5b0d545f30dbdd1fe3d6d8824dee7b02637 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 3 Apr 2024 19:21:13 -0700 Subject: [PATCH] nextcloud: Don't show incorrect phone region when it is not set Tests: - Install nextcloud and notice that the default phone region is 'Not set'. Select phone region, it sets properly. Set it to 'Not set' and that works too. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/nextcloud/forms.py | 7 +++++-- plinth/modules/nextcloud/views.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plinth/modules/nextcloud/forms.py b/plinth/modules/nextcloud/forms.py index 1d32ccaf3..731ac25ec 100644 --- a/plinth/modules/nextcloud/forms.py +++ b/plinth/modules/nextcloud/forms.py @@ -11,9 +11,12 @@ def _get_phone_regions(): from iso3166 import countries # type: ignore phone_regions = [(country.alpha2, country.name) for country in countries] - return sorted(phone_regions) + phone_regions = sorted(phone_regions) except ImportError: - return [('US', 'United States of America')] + # Allow users to set a non-empty value + phone_regions = [('US', 'United States of America')] + + return [('', _('Not set'))] + phone_regions class NextcloudForm(forms.Form): diff --git a/plinth/modules/nextcloud/views.py b/plinth/modules/nextcloud/views.py index 3eb01240d..92a1e21f6 100644 --- a/plinth/modules/nextcloud/views.py +++ b/plinth/modules/nextcloud/views.py @@ -25,7 +25,7 @@ class NextcloudAppView(AppView): initial = super().get_initial() initial.update({ 'domain': privileged.get_domain(), - 'default_phone_region': privileged.get_default_phone_region() + 'default_phone_region': privileged.get_default_phone_region() or '' }) return initial