From 1103b09a767936f69c02c5714717cf5d1d28bee9 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 13 Apr 2024 09:45:10 -0500 Subject: [PATCH] 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..? --- tailbone/forms/core.py | 17 ++++++++--------- tailbone/templates/batch/view.mako | 4 ++-- tailbone/templates/form.mako | 2 +- .../forms/{deform_buefy.mako => deform.mako} | 0 tailbone/templates/forms/form.mako | 2 -- tailbone/templates/products/batch.mako | 2 +- 6 files changed, 12 insertions(+), 15 deletions(-) rename tailbone/templates/forms/{deform_buefy.mako => deform.mako} (100%) delete mode 100644 tailbone/templates/forms/form.mako diff --git a/tailbone/forms/core.py b/tailbone/forms/core.py index e04126a3..aee85330 100644 --- a/tailbone/forms/core.py +++ b/tailbone/forms/core.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2023 Lance Edgar +# Copyright © 2010-2024 Lance Edgar # # This file is part of Rattail. # @@ -794,12 +794,11 @@ class Form(object): def set_vuejs_field_converter(self, field, converter): self.vuejs_field_converters[field] = converter - def render(self, template=None, **kwargs): - if not template: - template = '/forms/form.mako' - context = kwargs - context['form'] = self - return render(template, context) + def render(self, **kwargs): + warnings.warn("Form.render() is deprecated (for now?); " + "please use Form.render_deform() instead", + DeprecationWarning, stacklevel=2) + return self.render_deform(**kwargs) def make_deform_form(self): if not hasattr(self, 'deform_form'): @@ -841,14 +840,14 @@ class Form(object): def render_deform(self, dform=None, template=None, **kwargs): if not template: - template = '/forms/deform_buefy.mako' + template = '/forms/deform.mako' if dform is None: dform = self.make_deform_form() # TODO: would perhaps be nice to leverage deform's default rendering # someday..? i.e. using Chameleon *.pt templates - # return form.render() + # return dform.render() context = kwargs context['form'] = self diff --git a/tailbone/templates/batch/view.mako b/tailbone/templates/batch/view.mako index fa8fa19f..aa9677b7 100644 --- a/tailbone/templates/batch/view.mako +++ b/tailbone/templates/batch/view.mako @@ -150,8 +150,8 @@ <%def name="render_form()"> ## TODO: should use self.render_form_buttons() - ## ${form.render(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(self.render_form_buttons))|n} + ${form.render_deform(form_id='batch-form', buttons=capture(buttons))|n} <%def name="render_this_page()"> diff --git a/tailbone/templates/form.mako b/tailbone/templates/form.mako index 5878e030..c225bd3a 100644 --- a/tailbone/templates/form.mako +++ b/tailbone/templates/form.mako @@ -6,7 +6,7 @@ <%def name="render_form_buttons()"> <%def name="render_form()"> - ${form.render(buttons=capture(self.render_form_buttons))|n} + ${form.render_deform(buttons=capture(self.render_form_buttons))|n} <%def name="render_buefy_form()"> diff --git a/tailbone/templates/forms/deform_buefy.mako b/tailbone/templates/forms/deform.mako similarity index 100% rename from tailbone/templates/forms/deform_buefy.mako rename to tailbone/templates/forms/deform.mako diff --git a/tailbone/templates/forms/form.mako b/tailbone/templates/forms/form.mako deleted file mode 100644 index cd8fecc8..00000000 --- a/tailbone/templates/forms/form.mako +++ /dev/null @@ -1,2 +0,0 @@ -## -*- coding: utf-8; -*- -${form.render_deform(buttons=buttons)|n} diff --git a/tailbone/templates/products/batch.mako b/tailbone/templates/products/batch.mako index 81af729b..868ad9b1 100644 --- a/tailbone/templates/products/batch.mako +++ b/tailbone/templates/products/batch.mako @@ -64,7 +64,7 @@ ${parent.modify_this_page_vars()}