Show More
@@ -68,10 +68,11 class LdapSettingsController(BaseControl | |||||
68 | """POST ldap create and store ldap settings""" |
|
68 | """POST ldap create and store ldap settings""" | |
69 |
|
69 | |||
70 | settings_model = SettingsModel() |
|
70 | settings_model = SettingsModel() | |
71 | _form = LdapSettingsForm()() |
|
71 | post_data = dict(request.POST) | |
|
72 | _form = LdapSettingsForm(post_data.get('ldap_active'))() | |||
72 |
|
73 | |||
73 | try: |
|
74 | try: | |
74 |
form_result = _form.to_python( |
|
75 | form_result = _form.to_python(post_data) | |
75 | try: |
|
76 | try: | |
76 |
|
77 | |||
77 | for k, v in form_result.items(): |
|
78 | for k, v in form_result.items(): |
@@ -300,10 +300,13 class LdapLibValidator(formencode.valida | |||||
300 | raise LdapImportError |
|
300 | raise LdapImportError | |
301 | return value |
|
301 | return value | |
302 |
|
302 | |||
303 | class BaseDnValidator(formencode.validators.FancyValidator): |
|
303 | def BaseDnValidator(ldap_enable): | |
|
304 | class _BaseDnValidator(formencode.validators.FancyValidator): | |||
304 |
|
305 | |||
305 | def to_python(self, value, state): |
|
306 | def to_python(self, value, state): | |
306 |
|
307 | |||
|
308 | if not ldap_enable: | |||
|
309 | return '' | |||
307 | try: |
|
310 | try: | |
308 | value % {'user':'valid'} |
|
311 | value % {'user':'valid'} | |
309 |
|
312 | |||
@@ -319,7 +322,7 class BaseDnValidator(formencode.validat | |||||
319 | value, state) |
|
322 | value, state) | |
320 |
|
323 | |||
321 | return value |
|
324 | return value | |
322 |
|
325 | return _BaseDnValidator | ||
323 | #=============================================================================== |
|
326 | #=============================================================================== | |
324 | # FORMS |
|
327 | # FORMS | |
325 | #=============================================================================== |
|
328 | #=============================================================================== | |
@@ -467,7 +470,7 def DefaultPermissionsForm(perms_choices | |||||
467 | return _DefaultPermissionsForm |
|
470 | return _DefaultPermissionsForm | |
468 |
|
471 | |||
469 |
|
472 | |||
470 | def LdapSettingsForm(): |
|
473 | def LdapSettingsForm(ldap_enable): | |
471 | class _LdapSettingsForm(formencode.Schema): |
|
474 | class _LdapSettingsForm(formencode.Schema): | |
472 | allow_extra_fields = True |
|
475 | allow_extra_fields = True | |
473 | filter_extra_fields = True |
|
476 | filter_extra_fields = True | |
@@ -478,6 +481,6 def LdapSettingsForm(): | |||||
478 | ldap_ldaps = StringBoolean(if_missing=False) |
|
481 | ldap_ldaps = StringBoolean(if_missing=False) | |
479 | ldap_dn_user = UnicodeString(strip=True,) |
|
482 | ldap_dn_user = UnicodeString(strip=True,) | |
480 | ldap_dn_pass = UnicodeString(strip=True,) |
|
483 | ldap_dn_pass = UnicodeString(strip=True,) | |
481 | ldap_base_dn = All(BaseDnValidator, UnicodeString(strip=True,)) |
|
484 | ldap_base_dn = All(BaseDnValidator(ldap_enable), UnicodeString(strip=True,)) | |
482 |
|
485 | |||
483 | return _LdapSettingsForm |
|
486 | return _LdapSettingsForm |
General Comments 0
You need to be logged in to leave comments.
Login now