summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl MacMillan <kmacmill@redhat.com>2007-10-17 15:42:21 -0400
committerKarl MacMillan <kmacmill@redhat.com>2007-10-17 15:42:21 -0400
commit31fb0033ba89304fbaa54e78f680960092b557ca (patch)
treec0cfd3f684dd518622dc45b0b12712c0489fec2b
parentf8fba3b7ddbfbb8eb33faab1df3e024a30986b3e (diff)
parent8e88028417319bd3386195d95e244b05f82982ce (diff)
downloadfreeipa-31fb0033ba89304fbaa54e78f680960092b557ca.tar.gz
freeipa-31fb0033ba89304fbaa54e78f680960092b557ca.tar.xz
freeipa-31fb0033ba89304fbaa54e78f680960092b557ca.zip
Merge.
-rw-r--r--ipa-server/ipa-gui/ipagui/forms/delegate.py7
-rw-r--r--ipa-server/ipa-gui/ipagui/static/css/style.css7
-rw-r--r--ipa-server/ipa-gui/ipagui/static/javascript/dynamicedit.js6
-rw-r--r--ipa-server/ipa-gui/ipagui/static/javascript/ipautil.js2
-rw-r--r--ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py50
-rw-r--r--ipa-server/ipa-gui/ipagui/templates/delegateform.kid (renamed from ipa-server/ipa-gui/ipagui/templates/delegatenewform.kid)40
-rw-r--r--ipa-server/ipa-gui/ipagui/templates/delegatelist.kid41
-rw-r--r--ipa-server/ipa-gui/ipagui/templates/master.kid2
8 files changed, 125 insertions, 30 deletions
diff --git a/ipa-server/ipa-gui/ipagui/forms/delegate.py b/ipa-server/ipa-gui/ipagui/forms/delegate.py
index 668249128..c25d6c0cb 100644
--- a/ipa-server/ipa-gui/ipagui/forms/delegate.py
+++ b/ipa-server/ipa-gui/ipagui/forms/delegate.py
@@ -41,8 +41,10 @@ aci_attrs = [
aci_checkbox_attrs = [(field.name, field.label) for field in aci_attrs]
+aci_name_to_label = dict(aci_checkbox_attrs)
+
class DelegateFields():
- name = widgets.TextField(name="name", label="ACI Name")
+ name = widgets.TextField(name="name", label="Name")
source_group_dn = widgets.HiddenField(name="source_group_dn")
dest_group_dn = widgets.HiddenField(name="dest_group_dn")
@@ -81,9 +83,8 @@ class DelegateForm(widgets.Form):
def __init__(self, *args, **kw):
super(DelegateForm,self).__init__(*args, **kw)
- # TODO - rename to delegateform
(self.template_c, self.template) = widgets.meta.load_kid_template(
- "ipagui.templates.delegatenewform")
+ "ipagui.templates.delegateform")
self.delegate = DelegateFields
def update_params(self, params):
diff --git a/ipa-server/ipa-gui/ipagui/static/css/style.css b/ipa-server/ipa-gui/ipagui/static/css/style.css
index fb97a67a2..625eaa544 100644
--- a/ipa-server/ipa-gui/ipagui/static/css/style.css
+++ b/ipa-server/ipa-gui/ipagui/static/css/style.css
@@ -77,7 +77,7 @@ body {
#main_content {
background:#fff;
float:right;
- width:82%;
+ width:84%;
min-height:500px;
border-left: 1px solid #000;
padding: 10px;
@@ -92,7 +92,7 @@ body {
#sidebar {
background:#ccc; /* should be same as #page */
float:left;
- width:13%;
+ width:11%;
padding: 5px;
font-size: medium;
}
@@ -206,6 +206,9 @@ body {
background: #eee;
}
+.deletebutton {
+}
+
/*
* Used for checkboxlist of aci attributes
*/
diff --git a/ipa-server/ipa-gui/ipagui/static/javascript/dynamicedit.js b/ipa-server/ipa-gui/ipagui/static/javascript/dynamicedit.js
index 5d157cb86..d37dd920d 100644
--- a/ipa-server/ipa-gui/ipagui/static/javascript/dynamicedit.js
+++ b/ipa-server/ipa-gui/ipagui/static/javascript/dynamicedit.js
@@ -117,11 +117,11 @@ function addmember(dn, info) {
newdiv.style.display = 'none';
$('newmembers').appendChild(newdiv);
- return newdiv
+ return newdiv;
}
function addmemberHandler(element, dn, info) {
- var newdiv = addmember(dn, info)
+ var newdiv = addmember(dn, info);
if (newdiv != null) {
new Effect.Fade(Element.up(element), {duration: 0.75});
new Effect.Appear(newdiv, {duration: 0.75});
@@ -154,7 +154,7 @@ function removemember(dn, info) {
newdiv.style.display = 'none';
$('delmembers').appendChild(newdiv);
- return newdiv
+ return newdiv;
}
function removememberHandler(element, dn, info) {
diff --git a/ipa-server/ipa-gui/ipagui/static/javascript/ipautil.js b/ipa-server/ipa-gui/ipagui/static/javascript/ipautil.js
index 4aa74f37d..3fdd04ed4 100644
--- a/ipa-server/ipa-gui/ipagui/static/javascript/ipautil.js
+++ b/ipa-server/ipa-gui/ipagui/static/javascript/ipautil.js
@@ -4,5 +4,5 @@
* it can be embedded inside a dynamically generated string.
*/
function jsStringEscape(input) {
- return input.gsub(/(['"\\])/, function(match){ return "\\" + match[0]} );
+ return input.gsub(/(['"\\])/, function(match){ return "\\" + match[0];} );
}
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py b/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
index 47610a751..c732e8f85 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
@@ -125,6 +125,8 @@ class DelegationController(IPAController):
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(kw['orig_acistr'])
@@ -171,6 +173,8 @@ class DelegationController(IPAController):
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]
aci_list = []
for aci_str in aci_str_list:
@@ -182,7 +186,51 @@ class DelegationController(IPAController):
pass
group_dn_to_cn = self.extract_group_cns(aci_list, client)
- return dict(aci_list=aci_list, group_dn_to_cn=group_dn_to_cn)
+ # The list page needs to display field labels, not raw
+ # LDAP attributes
+ for aci in aci_list:
+ aci.attrs = map(lambda name:
+ ipagui.forms.delegate.aci_name_to_label.get(name, name),
+ aci.attrs)
+
+ 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 --git a/ipa-server/ipa-gui/ipagui/templates/delegatenewform.kid b/ipa-server/ipa-gui/ipagui/templates/delegateform.kid
index 2f31a06b3..26d136531 100644
--- a/ipa-server/ipa-gui/ipagui/templates/delegatenewform.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">
@@ -52,12 +64,20 @@
<th>
<input type="submit" class="submitbutton" name="submit"
value="${actionname} Delegation"/>
- <br />
+ <br/><br/>
</th>
<td>
<input type="submit" class="submitbutton" name="submit"
value="Cancel ${actionname}"/>
- <br />
+ <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>
@@ -150,21 +170,33 @@
<table class="formtable" cellpadding="2" cellspacing="0" border="0">
<tr>
<th>
+ <br/>
<input type="submit" class="submitbutton" name="submit"
value="${actionname} Delegation"/>
</th>
<td>
+ <br/>
<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>
- <script py:if="not value.get('source_group_dn')">
+ <script py:if="not value.get('source_group_dn')"
+ type="text/javascript">
new Effect.Appear($('source_searcharea'), {duration: 0.25});
new Effect.Fade($('source_change_link'), {duration: 0.25});
</script>
- <script py:if="not value.get('dest_group_dn')">
+ <script py:if="not value.get('dest_group_dn')"
+ type="text/javascript">
new Effect.Appear($('dest_searcharea'), {duration: 0.25});
new Effect.Fade($('dest_change_link'), {duration: 0.25});
</script>
diff --git a/ipa-server/ipa-gui/ipagui/templates/delegatelist.kid b/ipa-server/ipa-gui/ipagui/templates/delegatelist.kid
index 7e3374252..99bd1bb49 100644
--- a/ipa-server/ipa-gui/ipagui/templates/delegatelist.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/delegatelist.kid
@@ -6,18 +6,35 @@
<title>Delegations</title>
</head>
<body>
+
+<?python
+from ipagui.helpers import ipahelper
+?>
+
<script type="text/javascript" charset="utf-8" src="${tg.url('/static/javascript/tablekit.js')}"></script>
+ <script type="text/javascript">
+ function editDelegation(acistr) {
+ $('edit_acistr').value = acistr;
+ $('editform').submit();
+ return false;
+ }
+ </script>
+
+ <form style="display:none" id='editform'
+ method="post" action="${tg.url('/delegate/edit')}">
+ <input type="hidden" id="edit_acistr" name="acistr" value="" />
+ </form>
+
<h2>Delegations</h2>
<table id="resultstable" class="sortable resizable">
<thead>
<tr>
- <th>Name</th>
- <th>People in Group</th>
- <th>Can Modify</th>
- <th>For People in Group</th>
- <th>Action</th>
+ <th>${fields.name.label}</th>
+ <th>${fields.source_group_cn.label}</th>
+ <th>${fields.attrs.label}</th>
+ <th>${fields.dest_group_cn.label}</th>
</tr>
</thead>
<tbody>
@@ -25,9 +42,12 @@
<?python
source_cn = group_dn_to_cn.get(aci.source_group)
dest_cn = group_dn_to_cn.get(aci.dest_group)
+ acistr = aci.orig_acistr
+ acistr_esc = ipahelper.javascript_string_escape(acistr)
?>
<td>
- ${aci.name}
+ <a href="#" onclick="return editDelegation('${acistr_esc}');"
+ >${aci.name}</a>
</td>
<td>
<a href="${tg.url('/group/show', cn=source_cn)}"
@@ -40,15 +60,6 @@
<a href="${tg.url('/group/show', cn=dest_cn)}"
>${dest_cn}</a>
</td>
- <td>
- <?python
- # it's probably a bad idea to use a GET string here.
- # orig_acistr may be quite long
- # TODO - change to use a form/POST
- #
- ?>
- <a href="${tg.url('/delegate/edit', acistr=aci.orig_acistr)}">edit</a><br />
- </td>
</tr>
</tbody>
</table>
diff --git a/ipa-server/ipa-gui/ipagui/templates/master.kid b/ipa-server/ipa-gui/ipagui/templates/master.kid
index 2926c4f90..cf359579a 100644
--- a/ipa-server/ipa-gui/ipagui/templates/master.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/master.kid
@@ -78,7 +78,7 @@
<a href="${tg.url('/')}">Self Service</a><br/>
</p>
<p>
- <a href="${tg.url('/delegate/list')}">Delegation Mgmt</a><br/>
+ <a href="${tg.url('/delegate/list')}">Delegations</a><br/>
</p>
</div>