diff --git a/HISTORY.rst b/HISTORY.rst index 460b4b5584..9979afc7b1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,11 +1,12 @@ -2.6.5 (2017-XX-XX) -================== +2.7 (2017-XX-XX) +================ - Add workaround for PDF with IndirectObject as the rotation value. GitHub #261. - Add ACL list link with icon and use it for the document facet menu. - Fix mailing app permissions labels. - Add ACLs link and ACLs permissions to the mailer profile model. - Improve mailer URL regex. +- Add ordering support to the SourceColumn class. GitLab issue #417. 2.6.4 (2017-07-26) ================== diff --git a/mayan/apps/navigation/classes.py b/mayan/apps/navigation/classes.py index cca4109c85..7d444937b8 100644 --- a/mayan/apps/navigation/classes.py +++ b/mayan/apps/navigation/classes.py @@ -393,34 +393,39 @@ class Separator(Link): class SourceColumn(object): _registry = {} + @staticmethod + def sort(columns): + return sorted(columns, key=lambda x: x.order) + @classmethod def get_for_source(cls, source): try: - return cls._registry[source] + return SourceColumn.sort(columns=cls._registry[source]) except KeyError: try: # Try it as a queryset - return cls._registry[source.model] + return SourceColumn.sort(columns=cls._registry[source.model]) except AttributeError: try: # It seems to be an instance, try its class - return cls._registry[source.__class__] + return SourceColumn.sort(columns=cls._registry[source.__class__]) except KeyError: try: # Special case for queryset items produced from # .defer() or .only() optimizations - return cls._registry[source._meta.parents.items()[0][0]] + return SourceColumn.sort(columns=cls._registry[source._meta.parents.items()[0][0]]) except (AttributeError, KeyError, IndexError): return () except TypeError: # unhashable type: list return () - def __init__(self, source, label, attribute=None, func=None): + def __init__(self, source, label, attribute=None, func=None, order=None): self.source = source self.label = label self.attribute = attribute self.func = func + self.order = order or 0 self.__class__._registry.setdefault(source, []) self.__class__._registry[source].append(self)