diff options
author | Kevin McCarthy <kmccarth@redhat.com> | 2007-10-24 16:04:17 -0700 |
---|---|---|
committer | Kevin McCarthy <kmccarth@redhat.com> | 2007-10-24 16:04:17 -0700 |
commit | 358d279a53138220121379be2df546cc9ee82ae1 (patch) | |
tree | ab3fa58e9a395fa4659091d1bdf274a1b7f4c0c8 /ipa-server | |
parent | 6e6237e54a1f7a07478ec7c592ea08f71e1b18ce (diff) | |
download | freeipa-358d279a53138220121379be2df546cc9ee82ae1.tar.gz freeipa-358d279a53138220121379be2df546cc9ee82ae1.tar.xz freeipa-358d279a53138220121379be2df546cc9ee82ae1.zip |
webgui side of custom fields.
Diffstat (limited to 'ipa-server')
-rw-r--r-- | ipa-server/ipa-gui/ipagui/forms/user.py | 10 | ||||
-rw-r--r-- | ipa-server/ipa-gui/ipagui/subcontrollers/user.py | 39 | ||||
-rw-r--r-- | ipa-server/ipa-gui/ipagui/templates/usereditform.kid | 17 | ||||
-rw-r--r-- | ipa-server/ipa-gui/ipagui/templates/usernewform.kid | 17 | ||||
-rw-r--r-- | ipa-server/ipa-gui/ipagui/templates/usershow.kid | 15 |
5 files changed, 96 insertions, 2 deletions
diff --git a/ipa-server/ipa-gui/ipagui/forms/user.py b/ipa-server/ipa-gui/ipagui/forms/user.py index 73261cd9e..964067f4f 100644 --- a/ipa-server/ipa-gui/ipagui/forms/user.py +++ b/ipa-server/ipa-gui/ipagui/forms/user.py @@ -59,6 +59,8 @@ class UserFields(): user_groups_data = widgets.HiddenField(name="user_groups_data") dn_to_info_json = widgets.HiddenField(name="dn_to_info_json") + custom_fields = [] + class UserNewValidator(validators.Schema): uid = validators.PlainText(not_empty=True) userpassword = validators.String(not_empty=False) @@ -73,7 +75,7 @@ class UserNewValidator(validators.Schema): class UserNewForm(widgets.Form): - params = ['user'] + params = ['user', 'custom_fields'] hidden_fields = [ UserFields.dn_to_info_json, @@ -83,6 +85,8 @@ class UserNewForm(widgets.Form): UserFields.secretary_cn, ] + custom_fields = [] + validator = UserNewValidator() def __init__(self, *args, **kw): @@ -112,7 +116,7 @@ class UserEditValidator(validators.Schema): ] class UserEditForm(widgets.Form): - params = ['user'] + params = ['user', 'custom_fields'] hidden_fields = [ UserFields.uid_hidden, UserFields.user_orig, @@ -126,6 +130,8 @@ class UserEditForm(widgets.Form): UserFields.secretary_cn, ] + custom_fields = [] + validator = UserEditValidator() def __init__(self, *args, **kw): diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py index a5f99ef05..794cfaefb 100644 --- a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py +++ b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py @@ -32,6 +32,36 @@ email_domain = ipa.config.config.default_realm.lower() class UserController(IPAController): + def __init__(self, *args, **kw): + super(UserController,self).__init__(*args, **kw) + self.load_custom_fields() + + def load_custom_fields(self): + # client = self.get_ipaclient() + # schema = client.get_user_custom_schema() + schema = [ + { 'label': 'See Also', + 'field': 'seeAlso', + 'required': 'true', } , + { 'label': 'O O O', + 'field': 'o', + 'required': 'false', } , + ] + for s in schema: + required=False + if (s['required'] == "true"): + required=True + field = widgets.TextField(name=s['field'],label=s['label']) + validator = validators.String(not_empty=required) + + ipagui.forms.user.UserFields.custom_fields.append(field) + user_new_form.custom_fields.append(field) + user_edit_form.custom_fields.append(field) + + user_new_form.validator.add_field(s['field'], validator) + user_edit_form.validator.add_field(s['field'], validator) + + @expose() def index(self): raise turbogears.redirect("/user/list") @@ -107,6 +137,10 @@ class UserController(IPAController): if kw.get('nsAccountLock'): new_user.setValue('nsAccountLock', 'true') + for custom_field in user_new_form.custom_fields: + new_user.setValue(custom_field.name, + kw.get(custom_field.name, '')) + rv = client.add_user(new_user) except ipaerror.exception_for(ipaerror.LDAP_DUPLICATE): turbogears.flash("Person with login '%s' already exists" % @@ -320,6 +354,7 @@ class UserController(IPAController): new_user.setValue('nsAccountLock', 'true') else: new_user.setValue('nsAccountLock', None) + if kw.get('editprotected') == 'true': if kw.get('userpassword'): password_change = True @@ -327,6 +362,10 @@ class UserController(IPAController): new_user.setValue('gidnumber', str(kw.get('gidnumber'))) new_user.setValue('homedirectory', str(kw.get('homedirectory'))) + for custom_field in user_edit_form.custom_fields: + new_user.setValue(custom_field.name, + kw.get(custom_field.name, '')) + rv = client.update_user(new_user) # # If the user update succeeds, but below operations fail, we diff --git a/ipa-server/ipa-gui/ipagui/templates/usereditform.kid b/ipa-server/ipa-gui/ipagui/templates/usereditform.kid index 4f23e5bea..20edbced9 100644 --- a/ipa-server/ipa-gui/ipagui/templates/usereditform.kid +++ b/ipa-server/ipa-gui/ipagui/templates/usereditform.kid @@ -613,6 +613,23 @@ from ipagui.helpers import ipahelper </tr> </table> + <div py:if='len(custom_fields) > 0'> + <div class="formsection" >Custom Fields</div> + <table class="formtable" cellpadding="2" cellspacing="0" border="0"> + <tr py:for='custom_field in custom_fields'> + <th> + <label class="fieldlabel" for="${custom_field.field_id}" + py:content="custom_field.label" />: + </th> + <td> + <span py:replace="custom_field.display(value_for(custom_field))" /> + <span py:if="tg.errors.get(custom_field.name)" class="fielderror" + py:content="tg.errors.get(custom_field.name)" /> + </td> + </tr> + </table> + </div> + <div> <div class="formsection">Groups</div> diff --git a/ipa-server/ipa-gui/ipagui/templates/usernewform.kid b/ipa-server/ipa-gui/ipagui/templates/usernewform.kid index a958c1717..44314457e 100644 --- a/ipa-server/ipa-gui/ipagui/templates/usernewform.kid +++ b/ipa-server/ipa-gui/ipagui/templates/usernewform.kid @@ -601,6 +601,23 @@ from ipagui.helpers import ipahelper </tr> </table> + <div py:if='len(custom_fields) > 0'> + <div class="formsection" >Custom Fields</div> + <table class="formtable" cellpadding="2" cellspacing="0" border="0"> + <tr py:for='custom_field in custom_fields'> + <th> + <label class="fieldlabel" for="${custom_field.field_id}" + py:content="custom_field.label" />: + </th> + <td> + <span py:replace="custom_field.display(value_for(custom_field))" /> + <span py:if="tg.errors.get(custom_field.name)" class="fielderror" + py:content="tg.errors.get(custom_field.name)" /> + </td> + </tr> + </table> + </div> + <div style="clear:both"> <div class="formsection">Add Groups</div> diff --git a/ipa-server/ipa-gui/ipagui/templates/usershow.kid b/ipa-server/ipa-gui/ipagui/templates/usershow.kid index 81a75763f..c1e40a1b3 100644 --- a/ipa-server/ipa-gui/ipagui/templates/usershow.kid +++ b/ipa-server/ipa-gui/ipagui/templates/usershow.kid @@ -259,6 +259,21 @@ else: </tr> </table> + <div py:if='len(fields.custom_fields) > 0'> + <div class="formsection" >Custom Fields</div> + <table class="formtable" cellpadding="2" cellspacing="0" border="0"> + <tr py:for='custom_field in fields.custom_fields'> + <th> + <label class="fieldlabel" for="${custom_field.field_id}" + py:content="custom_field.label" />: + </th> + <td> + ${user.get(custom_field.name)} + </td> + </tr> + </table> + </div> + <div class="formsection" py:if='len(user_reports) > 0'>Direct Reports</div> <ol py:if="len(user_reports) > 0"> <li py:for="report in user_reports"> |