Add make_status_renderer()
to MasterView
batches aren't the only table/view where a status code/text combo may be in use
This commit is contained in:
parent
871ea84f96
commit
ed0a1f2740
|
@ -419,17 +419,6 @@ class BatchMasterView(MasterView):
|
|||
f.remove_fields('executed',
|
||||
'executed_by')
|
||||
|
||||
def make_status_renderer(self, enum):
|
||||
def render_status(batch, field):
|
||||
value = batch.status_code
|
||||
if value is None:
|
||||
return ""
|
||||
status_code_text = enum.get(value, six.text_type(value))
|
||||
if batch.status_text:
|
||||
return HTML.tag('span', title=batch.status_text, c=status_code_text)
|
||||
return status_code_text
|
||||
return render_status
|
||||
|
||||
def render_complete(self, batch, field):
|
||||
permission_prefix = self.get_permission_prefix()
|
||||
use_buefy = self.get_use_buefy()
|
||||
|
|
|
@ -953,6 +953,24 @@ class MasterView(View):
|
|||
|
||||
return email_key
|
||||
|
||||
def make_status_renderer(self, enum):
|
||||
"""
|
||||
Creates and returns a function for use with rendering a
|
||||
"status combo" field(s) for a record. Assumes the record has
|
||||
both ``status_code`` and ``status_text`` fields, as batches
|
||||
do. Renders the simple status code text, and if custom status
|
||||
text is present, it is rendered as a tooltip.
|
||||
"""
|
||||
def render_status(obj, field):
|
||||
value = obj.status_code
|
||||
if value is None:
|
||||
return ""
|
||||
status_code_text = enum.get(value, six.text_type(value))
|
||||
if obj.status_text:
|
||||
return HTML.tag('span', title=obj.status_text, c=status_code_text)
|
||||
return status_code_text
|
||||
return render_status
|
||||
|
||||
def before_create_flush(self, obj, form):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in a new issue