mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
forms: Allow showing a None option during domain selection
- To be used to show that no domain is initially selected in Home Assistant. And also to release a domain from dedicated use. Tests: - Install Matrix Synapse app in unstable VM. After install the setup form does not show None as an option. Selecting a domain works as expected. Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
927e1dc822
commit
2fdbe9948d
@ -51,12 +51,18 @@ class UninstallForm(forms.Form):
|
|||||||
class DomainSelectionForm(forms.Form):
|
class DomainSelectionForm(forms.Form):
|
||||||
"""Form for selecting a domain name."""
|
"""Form for selecting a domain name."""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, show_none=False, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
from plinth.modules.names.components import DomainName
|
from plinth.modules.names.components import DomainName
|
||||||
domains = list(DomainName.list_names())
|
domains = list(DomainName.list_names())
|
||||||
self.fields['domain_name'].choices = zip(domains, domains)
|
|
||||||
|
choices = list(zip(domains, domains))
|
||||||
|
if show_none:
|
||||||
|
choices = [('', _('(None)'))] + choices
|
||||||
|
self.fields['domain_name'].required = False
|
||||||
|
|
||||||
|
self.fields['domain_name'].choices = choices
|
||||||
|
|
||||||
domain_name = forms.ChoiceField(
|
domain_name = forms.ChoiceField(
|
||||||
label=_('Select a domain name to be used with this application'))
|
label=_('Select a domain name to be used with this application'))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user