mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-30 10:47:08 -06:00
Make the group cn an editable field though protected by default.
Fix some issues with the multi-value to single-value reversion.
This commit is contained in:
parent
83dd42797e
commit
cb0476f223
@ -7,7 +7,6 @@ class GroupFields():
|
|||||||
gidnumber = widgets.TextField(name="gidnumber", label="GID")
|
gidnumber = widgets.TextField(name="gidnumber", label="GID")
|
||||||
description = widgets.TextField(name="description", label="Description")
|
description = widgets.TextField(name="description", label="Description")
|
||||||
|
|
||||||
cn_hidden = widgets.HiddenField(name="cn")
|
|
||||||
editprotected_hidden = widgets.HiddenField(name="editprotected")
|
editprotected_hidden = widgets.HiddenField(name="editprotected")
|
||||||
|
|
||||||
group_orig = widgets.HiddenField(name="group_orig")
|
group_orig = widgets.HiddenField(name="group_orig")
|
||||||
@ -38,7 +37,7 @@ class GroupNewForm(widgets.Form):
|
|||||||
|
|
||||||
|
|
||||||
class GroupEditValidator(validators.Schema):
|
class GroupEditValidator(validators.Schema):
|
||||||
cn = validators.ForEach(validators.String(not_empty=True))
|
cn = validators.String(not_empty=True)
|
||||||
gidnumber = validators.Int(not_empty=False)
|
gidnumber = validators.Int(not_empty=False)
|
||||||
description = validators.String(not_empty=False)
|
description = validators.String(not_empty=False)
|
||||||
|
|
||||||
@ -50,7 +49,7 @@ class GroupEditForm(widgets.Form):
|
|||||||
params = ['members', 'group_fields']
|
params = ['members', 'group_fields']
|
||||||
|
|
||||||
hidden_fields = [
|
hidden_fields = [
|
||||||
GroupFields.cn_hidden, GroupFields.editprotected_hidden,
|
GroupFields.editprotected_hidden,
|
||||||
GroupFields.group_orig, GroupFields.member_data,
|
GroupFields.group_orig, GroupFields.member_data,
|
||||||
GroupFields.dn_to_info_json
|
GroupFields.dn_to_info_json
|
||||||
]
|
]
|
||||||
|
@ -184,14 +184,6 @@ class GroupController(IPAController):
|
|||||||
|
|
||||||
group_dict = group.toDict()
|
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
|
# convert members to users, for easier manipulation on the page
|
||||||
#
|
#
|
||||||
@ -223,8 +215,14 @@ class GroupController(IPAController):
|
|||||||
client = self.get_ipaclient()
|
client = self.get_ipaclient()
|
||||||
|
|
||||||
if kw.get('submit') == 'Cancel Edit':
|
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")
|
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
|
# Decode the member data, in case we need to round trip
|
||||||
member_dicts = loads(b64decode(kw.get('member_data')))
|
member_dicts = loads(b64decode(kw.get('member_data')))
|
||||||
@ -244,9 +242,6 @@ class GroupController(IPAController):
|
|||||||
try:
|
try:
|
||||||
orig_group_dict = loads(b64decode(kw.get('group_orig')))
|
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)
|
new_group = ipa.group.Group(orig_group_dict)
|
||||||
if new_group.description != kw.get('description'):
|
if new_group.description != kw.get('description'):
|
||||||
group_modified = True
|
group_modified = True
|
||||||
@ -256,12 +251,7 @@ class GroupController(IPAController):
|
|||||||
if new_group.gidnumber != new_gid:
|
if new_group.gidnumber != new_gid:
|
||||||
group_modified = True
|
group_modified = True
|
||||||
new_group.setValue('gidnumber', new_gid)
|
new_group.setValue('gidnumber', new_gid)
|
||||||
|
if new_group.cn != kw.get('cn'):
|
||||||
# Did any cn entries change?
|
|
||||||
oldcn = new_group.getValues('cn')
|
|
||||||
if isinstance(oldcn, str):
|
|
||||||
oldcn = [oldcn]
|
|
||||||
if oldcn != kw['cn']:
|
|
||||||
group_modified = True
|
group_modified = True
|
||||||
new_group.setValue('cn', kw['cn'])
|
new_group.setValue('cn', kw['cn'])
|
||||||
|
|
||||||
@ -332,11 +322,15 @@ class GroupController(IPAController):
|
|||||||
return dict(form=group_edit_form, group=kw, members=member_dicts,
|
return dict(form=group_edit_form, group=kw, members=member_dicts,
|
||||||
tg_template='ipagui.templates.groupedit')
|
tg_template='ipagui.templates.groupedit')
|
||||||
|
|
||||||
|
if isinstance(kw['cn'], list):
|
||||||
|
cn0 = kw['cn'][0]
|
||||||
|
else:
|
||||||
|
cn0 = kw['cn']
|
||||||
if group_modified == True:
|
if group_modified == True:
|
||||||
turbogears.flash("%s updated!" % kw['cn'][0])
|
turbogears.flash("%s updated!" % cn0)
|
||||||
else:
|
else:
|
||||||
turbogears.flash("No modifications requested.")
|
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")
|
@expose("ipagui.templates.grouplist")
|
||||||
@ -385,7 +379,7 @@ class GroupController(IPAController):
|
|||||||
return dict(group=group_dict, fields=ipagui.forms.group.GroupFields(),
|
return dict(group=group_dict, fields=ipagui.forms.group.GroupFields(),
|
||||||
members = member_dicts)
|
members = member_dicts)
|
||||||
except ipaerror.IPAError, e:
|
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("/")
|
raise turbogears.redirect("/")
|
||||||
|
|
||||||
@expose()
|
@expose()
|
||||||
|
@ -33,11 +33,14 @@ from ipagui.helpers import ipahelper
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function toggleProtectedFields(checkbox) {
|
function toggleProtectedFields(checkbox) {
|
||||||
var gidnumberField = $('form_gidnumber');
|
var gidnumberField = $('form_gidnumber');
|
||||||
|
var cnField = $('form_cn');
|
||||||
if (checkbox.checked) {
|
if (checkbox.checked) {
|
||||||
gidnumberField.disabled = false;
|
gidnumberField.disabled = false;
|
||||||
|
cnField.disabled = false;
|
||||||
$('form_editprotected').value = 'true';
|
$('form_editprotected').value = 'true';
|
||||||
} else {
|
} else {
|
||||||
gidnumberField.disabled = true;
|
gidnumberField.disabled = true;
|
||||||
|
cnField.disabled = true;
|
||||||
$('form_editprotected').value = '';
|
$('form_editprotected').value = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,8 +76,8 @@ from ipagui.helpers import ipahelper
|
|||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<span py:replace="group_fields.cn.display(value_for(group_fields.cn))" />
|
<span py:replace="group_fields.cn.display(value_for(group_fields.cn))" />
|
||||||
<span py:if="tg.errors.get('description')" class="fielderror"
|
<span py:if="tg.errors.get('cn')" class="fielderror"
|
||||||
py:content="tg.errors.get('description')" />
|
py:content="tg.errors.get('cn')" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@ -88,6 +91,9 @@ from ipagui.helpers import ipahelper
|
|||||||
<span py:if="tg.errors.get('description')" class="fielderror"
|
<span py:if="tg.errors.get('description')" class="fielderror"
|
||||||
py:content="tg.errors.get('description')" />
|
py:content="tg.errors.get('description')" />
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
document.getElementById('form_cn').disabled = true;
|
||||||
|
</script>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@ -160,6 +166,7 @@ from ipagui.helpers import ipahelper
|
|||||||
div_counter = div_counter + 1
|
div_counter = div_counter + 1
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- a space here to prevent an empty div -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user