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:
@@ -135,16 +135,14 @@ class DocumentStatesApp(MayanAppConfig):
|
||||
SourceColumn(
|
||||
attribute='label', is_identifier=True, source=Workflow
|
||||
)
|
||||
SourceColumn(
|
||||
attribute='internal_name', source=Workflow
|
||||
)
|
||||
SourceColumn(
|
||||
attribute='get_initial_state', source=Workflow,
|
||||
)
|
||||
SourceColumn(attribute='internal_name', source=Workflow)
|
||||
SourceColumn(attribute='get_initial_state', source=Workflow)
|
||||
|
||||
SourceColumn(
|
||||
attribute='get_current_state', source=WorkflowInstance
|
||||
attribute='workflow', is_identifier=True,
|
||||
source=WorkflowInstance
|
||||
)
|
||||
SourceColumn(attribute='get_current_state', source=WorkflowInstance)
|
||||
SourceColumn(
|
||||
attribute='get_last_transition_user', source=WorkflowInstance
|
||||
)
|
||||
@@ -163,57 +161,40 @@ class DocumentStatesApp(MayanAppConfig):
|
||||
SourceColumn(
|
||||
attribute='get_rendered_datetime', source=WorkflowInstanceLogEntry
|
||||
)
|
||||
SourceColumn(
|
||||
attribute='user', source=WorkflowInstanceLogEntry
|
||||
)
|
||||
SourceColumn(
|
||||
attribute='transition', source=WorkflowInstanceLogEntry
|
||||
)
|
||||
SourceColumn(
|
||||
attribute='comment', source=WorkflowInstanceLogEntry
|
||||
)
|
||||
SourceColumn(attribute='user', source=WorkflowInstanceLogEntry)
|
||||
SourceColumn(attribute='transition', source=WorkflowInstanceLogEntry)
|
||||
SourceColumn(attribute='comment', source=WorkflowInstanceLogEntry)
|
||||
|
||||
SourceColumn(
|
||||
source=WorkflowState, label=_('Is initial state?'),
|
||||
func=lambda context: TwoStateWidget(
|
||||
state=context['object'].initial
|
||||
).render()
|
||||
attribute='label', is_identifier=True, source=WorkflowState
|
||||
)
|
||||
SourceColumn(
|
||||
source=WorkflowState, label=_('Completion'), attribute='completion'
|
||||
attribute='initial', source=WorkflowState, widget=TwoStateWidget
|
||||
)
|
||||
SourceColumn(attribute='completion', source=WorkflowState)
|
||||
|
||||
SourceColumn(
|
||||
source=WorkflowStateAction, label=_('Label'), attribute='label'
|
||||
attribute='label', is_identifier=True, source=WorkflowStateAction
|
||||
)
|
||||
SourceColumn(
|
||||
source=WorkflowStateAction, label=_('Enabled?'),
|
||||
func=lambda context: TwoStateWidget(
|
||||
state=context['object'].enabled
|
||||
).render()
|
||||
attribute='enabled', source=WorkflowStateAction,
|
||||
widget=TwoStateWidget
|
||||
)
|
||||
SourceColumn(
|
||||
source=WorkflowStateAction, label=_('When?'),
|
||||
attribute='get_when_display'
|
||||
)
|
||||
SourceColumn(
|
||||
source=WorkflowStateAction, label=_('Action type'),
|
||||
attribute='get_class_label'
|
||||
attribute='get_when_display', label=_('When?'),
|
||||
source=WorkflowStateAction
|
||||
)
|
||||
SourceColumn(attribute='get_class_label', source=WorkflowStateAction)
|
||||
|
||||
SourceColumn(
|
||||
source=WorkflowTransition, label=_('Origin state'),
|
||||
attribute='origin_state'
|
||||
attribute='label', is_identifier=True, source=WorkflowTransition
|
||||
)
|
||||
SourceColumn(attribute='origin_state', source=WorkflowTransition)
|
||||
SourceColumn(attribute='destination_state', source=WorkflowTransition)
|
||||
SourceColumn(
|
||||
source=WorkflowTransition, label=_('Destination state'),
|
||||
attribute='destination_state'
|
||||
)
|
||||
SourceColumn(
|
||||
source=WorkflowTransition, label=_('Triggers'),
|
||||
func=lambda context: widget_transition_events(
|
||||
transition=context['object']
|
||||
)
|
||||
), label=_('Triggers'), source=WorkflowTransition
|
||||
)
|
||||
|
||||
app.conf.task_queues.extend(
|
||||
|
||||
@@ -318,6 +318,7 @@ class WorkflowStateAction(models.Model):
|
||||
|
||||
def get_class_label(self):
|
||||
return self.get_class().label
|
||||
get_class_label.short_description = _('Action type')
|
||||
|
||||
def loads(self):
|
||||
return json.loads(self.action_data)
|
||||
|
||||
@@ -62,7 +62,7 @@ class DocumentWorkflowInstanceListView(SingleObjectListView):
|
||||
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'hide_link': True,
|
||||
'hide_object': True,
|
||||
'no_results_icon': icon_workflow_list,
|
||||
'no_results_text': _(
|
||||
'Assign workflows to the document type of this document '
|
||||
@@ -96,6 +96,13 @@ class WorkflowInstanceDetailView(SingleObjectListView):
|
||||
return {
|
||||
'hide_object': True,
|
||||
'navigation_object_list': ('object', 'workflow_instance'),
|
||||
'no_results_text': _(
|
||||
'This view will show the states changed as a workflow '
|
||||
'instance is transitioned.'
|
||||
),
|
||||
'no_results_title': _(
|
||||
'There are no details for this workflow instance'
|
||||
),
|
||||
'object': self.get_workflow_instance().document,
|
||||
'title': _('Detail of workflow: %(workflow)s') % {
|
||||
'workflow': self.get_workflow_instance()
|
||||
@@ -509,7 +516,7 @@ class SetupWorkflowStateListView(SingleObjectListView):
|
||||
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'hide_link': True,
|
||||
'hide_object': True,
|
||||
'no_results_icon': icon_workflow_state,
|
||||
'no_results_main_link': link_setup_workflow_state_create.resolve(
|
||||
context=RequestContext(
|
||||
@@ -624,7 +631,7 @@ class SetupWorkflowTransitionListView(SingleObjectListView):
|
||||
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'hide_link': True,
|
||||
'hide_object': True,
|
||||
'no_results_icon': icon_workflow_transition,
|
||||
'no_results_main_link': link_setup_workflow_transition_create.resolve(
|
||||
context=RequestContext(
|
||||
|
||||
Reference in New Issue
Block a user