Skip to content

Commit

Permalink
ensure grid header posts are supported
Browse files Browse the repository at this point in the history
  • Loading branch information
guruofgentoo committed Sep 13, 2021
1 parent 39335bc commit e0638dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions keg_auth/tests/test_views.py
Expand Up @@ -8,6 +8,7 @@
from keg.db import db
import pytest
import sqlalchemy as sa
from webgrid.extensions import RequestArgsLoader, RequestFormLoader
from werkzeug.datastructures import MultiDict
from keg_auth_ta.app import mail_ext
from keg_auth.libs.decorators import requires_user
Expand Down Expand Up @@ -938,6 +939,20 @@ def test_list_alternate_ident_field(self):
assert resp.pyquery('.datagrid table.records thead th').eq(1).text() == 'User ID'
assert resp.pyquery('.datagrid table.records tbody td').eq(1).text() == user.username

@mock.patch('keg_auth_ta.extensions.Grid.manager.args_loaders',
[RequestArgsLoader, RequestFormLoader])
def test_list_post(self):
resp = self.client.get('/users')
form = resp.forms[0]
assert form.method == 'post'
resp = form.submit()
assert resp.status_code == 302
assert '/users' in resp.location

@mock.patch('keg_auth_ta.extensions.Grid.manager.args_loaders', [RequestArgsLoader])
def test_list_post_no_form_loader(self):
self.client.post('/users', status=400)

def test_list_export(self):
ents.User.testing_create()
resp = self.client.get('/users?export_to=xlsx')
Expand Down
3 changes: 3 additions & 0 deletions keg_auth/views.py
Expand Up @@ -342,6 +342,9 @@ def render_grid(self):
grid = self.make_grid()
grid = self.post_args_grid_setup(grid)

if grid.session_on and flask.request.method.lower() == 'post':
return flask.redirect(self.list_url_with_session)

if grid.export_to:
import webgrid

Expand Down

0 comments on commit e0638dc

Please sign in to comment.