Initial changes to support multi row actions
This commit is contained in:
@@ -70,6 +70,7 @@
|
||||
{% with subtemplate.main_object as main_object %}
|
||||
{% with subtemplate.hide_link as hide_link %}
|
||||
{% with subtemplate.hide_header as hide_header %}
|
||||
{% with subtemplate.multi_select as multi_select %}
|
||||
{% include subtemplate.name %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
@@ -78,6 +79,7 @@
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
<tbody>
|
||||
{% if not hide_header %}
|
||||
<tr>
|
||||
{% if multi_select %}
|
||||
<th class="first"><input type="checkbox" class="checkbox toggle" /></th>
|
||||
{% endif %}
|
||||
{% if not hide_object %}
|
||||
<th>{% trans "Identifier" %}</th>
|
||||
{% endif %}
|
||||
@@ -46,6 +49,9 @@
|
||||
{% endif %}
|
||||
{% for object in object_list %}
|
||||
<tr class="{% cycle 'odd' 'even2' %}">
|
||||
{% if multi_select %}
|
||||
<td><input type="checkbox" class="checkbox" name="id" value="1" /></td>
|
||||
{% endif %}
|
||||
{% if not hide_object %}
|
||||
{% if main_object %}
|
||||
{% with object|object_property:main_object as object %}
|
||||
|
||||
@@ -34,6 +34,7 @@ urlpatterns = patterns('documents.views',
|
||||
url(r'^document/(?P<document_id>\d+)/create/siblings/$', 'document_create_sibling', {'multiple':True if ENABLE_SINGLE_DOCUMENT_UPLOAD == False else False}, 'document_create_sibling'),
|
||||
url(r'^document/(?P<document_id>\d+)/find_duplicates/$', 'document_find_duplicates', (), 'document_find_duplicates'),
|
||||
url(r'^document/(?P<document_id>\d+)/clear_transformations/$', 'document_clear_transformations', (), 'document_clear_transformations'),
|
||||
url(r'^document/(?P<document_id_list>[0-9,]+)/clear_transformations/$', 'document_clear_transformations', (), 'document_clear_transformations'),
|
||||
url(r'^duplicates/$', 'document_find_all_duplicates', (), 'document_find_all_duplicates'),
|
||||
|
||||
url(r'^staging_file/(?P<staging_file_id>\w+)/preview/$', 'staging_file_preview', (), 'staging_file_preview'),
|
||||
|
||||
@@ -74,6 +74,7 @@ def document_list(request):
|
||||
template_name='generic_list.html',
|
||||
extra_context={
|
||||
'title':_(u'documents'),
|
||||
'multi_select':True,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -734,29 +735,49 @@ def document_find_all_duplicates(request):
|
||||
return _find_duplicate_list(request, include_source=True)
|
||||
|
||||
|
||||
def document_clear_transformations(request, document_id):
|
||||
def document_clear_transformations(request, document_id=None, document_id_list=None):
|
||||
check_permissions(request.user, 'documents', [PERMISSION_DOCUMENT_TRANSFORM])
|
||||
|
||||
previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', None)))
|
||||
|
||||
document = get_object_or_404(Document, pk=document_id)
|
||||
if document_id:
|
||||
documents = [get_object_or_404(Document, pk=document_id)]
|
||||
post_redirect = reverse('document_view', args=[documents[0].pk])
|
||||
elif document_id_list:
|
||||
documents = [get_object_or_404(Document, pk=document_id) for document_id in document_id_list.split(',')]
|
||||
post_redirect = None
|
||||
|
||||
previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', post_redirect or reverse('document_list'))))
|
||||
next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', post_redirect or reverse('document_list'))))
|
||||
|
||||
if request.method == 'POST':
|
||||
for document_page in document.documentpage_set.all():
|
||||
for transformation in document_page.documentpagetransformation_set.all():
|
||||
transformation.delete()
|
||||
|
||||
messages.success(request, _(u'All the page transformations for document: %s, have been deleted successfully.') % document)
|
||||
return HttpResponseRedirect(reverse('document_view', args=[document.pk]))
|
||||
|
||||
for document in documents:
|
||||
for document_page in document.documentpage_set.all():
|
||||
for transformation in document_page.documentpagetransformation_set.all():
|
||||
transformation.delete()
|
||||
|
||||
return render_to_response('generic_confirm.html', {
|
||||
if len(documents) == 1:
|
||||
messages.success(request, _(u'All the page transformations for document: %s, have been deleted successfully.') % documents)
|
||||
elif len(documents) > 1:
|
||||
messages.success(request, _(u'All the page transformations for the documents: %s, have been deleted successfully.') % documents)
|
||||
|
||||
return HttpResponseRedirect(next)#reverse('document_view', args=[document.pk]))
|
||||
|
||||
context = {
|
||||
'object_name':_(u'document transformation'),
|
||||
'delete_view':True,
|
||||
'object':document,
|
||||
'title':_(u'Are you sure you with to clear all the page transformations for document: %s?') % document,
|
||||
#'object':document,
|
||||
'previous':previous,
|
||||
}, context_instance=RequestContext(request))
|
||||
'next':next,
|
||||
}
|
||||
|
||||
if len(documents) == 1:
|
||||
context['object'] = documents[0]
|
||||
context['title'] = _(u'Are you sure you with to clear all the page transformations for document: %s?') % ', '.join([unicode(d) for d in documents])
|
||||
elif len(documents) > 1:
|
||||
context['title'] = _(u'Are you sure you with to clear all the page transformations for documents: %s?') % ', '.join([unicode(d) for d in documents])
|
||||
|
||||
|
||||
return render_to_response('generic_confirm.html', context,
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def document_view_simple(request, document_id):
|
||||
|
||||
Reference in New Issue
Block a user