Rename forms/deform template (drop buefy suffix)

for now, deprecate `form.render()` method and just use
`render_deform()` - but probably should change that to something
else eventually..?
This commit is contained in:
Lance Edgar 2024-04-13 09:45:10 -05:00
parent cd7c1bba21
commit 1103b09a76
6 changed files with 12 additions and 15 deletions

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2023 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -794,12 +794,11 @@ class Form(object):
def set_vuejs_field_converter(self, field, converter): def set_vuejs_field_converter(self, field, converter):
self.vuejs_field_converters[field] = converter self.vuejs_field_converters[field] = converter
def render(self, template=None, **kwargs): def render(self, **kwargs):
if not template: warnings.warn("Form.render() is deprecated (for now?); "
template = '/forms/form.mako' "please use Form.render_deform() instead",
context = kwargs DeprecationWarning, stacklevel=2)
context['form'] = self return self.render_deform(**kwargs)
return render(template, context)
def make_deform_form(self): def make_deform_form(self):
if not hasattr(self, 'deform_form'): if not hasattr(self, 'deform_form'):
@ -841,14 +840,14 @@ class Form(object):
def render_deform(self, dform=None, template=None, **kwargs): def render_deform(self, dform=None, template=None, **kwargs):
if not template: if not template:
template = '/forms/deform_buefy.mako' template = '/forms/deform.mako'
if dform is None: if dform is None:
dform = self.make_deform_form() dform = self.make_deform_form()
# TODO: would perhaps be nice to leverage deform's default rendering # TODO: would perhaps be nice to leverage deform's default rendering
# someday..? i.e. using Chameleon *.pt templates # someday..? i.e. using Chameleon *.pt templates
# return form.render() # return dform.render()
context = kwargs context = kwargs
context['form'] = self context['form'] = self

View file

@ -150,8 +150,8 @@
<%def name="render_form()"> <%def name="render_form()">
## TODO: should use self.render_form_buttons() ## TODO: should use self.render_form_buttons()
## ${form.render(form_id='batch-form', buttons=capture(self.render_form_buttons))|n} ## ${form.render_deform(form_id='batch-form', buttons=capture(self.render_form_buttons))|n}
${form.render(form_id='batch-form', buttons=capture(buttons))|n} ${form.render_deform(form_id='batch-form', buttons=capture(buttons))|n}
</%def> </%def>
<%def name="render_this_page()"> <%def name="render_this_page()">

View file

@ -6,7 +6,7 @@
<%def name="render_form_buttons()"></%def> <%def name="render_form_buttons()"></%def>
<%def name="render_form()"> <%def name="render_form()">
${form.render(buttons=capture(self.render_form_buttons))|n} ${form.render_deform(buttons=capture(self.render_form_buttons))|n}
</%def> </%def>
<%def name="render_buefy_form()"> <%def name="render_buefy_form()">

View file

@ -1,2 +0,0 @@
## -*- coding: utf-8; -*-
${form.render_deform(buttons=buttons)|n}

View file

@ -64,7 +64,7 @@
${parent.modify_this_page_vars()} ${parent.modify_this_page_vars()}
<script type="text/javascript"> <script type="text/javascript">
## TODO: ugh, an awful lot of duplicated code here (from /forms/deform_buefy.mako) ## TODO: ugh, an awful lot of duplicated code here (from /forms/deform.mako)
let ${form.component_studly} = { let ${form.component_studly} = {
template: '#${form.component}-template', template: '#${form.component}-template',