mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
nextcloud: Add option to configure the default phone region
This setting is necessarry to pass the setup warning under /nextcloud/settings/admin/overview Note: during testing the field only becomes visible once the freedombox-develop command is restarted https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#default-phone-region Signed-off-by: Benedek Nagy <contact@nbenedek.me> [sunil: Add missing docstring] [sunil: Update form label for consistency] [sunil: Reduce number of success form messages] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
1 parent
8ef680f450
commit
b21af70510
4 files changed
+47
-2
No files matched your search
@@ -5,6 +5,17 @@ from django import forms
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
def _get_phone_regions():
|
||||
"""Return choice field choices for phone regions."""
|
||||
try:
|
||||
from iso3166 import countries # type: ignore
|
||||
phone_regions = [(country.alpha2, country.name)
|
||||
for country in countries]
|
||||
return sorted(phone_regions)
|
||||
except ImportError:
|
||||
return [('US', 'United States of America')]
|
||||
|
||||
|
||||
class NextcloudForm(forms.Form):
|
||||
"""Nextcloud configuration form."""
|
||||
|
||||
@@ -19,3 +30,9 @@ class NextcloudForm(forms.Form):
|
||||
'and the minimum required length is <strong>10 characters'
|
||||
'</strong>. Leave this field blank to keep the current password.'),
|
||||
required=False, widget=forms.PasswordInput, min_length=10)
|
||||
|
||||
default_phone_region = forms.ChoiceField(
|
||||
label=_('Default phone region'), required=False,
|
||||
help_text=_('The default phone region is required to validate phone '
|
||||
'numbers in the profile settings without a country code.'),
|
||||
choices=_get_phone_regions)
|
||||
Reference in new issue
Block a user