Rewrite navigation as a class

Because we have multiple navigations, which will share the same methods
(by subclassing) but different mappings of navigation items to endpoints
by overriding the `.mapping` and `.exclude` attributes.
This commit is contained in:
Chris Hill-Scott
2018-04-25 10:24:32 +01:00
parent 1fba5d186d
commit e1fd63e184
4 changed files with 263 additions and 246 deletions

View File

@@ -36,9 +36,10 @@ from notifications_utils.formatters import formatted_list
from werkzeug.exceptions import abort
from werkzeug.local import LocalProxy
from app import proxy_fix, navigation
from app import proxy_fix
from app.config import configs
from app.asset_fingerprinter import AssetFingerprinter
from app.navigation import MainNavigation
from app.notify_client.service_api_client import ServiceAPIClient
from app.notify_client.api_key_api_client import ApiKeyApiClient
from app.notify_client.invite_api_client import InviteApiClient
@@ -89,6 +90,8 @@ current_service = LocalProxy(partial(_lookup_req_object, 'service'))
# The current organisation attached to the request stack.
current_organisation = LocalProxy(partial(_lookup_req_object, 'organisation'))
main_navigation = MainNavigation()
def create_app(application):
setup_commands(application)
@@ -173,7 +176,7 @@ def init_app(application):
@application.context_processor
def _nav_selected():
return {'nav_selected': navigation.nav_selected}
return {'main_navigation': main_navigation}
@application.before_request
def record_start_time():