Add docs for MasterView.help_url and get_help_url()

This commit is contained in:
Lance Edgar 2018-05-21 15:27:22 -05:00
parent e5ffe3025b
commit db25a5bfd0
2 changed files with 31 additions and 8 deletions

View file

@ -68,10 +68,21 @@ override when defining your subclass.
Factory callable to be used when creating new grid instances; defaults to Factory callable to be used when creating new grid instances; defaults to
:class:`tailbone.grids.Grid`. :class:`tailbone.grids.Grid`.
.. Methods to Override .. attribute:: MasterView.help_url
.. -------------------
.. If set, this defines the "default" help URL for all views provided by the
.. The following is a list of methods which you can override when defining your master. Default value for this is simply ``None`` which would mean the
.. subclass. Help button is not shown at all. Note that the master may choose to
.. override this for certain views, if so that should be done within
.. .. automethod:: MasterView.get_settings :meth:`get_help_url()`.
Methods to Override
-------------------
The following is a list of methods which you can override when defining your
subclass.
.. .. automethod:: MasterView.get_settings
.. automethod:: MasterView.get_help_url

View file

@ -107,6 +107,7 @@ class MasterView(View):
use_index_links = False use_index_links = False
has_versions = False has_versions = False
help_url = None
labels = {'uuid': "UUID"} labels = {'uuid': "UUID"}
@ -1693,7 +1694,18 @@ class MasterView(View):
return self.request.route_url('{}.{}'.format(route_prefix, action), **kw) return self.request.route_url('{}.{}'.format(route_prefix, action), **kw)
def get_help_url(self): def get_help_url(self):
return getattr(self, 'help_url', None) """
May return a "help URL" if applicable. Default behavior is to simply
return the value of :attr:`help_url` (regardless of which view is in
effect), which in turn defaults to ``None``. If an actual URL is
returned, then a Help button will be shown in the page header;
otherwise it is not shown.
This method is invoked whenever a template is rendered for a response,
so if you like you can return a different help URL depending on which
type of CRUD view is in effect, etc.
"""
return self.help_url
def render_to_response(self, template, data, mobile=False): def render_to_response(self, template, data, mobile=False):
""" """