Add widget support to SourceColumn
Allow passing a widget class to SourceColumn. This makes using lambdas to render model column unnecesary and are mostly removed too. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -89,18 +89,17 @@ class TextAreaDiv(forms.widgets.Widget):
|
||||
|
||||
|
||||
class TwoStateWidget(object):
|
||||
def __init__(self, state, center=False, icon_ok=None, icon_fail=None):
|
||||
self.state = state
|
||||
def __init__(self, center=False, icon_ok=None, icon_fail=None):
|
||||
self.icon_ok = icon_ok or default_icon_ok
|
||||
self.icon_fail = icon_fail or default_icon_fail
|
||||
self.center = center
|
||||
|
||||
def render(self):
|
||||
def render(self, name=None, value=None):
|
||||
center_class = ''
|
||||
if self.center:
|
||||
center_class = 'text-center'
|
||||
|
||||
if self.state:
|
||||
if value:
|
||||
return mark_safe(
|
||||
'<div class="{} text-success">{}</div>'.format(
|
||||
center_class, self.icon_ok.render()
|
||||
|
||||
Reference in New Issue
Block a user