summaryrefslogtreecommitdiffstats
path: root/ipa-server/ipa-gui
diff options
context:
space:
mode:
authorKevin McCarthy <kmccarth@redhat.com>2007-09-18 10:54:53 -0700
committerKevin McCarthy <kmccarth@redhat.com>2007-09-18 10:54:53 -0700
commitc4998d3902ab17e73d29255db38f9c4cc33863d6 (patch)
treeeb74cd5c1634e13c49f52962e2b2606b5e884dbe /ipa-server/ipa-gui
parent8190404706252774394110c4375633721df08641 (diff)
downloadfreeipa-c4998d3902ab17e73d29255db38f9c4cc33863d6.tar.gz
freeipa-c4998d3902ab17e73d29255db38f9c4cc33863d6.tar.xz
freeipa-c4998d3902ab17e73d29255db38f9c4cc33863d6.zip
Fixes to the edit protected checkbox.
- Make checkbox sticky on round trips - Make required fields validate when checkbox is checked.
Diffstat (limited to 'ipa-server/ipa-gui')
-rw-r--r--ipa-server/ipa-gui/ipagui/controllers.py15
-rw-r--r--ipa-server/ipa-gui/ipagui/forms/group.py9
-rw-r--r--ipa-server/ipa-gui/ipagui/forms/user.py7
-rw-r--r--ipa-server/ipa-gui/ipagui/templates/groupedit.kid2
-rw-r--r--ipa-server/ipa-gui/ipagui/templates/groupeditform.kid7
-rw-r--r--ipa-server/ipa-gui/ipagui/templates/useredit.kid2
-rw-r--r--ipa-server/ipa-gui/ipagui/templates/usereditform.kid9
7 files changed, 40 insertions, 11 deletions
diff --git a/ipa-server/ipa-gui/ipagui/controllers.py b/ipa-server/ipa-gui/ipagui/controllers.py
index 1cc99862..fd661eeb 100644
--- a/ipa-server/ipa-gui/ipagui/controllers.py
+++ b/ipa-server/ipa-gui/ipagui/controllers.py
@@ -163,11 +163,10 @@ class Root(controllers.RootController):
new_user.setValue('nsAccountLock', 'true')
else:
new_user.setValue('nsAccountLock', None)
- if kw.get('userpassword'):
- new_user.setValue('userpassword', kw.get('userpassword'))
- if kw.get('uidnumber'):
+ if kw.get('editprotected') == 'true':
+ if kw.get('userpassword'):
+ new_user.setValue('userpassword', kw.get('userpassword'))
new_user.setValue('uidnumber', str(kw.get('uidnumber')))
- if kw.get('gidnumber'):
new_user.setValue('gidnumber', str(kw.get('gidnumber')))
#
@@ -480,9 +479,11 @@ class Root(controllers.RootController):
if new_group.description != kw.get('description'):
group_modified = True
new_group.setValue('description', kw.get('description'))
- if kw.get('gidnumber'):
- group_modified = True
- new_group.setValue('gidnumber', str(kw.get('gidnumber')))
+ if kw.get('editprotected') == 'true':
+ new_gid = str(kw.get('gidnumber'))
+ if new_group.gidnumber != new_gid:
+ group_modified = True
+ new_group.setValue('gidnumber', new_gid)
if group_modified:
rv = client.update_group(new_group)
diff --git a/ipa-server/ipa-gui/ipagui/forms/group.py b/ipa-server/ipa-gui/ipagui/forms/group.py
index 83925596..20706eb6 100644
--- a/ipa-server/ipa-gui/ipagui/forms/group.py
+++ b/ipa-server/ipa-gui/ipagui/forms/group.py
@@ -7,13 +7,14 @@ class GroupFields():
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")
member_data = widgets.HiddenField(name="member_data")
uid_to_cn_json = widgets.HiddenField(name="uid_to_cn_json")
class GroupNewValidator(validators.Schema):
- cn = validators.PlainText(not_empty=True)
+ cn = validators.String(not_empty=True)
description = validators.String(not_empty=False)
@@ -37,11 +38,15 @@ class GroupEditValidator(validators.Schema):
gidnumber = validators.Int(not_empty=False)
description = validators.String(not_empty=False)
+ pre_validators = [
+ validators.RequireIfPresent(required='gidnumber', present='editprotected'),
+ ]
+
class GroupEditForm(widgets.Form):
params = ['members', 'group']
fields = [GroupFields.gidnumber, GroupFields.description,
- GroupFields.cn_hidden,
+ GroupFields.cn_hidden, GroupFields.editprotected_hidden,
GroupFields.group_orig, GroupFields.member_data,
GroupFields.uid_to_cn_json]
diff --git a/ipa-server/ipa-gui/ipagui/forms/user.py b/ipa-server/ipa-gui/ipagui/forms/user.py
index 0fc6761f..037205a1 100644
--- a/ipa-server/ipa-gui/ipagui/forms/user.py
+++ b/ipa-server/ipa-gui/ipagui/forms/user.py
@@ -21,6 +21,7 @@ class UserFields():
uidnumber_hidden = widgets.HiddenField(name="uidnumber")
gidnumber_hidden = widgets.HiddenField(name="gidnumber")
krbPasswordExpiration_hidden = widgets.HiddenField(name="krbPasswordExpiration")
+ editprotected_hidden = widgets.HiddenField(name="editprotected")
user_orig = widgets.HiddenField(name="user_orig")
@@ -70,6 +71,11 @@ class UserEditValidator(validators.Schema):
# validators.PhoneNumber may be a bit too picky, requiring an area code
# telephonenumber = validators.PlainText(not_empty=False)
+ pre_validators = [
+ validators.RequireIfPresent(required='uidnumber', present='editprotected'),
+ validators.RequireIfPresent(required='gidnumber', present='editprotected'),
+ ]
+
chained_validators = [
validators.FieldsMatch('userpassword', 'userpassword_confirm')
]
@@ -81,6 +87,7 @@ class UserEditForm(widgets.Form):
UserFields.uid_hidden, UserFields.user_orig,
UserFields.uidnumber, UserFields.gidnumber,
UserFields.krbPasswordExpiration_hidden,
+ UserFields.editprotected_hidden,
]
validator = UserEditValidator()
diff --git a/ipa-server/ipa-gui/ipagui/templates/groupedit.kid b/ipa-server/ipa-gui/ipagui/templates/groupedit.kid
index 1017e400..f1d309ca 100644
--- a/ipa-server/ipa-gui/ipagui/templates/groupedit.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/groupedit.kid
@@ -8,7 +8,7 @@
<body>
<div>
<div style="float:right">
- <input type="checkbox"
+ <input type="checkbox" id="toggleprotected_checkbox"
onclick="toggleProtectedFields(this);">
<span class="small">edit protected fields</span>
</input>
diff --git a/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid b/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid
index df0095d9..5c2fea74 100644
--- a/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid
@@ -24,8 +24,10 @@
var gidnumberField = $('form_gidnumber');
if (checkbox.checked) {
gidnumberField.disabled = false;
+ $('form_editprotected').value = 'true';
} else {
gidnumberField.disabled = true;
+ $('form_editprotected').value = '';
}
}
@@ -273,6 +275,11 @@
if ($('form_uid_to_cn_json').value != "") {
uid_to_cn_hash = new Hash($('form_uid_to_cn_json').value.evalJSON());
}
+
+ if ($('form_editprotected').value != "") {
+ $('toggleprotected_checkbox').checked = true;
+ toggleProtectedFields($('toggleprotected_checkbox'));
+ }
</script>
<?python
diff --git a/ipa-server/ipa-gui/ipagui/templates/useredit.kid b/ipa-server/ipa-gui/ipagui/templates/useredit.kid
index 9e8d8f46..b5e8447d 100644
--- a/ipa-server/ipa-gui/ipagui/templates/useredit.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/useredit.kid
@@ -9,7 +9,7 @@
<div>
<div style="float:right">
- <input type="checkbox"
+ <input type="checkbox" id="toggleprotected_checkbox"
onclick="toggleProtectedFields(this);">
<span class="small">edit protected fields</span>
</input>
diff --git a/ipa-server/ipa-gui/ipagui/templates/usereditform.kid b/ipa-server/ipa-gui/ipagui/templates/usereditform.kid
index ce92122b..3f7db50d 100644
--- a/ipa-server/ipa-gui/ipagui/templates/usereditform.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/usereditform.kid
@@ -13,11 +13,13 @@
passwordConfirmField.disabled = false;
uidnumberField.disabled = false;
gidnumberField.disabled = false;
+ $('form_editprotected').value = 'true';
} else {
passwordField.disabled = true;
passwordConfirmField.disabled = true;
uidnumberField.disabled = true;
gidnumberField.disabled = true;
+ $('form_editprotected').value = '';
}
}
</script>
@@ -228,4 +230,11 @@
</table>
</form>
+
+ <script type="text/javascript">
+ if ($('form_editprotected').value != "") {
+ $('toggleprotected_checkbox').checked = true;
+ toggleProtectedFields($('toggleprotected_checkbox'));
+ }
+ </script>
</div>