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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2024-04-03 19:21:13 -07:00 committed by James Valleroy
parent 138cdd6e3f
commit 722da5b0d5
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 6 additions and 3 deletions

View File

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

View File

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