mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-03-29 20:40:25 +00:00
Merge branch 'modellist-170' of git://github.com/ludw/django-admin2 into ludw-modellist-170
This commit is contained in:
commit
5be8972dac
3 changed files with 37 additions and 21 deletions
|
|
@ -9,8 +9,8 @@ $(function() {
|
|||
for (var ix = 0; ix < selectCheckboxen.length; ix++) {
|
||||
if ($(selectCheckboxen[ix]).prop('checked')) {
|
||||
count++;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
selectAllCheckbox.prop('checked', count == selectCheckboxen.length);
|
||||
selectedCount.text(count);
|
||||
};
|
||||
|
|
@ -23,4 +23,15 @@ $(function() {
|
|||
selectCheckboxen.click(function(e) {
|
||||
updateSelectedCount();
|
||||
});
|
||||
|
||||
|
||||
var actionDropdownLink = element.find('.dropdown-menu a');
|
||||
actionDropdownLink.click(function (e) {
|
||||
e.preventDefault();
|
||||
var form = $(this).closest('form');
|
||||
form.find('input[name="' + $(this).data('name') + '"]').val(
|
||||
$(this).data('value'));
|
||||
form.submit();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,16 +19,22 @@
|
|||
|
||||
<div id="model-list" class="row">
|
||||
<form id="model-list-form" class="form-inline" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="span12">
|
||||
<div class="navbar">
|
||||
{% csrf_token %}
|
||||
<select name="action">
|
||||
{% for action in actions %}
|
||||
<option value="{{ action.name }}">{{ action.description }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button type="Submit" class="btn">Go</button>
|
||||
<span id="selected-count">0</span> of {{ object_list|length }} selected
|
||||
<div class="btn-group">
|
||||
<button class="btn dropdown-toggle" data-toggle="dropdown">
|
||||
Actions
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
{% for action in actions %}
|
||||
<li><a tabindex="-1" href="#" data-name="action" data-value="{{ action.name }}">{{ action.description }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<input type="hidden" name="action" value="" />
|
||||
<small class="muted"><span id="selected-count">0</span> of {{ object_list|length }} selected</small>
|
||||
<div class="pull-right">
|
||||
{% if permissions.has_add_permission %}
|
||||
<a href="{% url view|admin2_urlname:'create' %}" class="btn"><i class="icon-plus"></i> {% blocktrans with model_verbose_name=model|model_verbose_name %}Add {{ model_verbose_name }}{% endblocktrans %}</a>
|
||||
|
|
@ -38,23 +44,22 @@
|
|||
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<th><input type="checkbox" class="model-select-all"></th>
|
||||
<th>{{ model_name }}</th>
|
||||
<th class="checkbox-column"><input type="checkbox" class="model-select-all"></th>
|
||||
<th>{{ model_name|capfirst }}</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for obj in object_list %}
|
||||
<tr>
|
||||
<td><input type="checkbox" class="model-select" name="selected_model_pk" value="{{ obj.pk }}"></td>
|
||||
<td>
|
||||
{{ obj }}
|
||||
{% if permissions.has_view_permission %}
|
||||
<a href="{% url view|admin2_urlname:'detail' pk=obj.pk %}">{% trans "Detail" %}</a>
|
||||
{% endif %}
|
||||
{% if permissions.has_change_permission %}
|
||||
<a href="{% url view|admin2_urlname:'update' pk=obj.pk %}">{% trans "Edit" %}</a>
|
||||
{% endif %}
|
||||
{% if permissions.has_delete_permission %}
|
||||
<a href="{% url view|admin2_urlname:'delete' pk=obj.pk %}">{% trans "Delete" %}</a>
|
||||
<a href="{% url view|admin2_urlname:'update' pk=obj.pk %}">{{ obj }}</a>
|
||||
{% else %}
|
||||
{% if permissions.has_view_permission %}
|
||||
<a href="{% url view|admin2_urlname:'detail' pk=obj.pk %}">{{ obj }}</a>
|
||||
{% else %}
|
||||
{{ obj }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class PostListTest(BaseIntegrationTest):
|
|||
|
||||
def test_actions_displayed(self):
|
||||
response = self.client.get(reverse("admin2:blog_post_index"))
|
||||
self.assertInHTML('<option value="DeleteSelectedAction">Delete selected items</option>', response.content)
|
||||
self.assertInHTML('<a tabindex="-1" href="#" data-name="action" data-value="DeleteSelectedAction">Delete selected items</a>', response.content)
|
||||
|
||||
def test_delete_selected_post(self):
|
||||
post = Post.objects.create(title="a_post_title", body="body")
|
||||
|
|
|
|||
Loading…
Reference in a new issue