Commit b929fc50 authored by Serge S. Koval's avatar Serge S. Koval

Merge pull request #1025 from pawl/fix_action_return

Return user to filtered list view after action
parents 45e2b81e e87c4302
......@@ -3,6 +3,7 @@ from flask import request, redirect
from flask_admin import tools
from flask_admin._compat import text_type
from flask_admin.helpers import get_redirect_target
def action(name, text, confirmation=None):
......@@ -100,7 +101,8 @@ class ActionsMixin(object):
:param return_view:
Name of the view to return to after the request.
If not provided, will return user to the index view.
If not provided, will return user to the return url in the form
or the list view.
"""
action = request.form.get('action')
ids = request.form.getlist('rowid')
......@@ -113,9 +115,9 @@ class ActionsMixin(object):
if response is not None:
return response
if not return_view:
url = self.get_url('.' + self._default_view)
else:
if return_view:
url = self.get_url('.' + return_view)
else:
url = get_redirect_target() or self.get_url('.index_view')
return redirect(url)
......@@ -17,6 +17,7 @@
{% if csrf_token %}
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
{% endif %}
<input type="hidden" name="url" value="{{ return_url }}">
<input type="hidden" id="action" name="action" />
</form>
{% endif %}
......
......@@ -17,6 +17,7 @@
{% if csrf_token %}
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
{% endif %}
<input type="hidden" name="url" value="{{ return_url }}">
<input type="hidden" id="action" name="action" />
</form>
{% endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment