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:
Roberto Rosario
2018-12-22 05:35:31 -04:00
parent 360e756093
commit 64e1c6bb67
59 changed files with 450 additions and 402 deletions

View File

@@ -57,28 +57,22 @@ class LinkingApp(MayanAppConfig):
)
SourceColumn(
source=ResolvedSmartLink, label=_('Label'),
func=lambda context: context['object'].get_label_for(
document=context['document']
)
), label=_('Label'), source=ResolvedSmartLink
)
SourceColumn(
source=SmartLink, label=_('Dynamic label'),
attribute='dynamic_label'
attribute='label', is_identifier=True, source=SmartLink
)
SourceColumn(attribute='dynamic_label', source=SmartLink)
SourceColumn(
source=SmartLink, label=_('Enabled'),
func=lambda context: TwoStateWidget(
state=context['object'].enabled
).render()
attribute='enabled', source=SmartLink, widget=TwoStateWidget
)
SourceColumn(
source=SmartLinkCondition, label=_('Enabled'),
func=lambda context: TwoStateWidget(
state=context['object'].enabled
).render()
attribute='enabled', source=SmartLinkCondition,
widget=TwoStateWidget
)
menu_facet.bind_links(

View File

@@ -139,7 +139,7 @@ class SmartLinkListView(SingleObjectListView):
def get_extra_context(self):
return {
'hide_link': True,
'hide_object': True,
'no_results_icon': icon_smart_link_setup,
'no_results_main_link': link_smart_link_create.resolve(
context=RequestContext(request=self.request)