summaryrefslogtreecommitdiffstats
path: root/ipa-server
diff options
context:
space:
mode:
authorKevin McCarthy <kmccarth@redhat.com>2007-10-16 10:01:30 -0700
committerKevin McCarthy <kmccarth@redhat.com>2007-10-16 10:01:30 -0700
commit3db0f99977deae9be43c239f89bfa348b8b3bafe (patch)
treea1f175819659e83cf6d7e099b0d031b391a9c912 /ipa-server
parent1592229c3c4bb53106cf35371fad5cd03ae76759 (diff)
downloadfreeipa-3db0f99977deae9be43c239f89bfa348b8b3bafe.tar.gz
freeipa-3db0f99977deae9be43c239f89bfa348b8b3bafe.tar.xz
freeipa-3db0f99977deae9be43c239f89bfa348b8b3bafe.zip
Adds deletion for delegations.
The deletion is only triggered via javascript, so they must hit confirm.
Diffstat (limited to 'ipa-server')
-rw-r--r--ipa-server/ipa-gui/ipagui/static/css/style.css4
-rw-r--r--ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py36
-rw-r--r--ipa-server/ipa-gui/ipagui/templates/delegateform.kid28
3 files changed, 68 insertions, 0 deletions
diff --git a/ipa-server/ipa-gui/ipagui/static/css/style.css b/ipa-server/ipa-gui/ipagui/static/css/style.css
index fb97a67a2..ff92c5a89 100644
--- a/ipa-server/ipa-gui/ipagui/static/css/style.css
+++ b/ipa-server/ipa-gui/ipagui/static/css/style.css
@@ -206,6 +206,10 @@ body {
background: #eee;
}
+.deletebutton {
+ background: #ee2222;
+}
+
/*
* Used for checkboxlist of aci attributes
*/
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py b/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
index 3f9752345..c732e8f85 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
@@ -196,6 +196,42 @@ class DelegationController(IPAController):
return dict(aci_list=aci_list, group_dn_to_cn=group_dn_to_cn,
fields=ipagui.forms.delegate.DelegateFields())
+ @expose()
+ @identity.require(identity.not_anonymous())
+ def delete(self, acistr):
+ """Display delegate page"""
+ self.restrict_post()
+ client = self.get_ipaclient()
+
+ try:
+ aci_entry = client.get_aci_entry(aci_fields)
+
+ aci_str_list = aci_entry.getValues('aci')
+ if aci_str_list is None:
+ aci_str_list = []
+ if not(isinstance(aci_str_list,list) or isinstance(aci_str_list,tuple)):
+ aci_str_list = [aci_str_list]
+
+ try :
+ old_aci_index = aci_str_list.index(acistr)
+ except ValueError:
+ turbogears.flash("Delegation deletion failed:<br />" +
+ "The delegation you were attempting to delete has been " +
+ "concurrently modified.")
+ raise turbogears.redirect('/delegate/list')
+
+ new_aci_str_list = copy.copy(aci_str_list)
+ del new_aci_str_list[old_aci_index]
+ aci_entry.setValue('aci', new_aci_str_list)
+
+ client.update_entry(aci_entry)
+
+ turbogears.flash("delegate deleted")
+ raise turbogears.redirect('/delegate/list')
+ except (SyntaxError, ipaerror.IPAError), e:
+ turbogears.flash("Delegation deletion failed: " + str(e))
+ raise turbogears.redirect('/delegate/list')
+
@expose("ipagui.templates.delegategroupsearch")
@identity.require(identity.not_anonymous())
def group_search(self, **kw):
diff --git a/ipa-server/ipa-gui/ipagui/templates/delegateform.kid b/ipa-server/ipa-gui/ipagui/templates/delegateform.kid
index e414e4443..26d136531 100644
--- a/ipa-server/ipa-gui/ipagui/templates/delegateform.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/delegateform.kid
@@ -43,8 +43,20 @@
new Effect.Fade($(which_group + '_searcharea'), {duration: 0.25});
new Effect.Appear($(which_group + '_change_link'), {duration: 0.25});
}
+
+ function confirmDelete() {
+ if (confirm("Are you sure you want to delete this delegation?")) {
+ $('deleteform').submit();
+ }
+ return false;
+ }
</script>
+ <form style="display:none" id='deleteform'
+ method="post" action="${tg.url('/delegate/delete')}">
+ <input type="hidden" name="acistr" value="${value.get('orig_acistr')}" />
+ </form>
+
<form action="${action}" name="${name}" method="${method}" class="tableform">
<table class="formtable" cellpadding="2" cellspacing="0" border="0">
@@ -59,6 +71,14 @@
value="Cancel ${actionname}"/>
<br/><br/>
</td>
+ <td py:if='actionname == "Edit"'>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
+ <input type="button" class="deletebutton"
+ value="Delete Delegation"
+ onclick="return confirmDelete();"
+ />
+ <br/><br/>
+ </td>
</tr>
</table>
@@ -159,6 +179,14 @@
<input type="submit" class="submitbutton" name="submit"
value="Cancel ${actionname}"/>
</td>
+ <td py:if='actionname == "Edit"'>
+ <br/>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
+ <input type="button" class="deletebutton"
+ value="Delete Delegation"
+ onclick="return confirmDelete();"
+ />
+ </td>
</tr>
</table>