diff --git a/HISTORY.rst b/HISTORY.rst index 06c5e29f9d..1a809e1b1f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -16,6 +16,7 @@ - Equalize dashboard widgets heights. - Switch the order of the DEFAULT_AUTHENTICATION_CLASSES of DRF. GitLab #400. - Backport document's version list view permission. +- Improve code to unbind menu entries. 2.5.2 (2017-07-08) ================== diff --git a/docs/releases/2.6.rst b/docs/releases/2.6.rst index 1df34d1543..e614e46da4 100644 --- a/docs/releases/2.6.rst +++ b/docs/releases/2.6.rst @@ -65,6 +65,7 @@ Other Changes - Sort setting by namespace label and by global name second. - Sort indexes by label. - Switch the order of the DEFAULT_AUTHENTICATION_CLASSES of DRF. GitLab #400. +- Improve code to unbind menu entries. Removals -------- diff --git a/mayan/apps/navigation/classes.py b/mayan/apps/navigation/classes.py index 1a313d50e3..2011586a27 100644 --- a/mayan/apps/navigation/classes.py +++ b/mayan/apps/navigation/classes.py @@ -206,13 +206,15 @@ class Menu(object): unbound_links.extend(self.unbound_links.get(source, ())) unbound_links.extend(self.unbound_links.get(current_view, ())) + new_result = [] for resolved_link in result[0]: try: - if resolved_link.link in unbound_links: - result[0].remove(resolved_link) + if resolved_link.link not in unbound_links: + new_result.append(resolved_link) except AttributeError: - # It's a menu, ignore - pass + new_result.append(resolved_link) + + result[0] = new_result # Sort links by position value passed during bind result[0] = sorted(