From 9ea30c057fc8488abe200fd1d0a824cf9c173cf6 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 25 Mar 2020 13:51:37 -0400 Subject: [PATCH] Replace get_menu_items() with static attribute --- netbox/extras/plugins/__init__.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/netbox/extras/plugins/__init__.py b/netbox/extras/plugins/__init__.py index d43c0cf5c..40db432e3 100644 --- a/netbox/extras/plugins/__init__.py +++ b/netbox/extras/plugins/__init__.py @@ -46,22 +46,18 @@ class PluginConfig(AppConfig): # Caching configuration caching_config = {} + # Default integration paths. Plugin authors can override these to customize the paths to + # integrated components. + menu_items = 'navigation.menu_items' + def ready(self): # Register navigation menu items (if defined) - register_menu_items(self.verbose_name, self.get_menu_items()) - - def get_menu_items(self): - """ - Default method to import navigation menu items for a plugin from the default location (menu_items in a - file named navigation.py). This method may be overridden by a plugin author to import menu items from - a different location if needed. - """ try: - menu_items = import_string(f"{self.__module__}.navigation.menu_items") - return menu_items + menu_items = import_string(f"{self.__module__}.{self.menu_items}") + register_menu_items(self.verbose_name, menu_items) except ImportError: - return [] + pass #