diff options
author | Rob Crittenden <rcritten@redhat.com> | 2007-11-14 17:50:46 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2007-11-14 17:50:46 -0500 |
commit | 83dd42797e169faabe059502066c3f2ff11d1338 (patch) | |
tree | 9760bf2ea01ecbb7c50864a5ff7331e1f3ed0248 | |
parent | 3e715a04cf95de0add2c37d6cd5985c43de47dab (diff) | |
download | freeipa-83dd42797e169faabe059502066c3f2ff11d1338.tar.gz freeipa-83dd42797e169faabe059502066c3f2ff11d1338.tar.xz freeipa-83dd42797e169faabe059502066c3f2ff11d1338.zip |
Include multi-value fields on the Add Person page
Remove multi-valued cn from groups
-rw-r--r-- | ipa-server/ipa-gui/ipagui/forms/group.py | 1 | ||||
-rw-r--r-- | ipa-server/ipa-gui/ipagui/forms/user.py | 1 | ||||
-rw-r--r-- | ipa-server/ipa-gui/ipagui/subcontrollers/group.py | 14 | ||||
-rw-r--r-- | ipa-server/ipa-gui/ipagui/subcontrollers/user.py | 9 | ||||
-rw-r--r-- | ipa-server/ipa-gui/ipagui/templates/groupeditform.kid | 32 | ||||
-rw-r--r-- | ipa-server/ipa-gui/ipagui/templates/groupshow.kid | 26 | ||||
-rw-r--r-- | ipa-server/ipa-gui/ipagui/templates/usernewform.kid | 275 |
7 files changed, 241 insertions, 117 deletions
diff --git a/ipa-server/ipa-gui/ipagui/forms/group.py b/ipa-server/ipa-gui/ipagui/forms/group.py index f9ae5e5ea..670494bd6 100644 --- a/ipa-server/ipa-gui/ipagui/forms/group.py +++ b/ipa-server/ipa-gui/ipagui/forms/group.py @@ -4,7 +4,6 @@ from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm class GroupFields(): cn = widgets.TextField(name="cn", label="Name") - cns = ExpandingForm(name="cns", label="Common Names", fields=[cn]) gidnumber = widgets.TextField(name="gidnumber", label="GID") description = widgets.TextField(name="description", label="Description") diff --git a/ipa-server/ipa-gui/ipagui/forms/user.py b/ipa-server/ipa-gui/ipagui/forms/user.py index 7cc150eff..7d3d37193 100644 --- a/ipa-server/ipa-gui/ipagui/forms/user.py +++ b/ipa-server/ipa-gui/ipagui/forms/user.py @@ -74,6 +74,7 @@ class UserNewValidator(validators.Schema): userpassword_confirm = validators.String(not_empty=False) givenname = validators.String(not_empty=True) sn = validators.String(not_empty=True) + cn = validators.ForEach(validators.String(not_empty=True)) mail = validators.Email(not_empty=False) chained_validators = [ diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py index 0df2d3c8c..e9763bacd 100644 --- a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py +++ b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py @@ -90,9 +90,11 @@ class GroupController(IPAController): # on any error, we redirect to the _edit_ group page. # this code does data setup, similar to groupedit() # - if isinstance(kw['cn'], str): - kw['cn'] = [kw['cn']] - group = client.get_entry_by_cn(kw['cn'][0], group_fields) + if isinstance(kw['cn'], list): + cn0 = kw['cn'][0] + else: + cn0 = kw['cn'] + group = client.get_entry_by_cn(cn0, group_fields) group_dict = group.toDict() member_dicts = [] @@ -220,12 +222,6 @@ class GroupController(IPAController): self.restrict_post() client = self.get_ipaclient() - # Fix incoming multi-valued form fields - kw['cn'] = [] - for i in range(len(kw['cns'])): - kw['cn'].append(kw['cns'][i]['cn']) - del(kw['cns']) - if kw.get('submit') == 'Cancel Edit': turbogears.flash("Edit group cancelled") raise turbogears.redirect('/group/show', cn=kw.get('cn')[0]) diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py index bf77b113f..290ad25cb 100644 --- a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py +++ b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py @@ -117,6 +117,15 @@ class UserController(IPAController): raise turbogears.redirect('/user/list') tg_errors, kw = self.usercreatevalidate(**kw) + + # Fix incoming multi-valued fields we created for the form + kw = self.fix_incoming_fields(kw, 'cn', 'cns') + kw = self.fix_incoming_fields(kw, 'telephonenumber', 'telephonenumbers') + kw = self.fix_incoming_fields(kw, 'facsimiletelephonenumber', 'facsimiletelephonenumbers') + kw = self.fix_incoming_fields(kw, 'mobile', 'mobiles') + kw = self.fix_incoming_fields(kw, 'pager', 'pagers') + kw = self.fix_incoming_fields(kw, 'homephone', 'homephones') + if tg_errors: turbogears.flash("There were validation errors.<br/>" + "Please see the messages below for details.") diff --git a/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid b/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid index 865cdfcc3..e6e456789 100644 --- a/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid +++ b/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid @@ -68,35 +68,13 @@ from ipagui.helpers import ipahelper <table class="formtable" cellpadding="2" cellspacing="0" border="0"> <tr> <th> - <label class="fieldlabel" for="${group_fields.cns.field_id}" + <label class="fieldlabel" for="${group_fields.cn.field_id}" py:content="group_fields.cn.label" />: </th> - <td colspan="3"> - <table class="formtable" cellpadding="2" cellspacing="0" border="0" id="${group_fields.cns.field_id}"> - <tbody> - <?python repetition = 0 - cn_index = 0 - cn_error = tg.errors.get('cn') - ?> - <tr py:for="cn in value_for(group_fields.cn)" - id="${group_fields.cns.field_id}_${repetition}" - class="${group_fields.cns.field_class}"> - - <td py:for="field in group_fields.cns.fields"> - <span><input class="textfield" type="text" id="${group_fields.cns.field_id}_${repetition}_cn" name="cns-${repetition}.cn" value="${cn}"/></span> - <span py:if="cn_error and cn_error[cn_index]" class="fielderror" - py:content="tg.errors.get('cn')" /> - </td> - <?python cn_index = cn_index + 1 ?> - <td> - <a - href="javascript:ExpandingForm.removeItem('${group_fields.cns.field_id}_${repetition}')">Remove (-)</a> - </td> - <?python repetition = repetition + 1?> - </tr> - </tbody> - </table> - <a id="${group_fields.cns.field_id}_doclink" href="javascript:ExpandingForm.addItem('${group_fields.cns.field_id}');">Add ( + )</a> + <td> + <span py:replace="group_fields.cn.display(value_for(group_fields.cn))" /> + <span py:if="tg.errors.get('description')" class="fielderror" + py:content="tg.errors.get('description')" /> </td> </tr> diff --git a/ipa-server/ipa-gui/ipagui/templates/groupshow.kid b/ipa-server/ipa-gui/ipagui/templates/groupshow.kid index a58220344..b2f37bf52 100644 --- a/ipa-server/ipa-gui/ipagui/templates/groupshow.kid +++ b/ipa-server/ipa-gui/ipagui/templates/groupshow.kid @@ -7,7 +7,10 @@ </head> <body> <?python -edit_url = tg.url('/group/edit', cn=group.get('cn')[0]) +cn = group.get('cn') +if isinstance(cn, list): + cn = cn[0] +edit_url = tg.url('/group/edit', cn=cn) ?> <div id="details"> <h1>View Group</h1> @@ -23,21 +26,7 @@ edit_url = tg.url('/group/edit', cn=group.get('cn')[0]) <th> <label class="fieldlabel" py:content="fields.cn.label" />: </th> - <td> - <table cellpadding="2" cellspacing="0" border="0"> - <tbody> - <?python - index = 0 - values = group.get("cn") - if isinstance(values, str): - values = [values] - ?> - <tr py:for="index in range(len(values))"> - <td>${values[index]}</td> - </tr> - </tbody> - </table> - </td> + <td>${group.get("cn")}</td> </tr> <tr> @@ -66,7 +55,10 @@ edit_url = tg.url('/group/edit', cn=group.get('cn')[0]) member_type = "user" view_url = tg.url('/user/show', uid=member_uid) else: - member_cn = "%s" % member.get('cn')[0] + mem = member.get('cn') + if isinstance(mem, list): + mem = mem[0] + member_cn = "%s" % mem member_desc = "[group]" member_type = "group" view_url = tg.url('/group/show', cn=member_cn) diff --git a/ipa-server/ipa-gui/ipagui/templates/usernewform.kid b/ipa-server/ipa-gui/ipagui/templates/usernewform.kid index 82a90982d..51d1711e7 100644 --- a/ipa-server/ipa-gui/ipagui/templates/usernewform.kid +++ b/ipa-server/ipa-gui/ipagui/templates/usernewform.kid @@ -2,7 +2,7 @@ class="simpleroster"> <form action="${action}" name="${name}" method="${method}" class="tableform" onsubmit="preSubmit()"> - + <input type="submit" class="submitbutton" name="submit" value="Add Person"/> <?python @@ -53,7 +53,7 @@ from ipagui.helpers import ipahelper </script> <div py:for="field in hidden_fields" - py:replace="field.display(value_for(field), **params_for(field))" + py:replace="field.display(value_for(field), **params_for(field))" /> <h2 class="formsection">Identity Details</h2> @@ -109,7 +109,7 @@ from ipagui.helpers import ipahelper var uid = $('form_uid'); var mail = $('form_mail'); - var cn = $('form_cn'); + var cn = $('form_cns_0_cn'); var displayname = $('form_displayname'); var initials = $('form_initials'); @@ -166,14 +166,38 @@ from ipagui.helpers import ipahelper <tr> <th> - <label class="fieldlabel" for="${user_fields.cn.field_id}" - py:content="user_fields.cn.label" />: + <label class="fieldlabel" for="${user_fields.cns.field_id}" + py:content="user_fields.cns.label" />: </th> - <td> - <span py:replace="user_fields.cn.display(value_for(user_fields.cn))" /> - <span py:if="tg.errors.get('cn')" class="fielderror" - py:content="tg.errors.get('cn')" /> + <td colspan="3"> + <table class="formtable" cellpadding="2" cellspacing="0" border="0" id="${user_fields.cns.field_id}"> + <tbody> + <?python repetition = 0 + cn_index = 0 + cn_error = tg.errors.get('cn') + values = value_for(user_fields.cn) + if values is None: + values=[''] + ?> + <tr py:for="cn in values" + id="${user_fields.cns.field_id}_${repetition}" + class="${user_fields.cns.field_class}"> + <td py:for="field in user_fields.cns.fields"> + <span><input class="textfield" type="text" id="${user_fields.cns.field_id}_${repetition}_cn" name="cns-${repetition}.cn" value="${cn}"/></span> + <span py:if="cn_error and cn_error[cn_index]" class="fielderror" + py:content="tg.errors.get('cn')" /> + </td> + <?python cn_index = cn_index + 1 ?> + <td> + <a + href="javascript:ExpandingForm.removeItem('${user_fields.cns.field_id}_${repetition}')">Remove</a> + </td> + <?python repetition = repetition + 1?> + </tr> + </tbody> + </table> + <a id="${user_fields.cns.field_id}_doclink" href="javascript:ExpandingForm.addItem('${user_fields.cns.field_id}');">Add Common Name</a> </td> </tr> @@ -339,63 +363,188 @@ from ipagui.helpers import ipahelper <tr> <th> - <label class="fieldlabel" for="${user_fields.telephonenumber.field_id}" - py:content="user_fields.telephonenumber.label" />: - </th> - <td> - <span py:replace="user_fields.telephonenumber.display(value_for(user_fields.telephonenumber))" /> - <span py:if="tg.errors.get('telephonenumber')" class="fielderror" - py:content="tg.errors.get('telephonenumber')" /> - </td> - </tr> - - <tr> - <th> - <label class="fieldlabel" for="${user_fields.facsimiletelephonenumber.field_id}" - py:content="user_fields.facsimiletelephonenumber.label" />: - </th> - <td> - <span py:replace="user_fields.facsimiletelephonenumber.display(value_for(user_fields.facsimiletelephonenumber))" /> - <span py:if="tg.errors.get('facsimiletelephonenumber')" class="fielderror" - py:content="tg.errors.get('facsimiletelephonenumber')" /> + <label class="fieldlabel" for="${user_fields.telephonenumbers.field_id}" + py:content="user_fields.telephonenumbers.label" />: + </th> + <td colspan="3"> + <table class="formtable" cellpadding="2" cellspacing="0" border="0" id="${user_fields.telephonenumbers.field_id}"> + <tbody> + <?python repetition = 0 + tele_index = 0 + tele_error = tg.errors.get('telephonenumber') + values = value_for(user_fields.telephonenumber) + if values is None: + values=[''] + ?> + <tr py:for="tele in values" + id="${user_fields.telephonenumbers.field_id}_${repetition}" + class="${user_fields.telephonenumbers.field_class}"> + + <td py:if="user_fields.telephonenumbers.fields is not None" py:for="field in user_fields.telephonenumbers.fields"> + <span><input class="textfield" type="text" id="${user_fields.telephonenumbers.field_id}_${repetition}_telephonenumber" name="telephonenumbers-${repetition}.telephonenumber" value="${tele}"/></span> + <span py:if="tele_error and tele_error[tele_index]" class="fielderror" + py:content="tg.errors.get('telephonenumber')" /> + </td> + <?python tele_index = tele_index + 1 ?> + <td> + <a + href="javascript:ExpandingForm.removeItem('${user_fields.telephonenumbers.field_id}_${repetition}')">Remove</a> + </td> + <?python repetition = repetition + 1?> + </tr> + </tbody> + </table> + <a id="${user_fields.telephonenumbers.field_id}_doclink" href="javascript:ExpandingForm.addItem('${user_fields.telephonenumbers.field_id}');">Add Work Number</a> + </td> + </tr> + <tr> + <th> + <label class="fieldlabel" for="${user_fields.facsimiletelephonenumbers.field_id}" + py:content="user_fields.facsimiletelephonenumbers.label" />: + </th> + <td colspan="3"> + <table class="formtable" cellpadding="2" cellspacing="0" border="0" id="${user_fields.facsimiletelephonenumbers.field_id}"> + <tbody> + <?python repetition = 0 + fax_index = 0 + fax_error = tg.errors.get('facsimiletelephonenumber') + values = value_for(user_fields.facsimiletelephonenumber) + if values is None: + values=[''] + ?> + <tr py:for="fax in values" + id="${user_fields.facsimiletelephonenumbers.field_id}_${repetition}" + class="${user_fields.facsimiletelephonenumbers.field_class}"> + + <td py:for="field in user_fields.facsimiletelephonenumbers.fields"> + <span><input class="textfield" type="text" id="${user_fields.facsimiletelephonenumbers.field_id}_${repetition}_facsimiletelephonenumber" name="facsimiletelephonenumbers-${repetition}.facsimiletelephonenumber" value="${fax}"/></span> + <span py:if="fax_error and fax_error[fax_index]" class="fielderror" + py:content="tg.errors.get('facsimiletelephonenumber')" /> + </td> + <?python fax_index = fax_index + 1 ?> + <td> + <a + href="javascript:ExpandingForm.removeItem('${user_fields.facsimiletelephonenumbers.field_id}_${repetition}')">Remove</a> + </td> + <?python repetition = repetition + 1?> + </tr> + </tbody> + </table> + <a id="${user_fields.facsimiletelephonenumbers.field_id}_doclink" href="javascript:ExpandingForm.addItem('${user_fields.facsimiletelephonenumbers.field_id}');">Add Fax Number</a> + </td> + </tr> + + <tr> + <th> + <label class="fieldlabel" for="${user_fields.mobiles.field_id}" + py:content="user_fields.mobiles.label" />: + </th> + <td colspan="3"> + <table class="formtable" cellpadding="2" cellspacing="0" border="0" id="${user_fields.mobiles.field_id}"> + <tbody> + <?python repetition = 0 + mobile_index = 0 + mobile_error = tg.errors.get('mobile') + values = value_for(user_fields.mobile) + if values is None: + values=[''] + ?> + <tr py:for="mobile in values" + id="${user_fields.mobiles.field_id}_${repetition}" + class="${user_fields.mobiles.field_class}"> + + <td py:for="field in user_fields.mobiles.fields"> + <span><input class="textfield" type="text" id="${user_fields.mobiles.field_id}_${repetition}_mobile" name="mobiles-${repetition}.mobile" value="${mobile}"/></span> + <span py:if="mobile_error and mobile_error[mobile_index]" class="fielderror" + py:content="tg.errors.get('mobile')" /> + </td> + <?python mobile_index = mobile_index + 1 ?> + <td> + <a + href="javascript:ExpandingForm.removeItem('${user_fields.mobiles.field_id}_${repetition}')">Remove</a> + </td> + <?python repetition = repetition + 1?> + </tr> + </tbody> + </table> + <a id="${user_fields.mobiles.field_id}_doclink" href="javascript:ExpandingForm.addItem('${user_fields.mobiles.field_id}');">Add Cell Number</a> + </td> + </tr> + + <tr> + <th> + <label class="fieldlabel" for="${user_fields.pagers.field_id}" + py:content="user_fields.pagers.label" />: + </th> + <td colspan="3"> + <table class="formtable" cellpadding="2" cellspacing="0" border="0" id="${user_fields.pagers.field_id}"> + <tbody> + <?python repetition = 0 + pager_index = 0 + pager_error = tg.errors.get('pager') + values = value_for(user_fields.pager) + if values is None: + values=[''] + ?> + <tr py:for="pager in values" + id="${user_fields.pagers.field_id}_${repetition}" + class="${user_fields.pagers.field_class}"> + + <td py:for="field in user_fields.pagers.fields"> + <span><input class="textfield" type="text" id="${user_fields.pagers.field_id}_${repetition}_pager" name="pagers-${repetition}.pager" value="${pager}"/></span> + <span py:if="pager_error and pager_error[pager_index]" class="fielderror" + py:content="tg.errors.get('pager')" /> + </td> + <?python pager_index = pager_index + 1 ?> + <td> + <a + href="javascript:ExpandingForm.removeItem('${user_fields.pagers.field_id}_${repetition}')">Remove</a> + </td> + <?python repetition = repetition + 1?> + </tr> + </tbody> + </table> + <a id="${user_fields.pagers.field_id}_doclink" href="javascript:ExpandingForm.addItem('${user_fields.pagers.field_id}');">Add Pager Number</a> + </td> + </tr> + + <tr> + <th> + <label class="fieldlabel" for="${user_fields.homephones.field_id}" + py:content="user_fields.homephones.label" />: + </th> + <td colspan="3"> + <table class="formtable" cellpadding="2" cellspacing="0" border="0" id="${user_fields.homephones.field_id}"> + <tbody> + <?python repetition = 0 + homephone_index = 0 + homephone_error = tg.errors.get('homephone') + values = value_for(user_fields.homephone) + if values is None: + values=[''] + ?> + <tr py:for="homephone in values" + id="${user_fields.homephones.field_id}_${repetition}" + class="${user_fields.homephones.field_class}"> + + <td py:for="field in user_fields.homephones.fields"> + <span><input class="textfield" type="text" id="${user_fields.homephones.field_id}_${repetition}_homephone" name="homephones-${repetition}.homephone" value="${homephone}"/></span> + <span py:if="homephone_error and homephone_error[homephone_index]" class="fielderror" + py:content="tg.errors.get('homephone')" /> + </td> + <?python homephone_index = homephone_index + 1 ?> + <td> + <a + href="javascript:ExpandingForm.removeItem('${user_fields.homephones.field_id}_${repetition}')">Remove</a> + </td> + <?python repetition = repetition + 1?> + </tr> + </tbody> + </table> + <a id="${user_fields.homephones.field_id}_doclink" href="javascript:ExpandingForm.addItem('${user_fields.homephones.field_id}');">Add Home Phone</a> </td> </tr> - <tr> - <th> - <label class="fieldlabel" for="${user_fields.mobile.field_id}" - py:content="user_fields.mobile.label" />: - </th> - <td> - <span py:replace="user_fields.mobile.display(value_for(user_fields.mobile))" /> - <span py:if="tg.errors.get('mobile')" class="fielderror" - py:content="tg.errors.get('mobile')" /> - </td> - </tr> - - <tr> - <th> - <label class="fieldlabel" for="${user_fields.pager.field_id}" - py:content="user_fields.pager.label" />: - </th> - <td> - <span py:replace="user_fields.pager.display(value_for(user_fields.pager))" /> - <span py:if="tg.errors.get('pager')" class="fielderror" - py:content="tg.errors.get('pager')" /> - </td> - </tr> - - <tr> - <th> - <label class="fieldlabel" for="${user_fields.homephone.field_id}" - py:content="user_fields.homephone.label" />: - </th> - <td> - <span py:replace="user_fields.homephone.display(value_for(user_fields.homephone))" /> - <span py:if="tg.errors.get('homephone')" class="fielderror" - py:content="tg.errors.get('homephone')" /> - </td> - </tr> </table> <h2 class="formsection">Mailing Address</h2> |