Use label handler to avoid deprecated logic

This commit is contained in:
Lance Edgar 2023-02-08 20:19:15 -06:00
parent 32fc0415da
commit ad5dec3dc6
2 changed files with 9 additions and 2 deletions

View file

@ -35,7 +35,7 @@
% for name, display in printer.required_settings.items(): % for name, display in printer.required_settings.items():
<div class="field-wrapper"> <div class="field-wrapper">
<label>${display}</label> <label>${display}</label>
<div class="field">${instance.get_printer_setting(name) or ''}</div> <div class="field">${label_handler.get_printer_setting(instance, name) or ''}</div>
</div> </div>
% endfor % endfor
</div> </div>

View file

@ -78,6 +78,13 @@ class LabelProfileView(MasterView):
# format # format
f.set_type('format', 'codeblock') f.set_type('format', 'codeblock')
def template_kwargs_view(self, **kwargs):
kwargs = super(LabelProfileView, self).template_kwargs_view(**kwargs)
kwargs['label_handler'] = self.label_handler
return kwargs
def after_create(self, profile): def after_create(self, profile):
self.after_edit(profile) self.after_edit(profile)
@ -97,7 +104,7 @@ class LabelProfileView(MasterView):
node = colander.SchemaNode(colander.String(), node = colander.SchemaNode(colander.String(),
name=name, name=name,
title=label, title=label,
default=profile.get_printer_setting(name)) default=self.label_handler.get_printer_setting(profile, name))
schema.add(node) schema.add(node)
form = forms.Form(schema=schema, request=self.request, form = forms.Form(schema=schema, request=self.request,