Created
August 22, 2017 20:17
-
-
Save hbradio/ef1ef6d47de5a1c8964e294d94c0535f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GridView(BaseView): | |
grid_cls = None | |
template = 'grid-view.html' | |
title = None | |
def get(self): | |
return self.render_grid() | |
def render_grid(self): | |
if self.grid_cls is None: | |
raise NotImplementedError( | |
'You must set {}.grid_cls to render a grid'.format(self.__class__.__name__) | |
) | |
g = self.grid_cls() | |
g.apply_qs_args() | |
if hasattr(self, 'setup_grid'): | |
self.setup_grid(g) | |
if g.export_to == 'xls': | |
raise ImmediateResponse(g.xls.as_response()) | |
template_args = { | |
'grid': g, | |
'title': self.title, | |
} | |
return flask.render_template( | |
self.template, | |
**template_args | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment