Allow passing id_lists from POST requests

Normally the MultipleObjectMixin class view only allows
id_list from the GET request. This is updated to allow
that query from POST requests like those produced by the
view tests.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-01-29 04:30:32 -04:00
parent fcfe7686fa
commit b4188de727

View File

@@ -284,7 +284,12 @@ class MultipleObjectMixin(SingleObjectMixin):
return queryset
def get_pk_list(self):
result = self.request.GET.get(self.pk_list_key)
# Accept pk_list even on POST request to allowing direct requests
# to the view bypassing the initial GET request to submit the form.
# Example: when the view is called from a test or a custom UI
result = self.request.GET.get(
self.pk_list_key, self.request.POST.get(self.pk_list_key)
)
if result:
return result.split(self.pk_list_separator)
@@ -316,7 +321,7 @@ class ObjectActionMixin(object):
def view_action(self, form=None):
self.action_count = 0
for instance in self.get_queryset():
for instance in self.get_object_list():
try:
self.object_action(form=form, instance=instance)
except PermissionDenied: