[Freeipa-devel] [PATCH] delete delegations

Kevin McCarthy kmccarth at redhat.com
Tue Oct 16 17:04:16 UTC 2007


Adds a delete button for delegations.  I debated a confirmation pages
vs confirm dialog.  For now I've gone for the dialog, with the addition
that the delete can't be triggered without javascript.

-Kevin

-------------- next part --------------
# HG changeset patch
# User Kevin McCarthy <kmccarth at redhat.com>
# Date 1192554090 25200
# Node ID bd42c014d9168c5ed95ed720b49b8791181fe267
# Parent  b24e9309b3f266c5c321cdda047d29dd9495d5b0
Adds deletion for delegations.
The deletion is only triggered via javascript, so they must hit confirm.

diff -r b24e9309b3f2 -r bd42c014d916 ipa-server/ipa-gui/ipagui/static/css/style.css
--- a/ipa-server/ipa-gui/ipagui/static/css/style.css	Tue Oct 16 09:24:21 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/static/css/style.css	Tue Oct 16 10:01:30 2007 -0700
@@ -206,6 +206,10 @@ body {
   background: #eee;
 }
 
+.deletebutton {
+  background: #ee2222;
+}
+
 /*
  * Used for checkboxlist of aci attributes
  */
diff -r b24e9309b3f2 -r bd42c014d916 ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py	Tue Oct 16 09:24:21 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py	Tue Oct 16 10:01:30 2007 -0700
@@ -195,6 +195,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())
diff -r b24e9309b3f2 -r bd42c014d916 ipa-server/ipa-gui/ipagui/templates/delegateform.kid
--- a/ipa-server/ipa-gui/ipagui/templates/delegateform.kid	Tue Oct 16 09:24:21 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/templates/delegateform.kid	Tue Oct 16 10:01:30 2007 -0700
@@ -43,7 +43,19 @@
       new Effect.Fade($(which_group + '_searcharea'), {duration: 0.25});
       new Effect.Appear($(which_group + '_change_link'), {duration: 0.25});
     }
-  </script>
+
+    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">
 
@@ -57,6 +69,14 @@
         <td>
           <input type="submit" class="submitbutton" name="submit"
                  value="Cancel ${actionname}"/>
+          <br/><br/>
+        </td>
+        <td py:if='actionname == "Edit"'>
+                    
+          <input type="button" class="deletebutton"
+                 value="Delete Delegation"
+                 onclick="return confirmDelete();"
+                 />
           <br/><br/>
         </td>
       </tr>
@@ -159,6 +179,14 @@
           <input type="submit" class="submitbutton" name="submit"
                  value="Cancel ${actionname}"/>
         </td>
+        <td py:if='actionname == "Edit"'>
+          <br/>
+                    
+          <input type="button" class="deletebutton"
+                 value="Delete Delegation"
+                 onclick="return confirmDelete();"
+                 />
+        </td>
       </tr>
     </table>
 
-------------- 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/20071016/99fc3a0a/attachment.bin>


More information about the Freeipa-devel mailing list