[Freeipa-devel] [PATCH] add group inactivation
Kevin McCarthy
kmccarth at redhat.com
Tue Oct 23 23:04:58 UTC 2007
This adds the same inactivation code for users to the groups pages.
-Kevin
-------------- next part --------------
# HG changeset patch
# User Kevin McCarthy <kmccarth at redhat.com>
# Date 1193180611 25200
# Node ID ba1cfe1ec9043c581a7cbb5ad6d2cfc472e9a7eb
# Parent f80f449a54d241db1bfb675a637bd7a24f745d43
Add group inactivation select list to web gui.
diff -r f80f449a54d2 -r ba1cfe1ec904 ipa-server/ipa-gui/ipagui/forms/group.py
--- a/ipa-server/ipa-gui/ipagui/forms/group.py Tue Oct 23 15:36:52 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/forms/group.py Tue Oct 23 16:03:31 2007 -0700
@@ -5,6 +5,10 @@ class GroupFields():
cn = widgets.TextField(name="cn", label="Name")
gidnumber = widgets.TextField(name="gidnumber", label="GID")
description = widgets.TextField(name="description", label="Description")
+
+ nsAccountLock = widgets.SingleSelectField(name="nsAccountLock",
+ label="Account Status",
+ options = [("", "active"), ("true", "inactive")])
cn_hidden = widgets.HiddenField(name="cn")
editprotected_hidden = widgets.HiddenField(name="editprotected")
diff -r f80f449a54d2 -r ba1cfe1ec904 ipa-server/ipa-gui/ipagui/helpers/ipahelper.py
--- a/ipa-server/ipa-gui/ipagui/helpers/ipahelper.py Tue Oct 23 15:36:52 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/helpers/ipahelper.py Tue Oct 23 16:03:31 2007 -0700
@@ -7,3 +7,9 @@ def javascript_string_escape(input):
return re.sub(r'[\'\"\\]',
lambda match: "\\%s" % match.group(),
input)
+
+def account_status_display(status):
+ if status == "true":
+ return "inactive"
+ else:
+ return "active"
diff -r f80f449a54d2 -r ba1cfe1ec904 ipa-server/ipa-gui/ipagui/helpers/userhelper.py
--- a/ipa-server/ipa-gui/ipagui/helpers/userhelper.py Tue Oct 23 15:36:52 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/helpers/userhelper.py Tue Oct 23 16:03:31 2007 -0700
@@ -21,9 +21,3 @@ def password_is_expired(days):
def password_expires_soon(days):
return (not password_is_expired(days)) and (days < 7)
-
-def account_status_display(status):
- if status == "true":
- return "inactive"
- else:
- return "active"
diff -r f80f449a54d2 -r ba1cfe1ec904 ipa-server/ipa-gui/ipagui/subcontrollers/group.py
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py Tue Oct 23 15:36:52 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py Tue Oct 23 16:03:31 2007 -0700
@@ -22,7 +22,7 @@ group_new_form = ipagui.forms.group.Grou
group_new_form = ipagui.forms.group.GroupNewForm()
group_edit_form = ipagui.forms.group.GroupEditForm()
-group_fields = ['*']
+group_fields = ['*', 'nsAccountLock']
class GroupController(IPAController):
@@ -73,6 +73,9 @@ class GroupController(IPAController):
new_group = ipa.group.Group()
new_group.setValue('cn', kw.get('cn'))
new_group.setValue('description', kw.get('description'))
+
+ if kw.get('nsAccountLock'):
+ new_group.setValue('nsAccountLock', 'true')
rv = client.add_group(new_group)
except ipaerror.exception_for(ipaerror.LDAP_DUPLICATE):
@@ -245,23 +248,28 @@ class GroupController(IPAController):
orig_group_dict = loads(b64decode(kw.get('group_orig')))
new_group = ipa.group.Group(orig_group_dict)
- if new_group.description != kw.get('description'):
- group_modified = True
- new_group.setValue('description', kw.get('description'))
+
+ new_group.setValue('description', kw.get('description'))
+
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)
- #
- # If the group update succeeds, but below operations fail, we
- # need to make sure a subsequent submit doesn't try to update
- # the group again.
- #
- kw['group_orig'] = b64encode(dumps(new_group.toDict()))
+ new_group.setValue('gidnumber', new_gid)
+
+ if kw.get('nsAccountLock'):
+ new_group.setValue('nsAccountLock', 'true')
+ else:
+ new_group.setValue('nsAccountLock', None)
+
+ rv = client.update_group(new_group)
+ group_modified = True
+ #
+ # If the group update succeeds, but below operations fail, we
+ # need to make sure a subsequent submit doesn't try to update
+ # the group again.
+ #
+ kw['group_orig'] = b64encode(dumps(new_group.toDict()))
+ except ipaerror.exception_for(ipaerror.LDAP_EMPTY_MODLIST), e:
+ pass
except ipaerror.IPAError, e:
turbogears.flash("Group update failed: " + str(e))
return dict(form=group_edit_form, group=kw, members=member_dicts,
diff -r f80f449a54d2 -r ba1cfe1ec904 ipa-server/ipa-gui/ipagui/templates/groupeditform.kid
--- a/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid Tue Oct 23 15:36:52 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid Tue Oct 23 16:03:31 2007 -0700
@@ -94,6 +94,18 @@ from ipagui.helpers import ipahelper
<script type="text/javascript">
document.getElementById('form_gidnumber').disabled = true;
</script>
+ </td>
+ </tr>
+
+ <tr>
+ <th>
+ <label class="fieldlabel" for="${group.nsAccountLock.field_id}"
+ py:content="group.nsAccountLock.label" />:
+ </th>
+ <td>
+ <span py:replace="group.nsAccountLock.display(value_for(group.nsAccountLock))" />
+ <span py:if="tg.errors.get('nsAccountLock')" class="fielderror"
+ py:content="tg.errors.get('nsAccountLock')" />
</td>
</tr>
</table>
diff -r f80f449a54d2 -r ba1cfe1ec904 ipa-server/ipa-gui/ipagui/templates/groupnewform.kid
--- a/ipa-server/ipa-gui/ipagui/templates/groupnewform.kid Tue Oct 23 15:36:52 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/templates/groupnewform.kid Tue Oct 23 16:03:31 2007 -0700
@@ -73,6 +73,18 @@ from ipagui.helpers import ipahelper
Generated by server
</td>
</tr>
+
+ <tr>
+ <th>
+ <label class="fieldlabel" for="${group.nsAccountLock.field_id}"
+ py:content="group.nsAccountLock.label" />:
+ </th>
+ <td>
+ <span py:replace="group.nsAccountLock.display(value_for(group.nsAccountLock))" />
+ <span py:if="tg.errors.get('nsAccountLock')" class="fielderror"
+ py:content="tg.errors.get('nsAccountLock')" />
+ </td>
+ </tr>
</table>
<div style="clear:both">
diff -r f80f449a54d2 -r ba1cfe1ec904 ipa-server/ipa-gui/ipagui/templates/groupshow.kid
--- a/ipa-server/ipa-gui/ipagui/templates/groupshow.kid Tue Oct 23 15:36:52 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/templates/groupshow.kid Tue Oct 23 16:03:31 2007 -0700
@@ -7,6 +7,8 @@
</head>
<body>
<?python
+from ipagui.helpers import ipahelper
+
edit_url = tg.url('/group/edit', cn=group.get('cn'))
?>
<h2>View Group</h2>
@@ -36,6 +38,13 @@ edit_url = tg.url('/group/edit', cn=grou
<label class="fieldlabel" py:content="fields.gidnumber.label" />:
</th>
<td>${group.get("gidnumber")}</td>
+ </tr>
+
+ <tr>
+ <th>
+ <label class="fieldlabel" py:content="fields.nsAccountLock.label" />:
+ </th>
+ <td>${ipahelper.account_status_display(group.get("nsAccountLock"))}</td>
</tr>
</table>
diff -r f80f449a54d2 -r ba1cfe1ec904 ipa-server/ipa-gui/ipagui/templates/usershow.kid
--- a/ipa-server/ipa-gui/ipagui/templates/usershow.kid Tue Oct 23 15:36:52 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/templates/usershow.kid Tue Oct 23 16:03:31 2007 -0700
@@ -17,6 +17,7 @@ edit_url = tg.url('/user/edit', uid=user
<?python
from ipagui.helpers import userhelper
+from ipagui.helpers import ipahelper
pw_expires_days = userhelper.password_expires_in(user.get("krbPasswordExpiration"))
pw_expires_soon = userhelper.password_expires_soon(pw_expires_days)
pw_is_expired = userhelper.password_is_expired(pw_expires_days)
@@ -79,7 +80,7 @@ else:
<th>
<label class="fieldlabel" py:content="fields.nsAccountLock.label" />:
</th>
- <td>${userhelper.account_status_display(user.get("nsAccountLock"))}</td>
+ <td>${ipahelper.account_status_display(user.get("nsAccountLock"))}</td>
</tr>
<tr>
<th>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4054 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20071023/d30545ca/attachment.bin>
More information about the Freeipa-devel
mailing list