From 34d652f33a6dba500b6159bb1f3f04d25b6edeb9 Mon Sep 17 00:00:00 2001 From: Patrick Smith Date: Tue, 21 Aug 2018 14:52:06 -0400 Subject: [PATCH] Add context processor to put allow accessing workspace in template --- atst/routes/workspaces.py | 19 ++++++++++--------- templates/navigation/topbar.html | 4 ++-- templates/workspace_reports.html | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/atst/routes/workspaces.py b/atst/routes/workspaces.py index f2302f87..40be4aee 100644 --- a/atst/routes/workspaces.py +++ b/atst/routes/workspaces.py @@ -5,6 +5,13 @@ from atst.domain.workspaces import Members, Projects, Workspaces bp = Blueprint("workspaces", __name__) +@bp.context_processor +def workspace(): + workspace = None + if "workspace_id" in http_request.view_args: + workspace = Workspaces.get(http_request.view_args["workspace_id"]) + return { "workspace": workspace } + @bp.route("/workspaces") def workspaces(): @@ -14,21 +21,15 @@ def workspaces(): @bp.route("/workspaces//projects") def workspace_projects(workspace_id): projects = Projects.get_many(workspace_id) - return render_template( - "workspace_projects.html", workspace_id=workspace_id, projects=projects - ) + return render_template("workspace_projects.html", projects=projects) @bp.route("/workspaces//members") def workspace_members(workspace_id): members = Members.get_many(workspace_id) - return render_template( - "workspace_members.html", workspace_id=workspace_id, members=members - ) + return render_template("workspace_members.html", members=members) @bp.route("/workspaces//reports") def workspace_reports(workspace_id): - return render_template( - "workspace_reports.html", workspace_id=workspace_id - ) + return render_template("workspace_reports.html") diff --git a/templates/navigation/topbar.html b/templates/navigation/topbar.html index 791cfce5..9c13372d 100644 --- a/templates/navigation/topbar.html +++ b/templates/navigation/topbar.html @@ -6,9 +6,9 @@ {{ Icon('shield', classes='topbar__link-icon') }} -
+
- {{ "Workspace 123456" if context == 'workspace' else "JEDI" }} + {{ ("Workspace " + workspace.name) if workspace else "JEDI" }} {{ Icon('caret_down', classes='topbar__link-icon icon--tiny') }} diff --git a/templates/workspace_reports.html b/templates/workspace_reports.html index 3f15244d..46f72b1c 100644 --- a/templates/workspace_reports.html +++ b/templates/workspace_reports.html @@ -4,7 +4,7 @@ {% block workspace_content %} - {{ Alert("Funding Information & Reports for Workspace " + workspace_id, + {{ Alert("Funding Information & Reports for Workspace " + workspace.name, message="

On this screen you'll find detailed reporting information on this workspace. This message needs to be written better and be dismissable.

", actions=[ {"label": "Learn More", "href": "/", "icon": "info"},