Fixed a little bug on form creation

This commit is contained in:
Adolfo Gómez
2014-03-07 06:35:45 +00:00
parent 55ce029b68
commit 41fba86f93

View File

@@ -44,7 +44,7 @@ logger = logging.getLogger(__name__)
class CustomSelect(forms.Select): class CustomSelect(forms.Select):
def render(self, name, value, attrs=None): def render(self, name, value, attrs=None):
if len(self.choices) < 2: if len(self.choices) < 2:
visible = 'style="display: none;"' visible = ' style="display: none;"'
else: else:
visible = ''; visible = '';
res = '<select id="id_{0}" name="{0}" class="selectpicker show-menu-arrow" data-header="{1}" data-size="8" data-width="100%" >'.format(name, ugettext('Select authenticator')) res = '<select id="id_{0}" name="{0}" class="selectpicker show-menu-arrow" data-header="{1}" data-size="8" data-width="100%" >'.format(name, ugettext('Select authenticator'))
@@ -68,10 +68,10 @@ class BaseForm(forms.Form):
class LoginForm(BaseForm): class LoginForm(BaseForm):
user = forms.CharField(label=_('Username'), max_length=64, widget=forms.TextInput()) user = forms.CharField(label=_('Username'), max_length=64, widget=forms.TextInput())
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput(attrs={'title': _('Password')}), required=False) password = forms.CharField(label=_('Password'), widget=forms.PasswordInput(attrs={'title': _('Password')}), required=False)
authenticator = forms.ChoiceField(label=_('Authenticator'), choices = (), widget=CustomSelect(), required=False) authenticator = forms.ChoiceField(label=_('Authenticator'), choices=(), widget=CustomSelect(), required=False)
java = forms.CharField(widget = forms.HiddenInput()) java = forms.CharField(widget=forms.HiddenInput())
standard = forms.CharField(widget = forms.HiddenInput(), required=False) standard = forms.CharField(widget=forms.HiddenInput(), required=False)
nonStandard = forms.CharField(widget = forms.HiddenInput(), required=False) nonStandard = forms.CharField(widget=forms.HiddenInput(), required=False)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
# If an specified login is passed in, retrieve it & remove it from kwargs dict # If an specified login is passed in, retrieve it & remove it from kwargs dict
@@ -99,7 +99,7 @@ class LoginForm(BaseForm):
for a in auths: for a in auths:
if a.getType() is None: if a.getType() is None:
continue continue
choices.append( (a.id, a.name) ) choices.append((a.id, a.name))
if a.getType().isCustom(): if a.getType().isCustom():
nonStandard.append(str(a.id)) nonStandard.append(str(a.id))
else: else: