Add basic support for managing, and accepting API tokens

also various other changes in pursuit of that.  so far tokens are only
accepted by web API and not traditional web app
This commit is contained in:
Lance Edgar 2023-05-14 20:10:05 -05:00
parent 85947878c4
commit c002d3d182
9 changed files with 318 additions and 26 deletions

View file

@ -338,7 +338,7 @@ class Form(object):
assume_local_times=False, renderers=None, renderer_kwargs={},
hidden={}, widgets={}, defaults={}, validators={}, required={}, helptext={}, focus_spec=None,
action_url=None, cancel_url=None, component='tailbone-form',
vuejs_field_converters={},
vuejs_component_kwargs=None, vuejs_field_converters={},
# TODO: ugh this is getting out hand!
can_edit_help=False, edit_help_url=None, route_prefix=None,
):
@ -379,6 +379,7 @@ class Form(object):
self.action_url = action_url
self.cancel_url = cancel_url
self.component = component
self.vuejs_component_kwargs = vuejs_component_kwargs or {}
self.vuejs_field_converters = vuejs_field_converters or {}
self.can_edit_help = can_edit_help
self.edit_help_url = edit_help_url
@ -913,6 +914,25 @@ class Form(object):
return False
return True
def set_vuejs_component_kwargs(self, **kwargs):
self.vuejs_component_kwargs.update(kwargs)
def render_vuejs_component(self):
"""
Render the Vue.js component HTML for the form.
Most typically this is something like:
.. code-block:: html
<tailbone-form :configure-fields-help="configureFieldsHelp">
</tailbone-form>
"""
kwargs = dict(self.vuejs_component_kwargs)
if self.can_edit_help:
kwargs.setdefault(':configure-fields-help', 'configureFieldsHelp')
return HTML.tag(self.component, **kwargs)
def render_buefy_field(self, fieldname, bfield_attrs={}):
"""
Render the given field in a Buefy-compatible way. Note that