summaryrefslogtreecommitdiffstats
path: root/ipa-server
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2007-11-14 23:33:49 -0500
committerRob Crittenden <rcritten@redhat.com>2007-11-14 23:33:49 -0500
commitcb0476f223a39234eda5c48e7482b2996ca7d49d (patch)
tree81cf3c6ec2d3ca56784c7e37a182684af2554939 /ipa-server
parent83dd42797e169faabe059502066c3f2ff11d1338 (diff)
downloadfreeipa-cb0476f223a39234eda5c48e7482b2996ca7d49d.tar.gz
freeipa-cb0476f223a39234eda5c48e7482b2996ca7d49d.tar.xz
freeipa-cb0476f223a39234eda5c48e7482b2996ca7d49d.zip
Make the group cn an editable field though protected by default.
Fix some issues with the multi-value to single-value reversion.
Diffstat (limited to 'ipa-server')
-rw-r--r--ipa-server/ipa-gui/ipagui/forms/group.py5
-rw-r--r--ipa-server/ipa-gui/ipagui/subcontrollers/group.py36
-rw-r--r--ipa-server/ipa-gui/ipagui/templates/groupeditform.kid11
3 files changed, 26 insertions, 26 deletions
diff --git a/ipa-server/ipa-gui/ipagui/forms/group.py b/ipa-server/ipa-gui/ipagui/forms/group.py
index 670494bd6..04c0298ad 100644
--- a/ipa-server/ipa-gui/ipagui/forms/group.py
+++ b/ipa-server/ipa-gui/ipagui/forms/group.py
@@ -7,7 +7,6 @@ class GroupFields():
gidnumber = widgets.TextField(name="gidnumber", label="GID")
description = widgets.TextField(name="description", label="Description")
- cn_hidden = widgets.HiddenField(name="cn")
editprotected_hidden = widgets.HiddenField(name="editprotected")
group_orig = widgets.HiddenField(name="group_orig")
@@ -38,7 +37,7 @@ class GroupNewForm(widgets.Form):
class GroupEditValidator(validators.Schema):
- cn = validators.ForEach(validators.String(not_empty=True))
+ cn = validators.String(not_empty=True)
gidnumber = validators.Int(not_empty=False)
description = validators.String(not_empty=False)
@@ -50,7 +49,7 @@ class GroupEditForm(widgets.Form):
params = ['members', 'group_fields']
hidden_fields = [
- GroupFields.cn_hidden, GroupFields.editprotected_hidden,
+ GroupFields.editprotected_hidden,
GroupFields.group_orig, GroupFields.member_data,
GroupFields.dn_to_info_json
]
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
index e9763bacd..7c05eebc0 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
@@ -184,14 +184,6 @@ class GroupController(IPAController):
group_dict = group.toDict()
- # Load potential multi-valued fields
- if isinstance(group_dict['cn'], str):
- group_dict['cn'] = [group_dict['cn']]
- cns = []
- for cn in group_dict['cn']:
- cns.append(dict(cn=cn))
- group_dict['cns'] = cns
-
#
# convert members to users, for easier manipulation on the page
#
@@ -223,8 +215,14 @@ class GroupController(IPAController):
client = self.get_ipaclient()
if kw.get('submit') == 'Cancel Edit':
+ orig_group_dict = loads(b64decode(kw.get('group_orig')))
+ # if cancelling need to use the original group because the one
+ # in kw may not exist yet.
+ cn = orig_group_dict.get('cn')
+ if (isinstance(cn,str)):
+ cn = [cn]
turbogears.flash("Edit group cancelled")
- raise turbogears.redirect('/group/show', cn=kw.get('cn')[0])
+ raise turbogears.redirect('/group/show', cn=cn[0])
# Decode the member data, in case we need to round trip
member_dicts = loads(b64decode(kw.get('member_data')))
@@ -244,9 +242,6 @@ class GroupController(IPAController):
try:
orig_group_dict = loads(b64decode(kw.get('group_orig')))
- # remove multi-valued form fields
- del(orig_group_dict['cns'])
-
new_group = ipa.group.Group(orig_group_dict)
if new_group.description != kw.get('description'):
group_modified = True
@@ -256,12 +251,7 @@ class GroupController(IPAController):
if new_group.gidnumber != new_gid:
group_modified = True
new_group.setValue('gidnumber', new_gid)
-
- # Did any cn entries change?
- oldcn = new_group.getValues('cn')
- if isinstance(oldcn, str):
- oldcn = [oldcn]
- if oldcn != kw['cn']:
+ if new_group.cn != kw.get('cn'):
group_modified = True
new_group.setValue('cn', kw['cn'])
@@ -332,11 +322,15 @@ class GroupController(IPAController):
return dict(form=group_edit_form, group=kw, members=member_dicts,
tg_template='ipagui.templates.groupedit')
+ if isinstance(kw['cn'], list):
+ cn0 = kw['cn'][0]
+ else:
+ cn0 = kw['cn']
if group_modified == True:
- turbogears.flash("%s updated!" % kw['cn'][0])
+ turbogears.flash("%s updated!" % cn0)
else:
turbogears.flash("No modifications requested.")
- raise turbogears.redirect('/group/show', cn=kw['cn'][0])
+ raise turbogears.redirect('/group/show', cn=cn0)
@expose("ipagui.templates.grouplist")
@@ -385,7 +379,7 @@ class GroupController(IPAController):
return dict(group=group_dict, fields=ipagui.forms.group.GroupFields(),
members = member_dicts)
except ipaerror.IPAError, e:
- turbogears.flash("Group show failed: " + str(e) + "<br/>" + e.detail[0]['desc'])
+ turbogears.flash("Group show failed: " + str(e))
raise turbogears.redirect("/")
@expose()
diff --git a/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid b/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid
index e6e456789..d46bc731e 100644
--- a/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid
@@ -33,11 +33,14 @@ from ipagui.helpers import ipahelper
<script type="text/javascript">
function toggleProtectedFields(checkbox) {
var gidnumberField = $('form_gidnumber');
+ var cnField = $('form_cn');
if (checkbox.checked) {
gidnumberField.disabled = false;
+ cnField.disabled = false;
$('form_editprotected').value = 'true';
} else {
gidnumberField.disabled = true;
+ cnField.disabled = true;
$('form_editprotected').value = '';
}
}
@@ -73,8 +76,8 @@ from ipagui.helpers import ipahelper
</th>
<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')" />
+ <span py:if="tg.errors.get('cn')" class="fielderror"
+ py:content="tg.errors.get('cn')" />
</td>
</tr>
@@ -88,6 +91,9 @@ from ipagui.helpers import ipahelper
<span py:if="tg.errors.get('description')" class="fielderror"
py:content="tg.errors.get('description')" />
+ <script type="text/javascript">
+ document.getElementById('form_cn').disabled = true;
+ </script>
</td>
</tr>
@@ -160,6 +166,7 @@ from ipagui.helpers import ipahelper
div_counter = div_counter + 1
?>
</div>
+ &nbsp; <!-- a space here to prevent an empty div -->
</div>
</div>