diff --git a/CHANGES_BC.rst b/CHANGES_BC.rst index 16c71c7b60..8fb85ef407 100644 --- a/CHANGES_BC.rst +++ b/CHANGES_BC.rst @@ -4,3 +4,4 @@ workflow state. - Sort module. - Add link to sort individual indexes. +- Support exclusions from source columns. diff --git a/mayan/apps/document_indexing/apps.py b/mayan/apps/document_indexing/apps.py index 0d4c141ecf..586b7246bd 100644 --- a/mayan/apps/document_indexing/apps.py +++ b/mayan/apps/document_indexing/apps.py @@ -106,11 +106,12 @@ class DocumentIndexingApp(MayanAppConfig): source=Index ) SourceColumn( - attribute='slug', is_sortable=True, source=Index + attribute='slug', exclude=(IndexInstance,), is_sortable=True, + source=Index ) SourceColumn( - attribute='enabled', is_sortable=True, source=Index, - widget=TwoStateWidget + attribute='enabled', exclude=(IndexInstance,), is_sortable=True, + source=Index, widget=TwoStateWidget ) SourceColumn( diff --git a/mayan/apps/document_states/apps.py b/mayan/apps/document_states/apps.py index dff0c11b27..f7e02372d9 100644 --- a/mayan/apps/document_states/apps.py +++ b/mayan/apps/document_states/apps.py @@ -161,7 +161,8 @@ class DocumentStatesApp(MayanAppConfig): attribute='label', is_sortable=True, source=Workflow ) SourceColumn( - attribute='internal_name', is_sortable=True, source=Workflow + attribute='internal_name', exclude=(WorkflowRuntimeProxy,), + is_sortable=True, source=Workflow ) SourceColumn( attribute='get_initial_state', empty_value=_('None'), diff --git a/mayan/apps/navigation/classes.py b/mayan/apps/navigation/classes.py index d51c3db2d8..2e637e30bf 100644 --- a/mayan/apps/navigation/classes.py +++ b/mayan/apps/navigation/classes.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals +import copy import inspect import logging @@ -615,6 +616,11 @@ class SourceColumn(object): except (AttributeError, KeyError, IndexError): pass + columns = copy.copy(columns) + for column in columns: + if source in column.exclude or source.__class__ in column.exclude or source._meta.model in column.exclude: + columns.remove(column) + columns = SourceColumn.sort(columns=columns) if exclude_identifier: @@ -654,7 +660,7 @@ class SourceColumn(object): return final_result def __init__( - self, source, attribute=None, empty_value=None, func=None, + self, source, attribute=None, empty_value=None, exclude=None, func=None, include_label=False, is_attribute_absolute_url=False, is_object_absolute_url=False, is_identifier=False, is_sortable=False, kwargs=None, label=None, order=None, sort_field=None, views=None, @@ -664,6 +670,7 @@ class SourceColumn(object): self._label = label self.attribute = attribute self.empty_value = empty_value + self.exclude = exclude or () self.func = func self.is_attribute_absolute_url = is_attribute_absolute_url self.is_object_absolute_url = is_object_absolute_url