Skip to content

Commit

Permalink
[per-object-permissions] Added "Apply Selected" button to RLP table t…
Browse files Browse the repository at this point in the history
…hat submits the selected row levle permissions to be changed.

git-svn-id: http://code.djangoproject.com/svn/django/branches/per-object-permissions@3578 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
Christopher Long committed Aug 13, 2006
1 parent 03e1b7f commit 4f01189
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 43 deletions.
26 changes: 22 additions & 4 deletions django/contrib/admin/media/js/row_level_permission.js
@@ -1,13 +1,31 @@
var row_level_permission = {


copyToNew: function (id)
{
var newForm = add_row_level_permission.form;
var newForm = document.getElementById("addRLPForm");
var form = document.getElementById("editRLPForm-"+id);
newForm.owner.selectedIndex = form.owner.selectedIndex;
newForm.perm.selectedIndex = form.perm.selectedIndex;
newForm.negative.checked = form.negative.checked;
}
},

apply_selected: function ()
{
var eleList = document.getElementsByName("apply_checkbox");
var formList = [];
for(var i=0; eleList.length; i++)
{
var ele = eleList[i];
if(ele.tagName == "INPUT") {
if(ele.checked) {
ele.form.submit();
}
}
}
return false;
},

init: function() {

}
}

60 changes: 21 additions & 39 deletions django/contrib/admin/templates/admin/row_level_permission.html
Expand Up @@ -50,16 +50,17 @@ <h2>{% trans "Add Permissions" %}</h2>
<h2>{% trans "Current Permissions" %}</h2>
<table id="current-rlpTable">
<tr class="header">
<th>
<th id="select_header"></th>
<th id="owner_header">
{% trans "Owner" %}
</th>
<th>
<th id="perm_header">
{% trans "Permission" %}
</th>
<th>
<th id="negative_header">
{% trans "Negative" %}
</th>
<th>
<th id="options_header">
{% trans "Options" %}
</th>
</tr>
Expand All @@ -68,10 +69,13 @@ <h2>{% trans "Current Permissions" %}</h2>
{% load row_level_permission %}
{% for o in rlp_form_list %}
<tr id="editRLP-{{ o.rlp.id }}">
<td colspan="4">
<form id="editRLPForm-{{ o.rlp.id }}" class="editRLPForm" method="POST" name="editRLPForm-{{ rlp.id }}" action="../../../auth/row_level_permission/{% objref o.rlp %}/change/">
<table>
<tr>
<!--<td colspan="5">-->
<form id="editRLPForm-{{ o.rlp.id }}" class="editRLPForm" method="POST" name="editRLPForm-{{ o.rlp.id }}" action="../../../auth/row_level_permission/{% objref o.rlp %}/change/">
<!--<table>
<tr>-->
<td>
<input type="checkbox" name="apply_checkbox">
</td>
<td>
{{ o.form.owner }}
</td>
Expand All @@ -89,43 +93,21 @@ <h2>{% trans "Current Permissions" %}</h2>
<a href="../../../auth/row_level_permission/{% objref o.rlp %}/delete/" class="deleteLink">{% trans 'Delete' %}</a> |
<a href="javascript:row_level_permission.copyToNew({{ o.rlp.id }})" class="copyToNewLink">{% trans 'Copy to New' %}</a>
</td>
</tr>
</table>
<!--</tr>
</table>-->
</form>
</td>
</tr>
{% endfor %}
<tr align="right">
<td colspan="5">
<form id="apply_selected_form" method="POST" name="apply_selected_form" onsubmit="row_level_permission.apply_selected(); return false;">
<input id="apply_selected_button" type="submit" value="{% trans 'Apply Selected' %}" />
</form>
</td>
</tr>
{% else %}
<tr><td colspan=4><em>No row level permissions</em></td></tr>
{% endif %}
</TBODY>
</table>

<table style="display: none">
<tr id="empty_editRLP">
<td colspan="4">
<form id="empty_editRLPForm" method="POST" class="editRLPForm" name="empty-editRLPForm">
<table>
<tr>
<td>
{{ empty_rlp_form.owner }}
</td>
<td>
{{ empty_rlp_form.perm }}
</td>
<td>
{{ empty_rlp_form.negative }}
</td>
<td>
<input id="applyButton" type="submit" value="{% trans 'Apply' %}" />
<input id="cancelButton" type="reset" value="{% trans 'Reset' %}"/>
<br/>
<a class="deleteLink" >{% trans 'Delete' %}</a> |
<a class="copyToNewLink">{% trans 'Copy to New' %}</a>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

0 comments on commit 4f01189

Please sign in to comment.