forked from shaba/openuds
Fixed a little bug on form creation
This commit is contained in:
parent
55ce029b68
commit
41fba86f93
@ -44,14 +44,14 @@ logger = logging.getLogger(__name__)
|
||||
class CustomSelect(forms.Select):
|
||||
def render(self, name, value, attrs=None):
|
||||
if len(self.choices) < 2:
|
||||
visible = 'style="display: none;"'
|
||||
visible = ' style="display: none;"'
|
||||
else:
|
||||
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'))
|
||||
for choice in self.choices:
|
||||
res += '<option value="{0}">{1}</option>'.format(choice[0], choice[1])
|
||||
res += '</select>'
|
||||
return mark_safe('<div class="form-group"{0}><label>'.format(visible) + unicode(_('authenticator')) + '</label>' + res + '</div>')
|
||||
return mark_safe('<div class="form-group"{0}><label>'.format(visible) + unicode(_('authenticator')) + '</label>' + res + '</div>')
|
||||
|
||||
class BaseForm(forms.Form):
|
||||
|
||||
@ -68,10 +68,10 @@ class BaseForm(forms.Form):
|
||||
class LoginForm(BaseForm):
|
||||
user = forms.CharField(label=_('Username'), max_length=64, widget=forms.TextInput())
|
||||
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput(attrs={'title': _('Password')}), required=False)
|
||||
authenticator = forms.ChoiceField(label=_('Authenticator'), choices = (), widget=CustomSelect(), required=False)
|
||||
java = forms.CharField(widget = forms.HiddenInput())
|
||||
standard = forms.CharField(widget = forms.HiddenInput(), required=False)
|
||||
nonStandard = forms.CharField(widget = forms.HiddenInput(), required=False)
|
||||
authenticator = forms.ChoiceField(label=_('Authenticator'), choices=(), widget=CustomSelect(), required=False)
|
||||
java = forms.CharField(widget=forms.HiddenInput())
|
||||
standard = forms.CharField(widget=forms.HiddenInput(), required=False)
|
||||
nonStandard = forms.CharField(widget=forms.HiddenInput(), required=False)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
# 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:
|
||||
if a.getType() is None:
|
||||
continue
|
||||
choices.append( (a.id, a.name) )
|
||||
choices.append((a.id, a.name))
|
||||
if a.getType().isCustom():
|
||||
nonStandard.append(str(a.id))
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user