Skip to content

Commit

Permalink
Merge pull request pallets-eco#1025 from pawl/fix_action_return
Browse files Browse the repository at this point in the history
Return user to filtered list view after action
  • Loading branch information
mrjoes committed Aug 26, 2015
2 parents 45e2b81 + e87c430 commit b929fc5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions flask_admin/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

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):
Expand Down Expand Up @@ -100,7 +101,8 @@ def handle_action(self, return_view=None):
: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')
Expand All @@ -113,9 +115,9 @@ def handle_action(self, return_view=None):
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)
1 change: 1 addition & 0 deletions flask_admin/templates/bootstrap2/admin/actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
1 change: 1 addition & 0 deletions flask_admin/templates/bootstrap3/admin/actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down

0 comments on commit b929fc5

Please sign in to comment.