Skip to content

Commit

Permalink
fixes #64 Export not working when actions enabled on top & bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
sax committed May 28, 2015
1 parent 07528c9 commit 04f0d1a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions adminactions/export.py
Expand Up @@ -22,6 +22,14 @@
from six.moves import zip


def get_action(request):
try:
action_index = int(request.POST.get('index', 0))
except ValueError:
action_index = 0
return request.POST.getlist('action')[action_index]


def base_export(modeladmin, request, queryset, title, impl, name, template, form_class, ):
"""
export a queryset to csv file
Expand All @@ -45,7 +53,7 @@ def base_export(modeladmin, request, queryset, title, impl, name, template, form
cols = [(f.name, f.verbose_name) for f in queryset.model._meta.fields]
initial = {'_selected_action': request.POST.getlist(helpers.ACTION_CHECKBOX_NAME),
'select_across': request.POST.get('select_across') == '1',
'action': request.POST.get('action'),
'action': get_action(request),
'columns': [x for x, v in cols]}
# initial.update(csv_options_default)

Expand Down Expand Up @@ -205,7 +213,8 @@ def _dump_qs(form, queryset, data, filename):
def export_as_fixture(modeladmin, request, queryset):
initial = {'_selected_action': request.POST.getlist(helpers.ACTION_CHECKBOX_NAME),
'select_across': request.POST.get('select_across') == '1',
'action': request.POST.get('action'),
'action': get_action(request),

'serializer': 'json',
'indent': 4}
opts = modeladmin.model._meta
Expand Down Expand Up @@ -302,7 +311,8 @@ def export_delete_tree(modeladmin, request, queryset):

initial = {'_selected_action': request.POST.getlist(helpers.ACTION_CHECKBOX_NAME),
'select_across': request.POST.get('select_across') == '1',
'action': request.POST.get('action'),
'action': get_action(request),

'serializer': 'json',
'indent': 4}

Expand Down

0 comments on commit 04f0d1a

Please sign in to comment.