Added multi item action subform for generic list subtemplate and related code
This commit is contained in:
@@ -4,9 +4,15 @@ from django.db.utils import DatabaseError
|
|||||||
|
|
||||||
|
|
||||||
object_navigation = {}
|
object_navigation = {}
|
||||||
|
multi_object_navigation = {}
|
||||||
menu_links = []
|
menu_links = []
|
||||||
model_list_columns = {}
|
model_list_columns = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def register_multi_item_links(src, links, menu_name=None):
|
||||||
|
pass
|
||||||
|
|
||||||
def register_links(src, links, menu_name=None):
|
def register_links(src, links, menu_name=None):
|
||||||
if menu_name in object_navigation:
|
if menu_name in object_navigation:
|
||||||
if hasattr(src, '__iter__'):
|
if hasattr(src, '__iter__'):
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ from django.conf import settings
|
|||||||
from common.utils import return_attrib
|
from common.utils import return_attrib
|
||||||
|
|
||||||
|
|
||||||
|
class MultiItemForm(forms.Form):
|
||||||
|
action = forms.ChoiceField()
|
||||||
|
|
||||||
|
|
||||||
class DetailSelectMultiple(forms.widgets.SelectMultiple):
|
class DetailSelectMultiple(forms.widgets.SelectMultiple):
|
||||||
def __init__(self, queryset=None, *args, **kwargs):
|
def __init__(self, queryset=None, *args, **kwargs):
|
||||||
self.queryset=queryset
|
self.queryset=queryset
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<div class="inner">
|
<div class="inner">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<form action="#" class="form">
|
<form action="#" class="form" method="">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
{% if not hide_header %}
|
{% if not hide_header %}
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
{% for object in object_list %}
|
{% for object in object_list %}
|
||||||
<tr class="{% cycle 'odd' 'even2' %}">
|
<tr class="{% cycle 'odd' 'even2' %}">
|
||||||
{% if multi_select %}
|
{% if multi_select %}
|
||||||
<td><input type="checkbox" class="checkbox" name="id" value="1" /></td>
|
<td><input type="checkbox" class="checkbox" name="id" value="{{ object.pk }}" /></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not hide_object %}
|
{% if not hide_object %}
|
||||||
{% if main_object %}
|
{% if main_object %}
|
||||||
@@ -86,6 +86,9 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{% if multi_select %}
|
||||||
|
{% get_multi_item_links_form %}
|
||||||
|
{% endif %}
|
||||||
{% paginate %}
|
{% paginate %}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ from django.core.urlresolvers import RegexURLResolver, RegexURLPattern, Resolver
|
|||||||
from django.template import TemplateSyntaxError, Library, \
|
from django.template import TemplateSyntaxError, Library, \
|
||||||
VariableDoesNotExist, Node, Variable
|
VariableDoesNotExist, Node, Variable
|
||||||
from django.utils.text import unescape_string_literal
|
from django.utils.text import unescape_string_literal
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from common.api import object_navigation, menu_links as menu_navigation
|
from common.api import object_navigation, menu_links as menu_navigation
|
||||||
|
from common.forms import MultiItemForm
|
||||||
|
|
||||||
register = Library()
|
register = Library()
|
||||||
|
|
||||||
@@ -234,3 +236,12 @@ def object_navigation_template(context):
|
|||||||
return new_context
|
return new_context
|
||||||
register.inclusion_tag('generic_navigation.html', takes_context=True)(object_navigation_template)
|
register.inclusion_tag('generic_navigation.html', takes_context=True)(object_navigation_template)
|
||||||
|
|
||||||
|
|
||||||
|
def get_multi_item_links_form(context):
|
||||||
|
new_context = copy.copy(context)
|
||||||
|
new_context.update({
|
||||||
|
'form':MultiItemForm(),
|
||||||
|
'title':_(u'Selected item actions:')
|
||||||
|
})
|
||||||
|
return new_context
|
||||||
|
register.inclusion_tag('generic_form_subtemplate.html', takes_context=True)(get_multi_item_links_form)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
from common.api import register_links, register_menu, \
|
from common.api import register_links, register_menu, \
|
||||||
register_model_list_columns
|
register_model_list_columns, register_multi_item_links
|
||||||
from common.utils import pretty_size
|
from common.utils import pretty_size
|
||||||
|
|
||||||
from permissions.api import register_permissions
|
from permissions.api import register_permissions
|
||||||
@@ -62,6 +62,7 @@ staging_file_delete = {'text':_('delete'), 'view':'staging_file_delete', 'args':
|
|||||||
|
|
||||||
register_links(Document, [document_view_simple, document_view, document_edit, document_edit_metadata, document_delete, document_download, document_find_duplicates, document_clear_transformations], menu_name='sidebar')
|
register_links(Document, [document_view_simple, document_view, document_edit, document_edit_metadata, document_delete, document_download, document_find_duplicates, document_clear_transformations], menu_name='sidebar')
|
||||||
register_links(Document, [document_list, document_create, document_create_multiple, document_create_sibling], menu_name='sidebar')
|
register_links(Document, [document_list, document_create, document_create_multiple, document_create_sibling], menu_name='sidebar')
|
||||||
|
register_multi_item_links(Document, [document_clear_transformations], menu_name='sidebar')
|
||||||
|
|
||||||
if ENABLE_SINGLE_DOCUMENT_UPLOAD:
|
if ENABLE_SINGLE_DOCUMENT_UPLOAD:
|
||||||
register_links(['document_list', 'document_create', 'document_create_multiple', 'upload_document_with_type', 'upload_multiple_documents_with_type'], [document_list, document_create, document_create_multiple], menu_name='sidebar')
|
register_links(['document_list', 'document_create', 'document_create_multiple', 'upload_document_with_type', 'upload_multiple_documents_with_type'], [document_list, document_create, document_create_multiple], menu_name='sidebar')
|
||||||
|
|||||||
Reference in New Issue
Block a user