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:
@@ -12,6 +12,7 @@ from mayan.apps.acls.permissions import (
|
||||
from mayan.apps.common import (
|
||||
MayanAppConfig, menu_list_facet, menu_object, menu_secondary, menu_setup
|
||||
)
|
||||
from mayan.apps.common.widgets import TwoStateWidget
|
||||
from mayan.apps.navigation import SourceColumn
|
||||
|
||||
from .links import (
|
||||
@@ -45,16 +46,18 @@ class MOTDApp(MayanAppConfig):
|
||||
permission_message_view
|
||||
)
|
||||
)
|
||||
|
||||
SourceColumn(
|
||||
source=Message, label=_('Enabled'), attribute='enabled'
|
||||
attribute='label', is_identifier=True, source=Message
|
||||
)
|
||||
SourceColumn(
|
||||
source=Message, label=_('Start date time'),
|
||||
func=lambda context: context['object'].start_datetime or _('None')
|
||||
attribute='enabled', source=Message, widget=TwoStateWidget
|
||||
)
|
||||
SourceColumn(
|
||||
source=Message, label=_('End date time'),
|
||||
func=lambda context: context['object'].end_datetime or _('None')
|
||||
attribute='start_datetime', empty_value=_('None'), source=Message
|
||||
)
|
||||
SourceColumn(
|
||||
attribute='end_datetime', empty_value=_('None'), source=Message
|
||||
)
|
||||
|
||||
menu_list_facet.bind_links(
|
||||
|
||||
@@ -65,7 +65,7 @@ class MessageListView(SingleObjectListView):
|
||||
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'hide_link': True,
|
||||
'hide_object': True,
|
||||
'no_results_icon': icon_message_list,
|
||||
'no_results_main_link': link_message_create.resolve(
|
||||
context=RequestContext(request=self.request)
|
||||
|
||||
Reference in New Issue
Block a user