Support exclusions from source columns
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -4,3 +4,4 @@
|
|||||||
workflow state.
|
workflow state.
|
||||||
- Sort module.
|
- Sort module.
|
||||||
- Add link to sort individual indexes.
|
- Add link to sort individual indexes.
|
||||||
|
- Support exclusions from source columns.
|
||||||
|
|||||||
@@ -106,11 +106,12 @@ class DocumentIndexingApp(MayanAppConfig):
|
|||||||
source=Index
|
source=Index
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
attribute='slug', is_sortable=True, source=Index
|
attribute='slug', exclude=(IndexInstance,), is_sortable=True,
|
||||||
|
source=Index
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
attribute='enabled', is_sortable=True, source=Index,
|
attribute='enabled', exclude=(IndexInstance,), is_sortable=True,
|
||||||
widget=TwoStateWidget
|
source=Index, widget=TwoStateWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
|
|||||||
@@ -161,7 +161,8 @@ class DocumentStatesApp(MayanAppConfig):
|
|||||||
attribute='label', is_sortable=True, source=Workflow
|
attribute='label', is_sortable=True, source=Workflow
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
attribute='internal_name', is_sortable=True, source=Workflow
|
attribute='internal_name', exclude=(WorkflowRuntimeProxy,),
|
||||||
|
is_sortable=True, source=Workflow
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
attribute='get_initial_state', empty_value=_('None'),
|
attribute='get_initial_state', empty_value=_('None'),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import copy
|
||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -615,6 +616,11 @@ class SourceColumn(object):
|
|||||||
except (AttributeError, KeyError, IndexError):
|
except (AttributeError, KeyError, IndexError):
|
||||||
pass
|
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)
|
columns = SourceColumn.sort(columns=columns)
|
||||||
|
|
||||||
if exclude_identifier:
|
if exclude_identifier:
|
||||||
@@ -654,7 +660,7 @@ class SourceColumn(object):
|
|||||||
return final_result
|
return final_result
|
||||||
|
|
||||||
def __init__(
|
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,
|
include_label=False, is_attribute_absolute_url=False,
|
||||||
is_object_absolute_url=False, is_identifier=False, is_sortable=False,
|
is_object_absolute_url=False, is_identifier=False, is_sortable=False,
|
||||||
kwargs=None, label=None, order=None, sort_field=None, views=None,
|
kwargs=None, label=None, order=None, sort_field=None, views=None,
|
||||||
@@ -664,6 +670,7 @@ class SourceColumn(object):
|
|||||||
self._label = label
|
self._label = label
|
||||||
self.attribute = attribute
|
self.attribute = attribute
|
||||||
self.empty_value = empty_value
|
self.empty_value = empty_value
|
||||||
|
self.exclude = exclude or ()
|
||||||
self.func = func
|
self.func = func
|
||||||
self.is_attribute_absolute_url = is_attribute_absolute_url
|
self.is_attribute_absolute_url = is_attribute_absolute_url
|
||||||
self.is_object_absolute_url = is_object_absolute_url
|
self.is_object_absolute_url = is_object_absolute_url
|
||||||
|
|||||||
Reference in New Issue
Block a user