fix: rename MasterView method to configure_grid()
still not 100% sure about this, `index_configure_grid()` is more explicit, but this will be a common method to override so probably the shorter name is better
This commit is contained in:
parent
e0de4e9a65
commit
9e1fc6e57d
|
@ -245,7 +245,7 @@ class MasterView(View):
|
|||
* :meth:`get_grid_key()`
|
||||
* :meth:`index_get_grid_columns()`
|
||||
* :meth:`index_get_grid_data()`
|
||||
* :meth:`index_configure_grid()`
|
||||
* :meth:`configure_grid()`
|
||||
"""
|
||||
if 'key' not in kwargs:
|
||||
kwargs['key'] = self.get_grid_key()
|
||||
|
@ -267,7 +267,7 @@ class MasterView(View):
|
|||
kwargs['actions'] = actions
|
||||
|
||||
grid = self.make_grid(**kwargs)
|
||||
self.index_configure_grid(grid)
|
||||
self.configure_grid(grid)
|
||||
return grid
|
||||
|
||||
def index_get_grid_columns(self):
|
||||
|
@ -285,12 +285,12 @@ class MasterView(View):
|
|||
Subclass may define :attr:`grid_columns` for simple cases, or
|
||||
can override this method if needed.
|
||||
|
||||
Also note that :meth:`index_configure_grid()` may be used to
|
||||
further modify the final column set, regardless of what this
|
||||
method returns. So a common pattern is to declare all
|
||||
"supported" columns by setting :attr:`grid_columns` but then
|
||||
optionally remove or replace some of those within
|
||||
:meth:`index_configure_grid()`.
|
||||
Also note that :meth:`configure_grid()` may be used to further
|
||||
modify the final column set, regardless of what this method
|
||||
returns. So a common pattern is to declare all "supported"
|
||||
columns by setting :attr:`grid_columns` but then optionally
|
||||
remove or replace some of those within
|
||||
:meth:`configure_grid()`.
|
||||
"""
|
||||
if hasattr(self, 'grid_columns'):
|
||||
return self.grid_columns
|
||||
|
@ -324,18 +324,6 @@ class MasterView(View):
|
|||
|
||||
return self.request.route_url(f'{route_prefix}.view', **kw)
|
||||
|
||||
def index_configure_grid(self, grid):
|
||||
"""
|
||||
Configure the grid for the :meth:`index()` view.
|
||||
|
||||
This is called by :meth:`index_make_grid()`.
|
||||
|
||||
There is no default logic here; subclass should override as
|
||||
needed. The ``grid`` param will already be "complete" and
|
||||
ready to use as-is, but this method can further modify it
|
||||
based on request details etc.
|
||||
"""
|
||||
|
||||
##############################
|
||||
# view methods
|
||||
##############################
|
||||
|
@ -758,6 +746,21 @@ class MasterView(View):
|
|||
route_prefix = self.get_route_prefix()
|
||||
return self.request.route_url(route_prefix, **kwargs)
|
||||
|
||||
def configure_grid(self, grid):
|
||||
"""
|
||||
Configure the grid for the :meth:`index()` view.
|
||||
|
||||
This is called by :meth:`index_make_grid()`.
|
||||
|
||||
There is no default logic here; subclass should override as
|
||||
needed. The ``grid`` param will already be "complete" and
|
||||
ready to use as-is, but this method can further modify it
|
||||
based on request details etc.
|
||||
"""
|
||||
for key in self.get_model_key():
|
||||
grid.set_link(key)
|
||||
# print("set link:", key)
|
||||
|
||||
def get_instance(self):
|
||||
"""
|
||||
This should return the "current" model instance based on the
|
||||
|
|
Loading…
Reference in a new issue