Add context processor to put allow accessing workspace in template
This commit is contained in:
parent
f8c3ac824a
commit
34d652f33a
@ -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/<workspace_id>/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/<workspace_id>/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/<workspace_id>/reports")
|
||||
def workspace_reports(workspace_id):
|
||||
return render_template(
|
||||
"workspace_reports.html", workspace_id=workspace_id
|
||||
)
|
||||
return render_template("workspace_reports.html")
|
||||
|
@ -6,9 +6,9 @@
|
||||
{{ Icon('shield', classes='topbar__link-icon') }}
|
||||
</a>
|
||||
|
||||
<div class="topbar__context topbar__context--{{context}}">
|
||||
<div class="topbar__context {% if workspace %}topbar__context--workspace{% endif %}">
|
||||
<a href="/" class="topbar__link">
|
||||
<span class="topbar__link-label">{{ "Workspace 123456" if context == 'workspace' else "JEDI" }}</span>
|
||||
<span class="topbar__link-label">{{ ("Workspace " + workspace.name) if workspace else "JEDI" }}</span>
|
||||
{{ Icon('caret_down', classes='topbar__link-icon icon--tiny') }}
|
||||
</a>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
{% block workspace_content %}
|
||||
|
||||
{{ Alert("Funding Information & Reports for Workspace " + workspace_id,
|
||||
{{ Alert("Funding Information & Reports for Workspace " + workspace.name,
|
||||
message="<p>On this screen you'll find detailed reporting information on this workspace. This message needs to be written better and be dismissable.</p>",
|
||||
actions=[
|
||||
{"label": "Learn More", "href": "/", "icon": "info"},
|
||||
|
Loading…
x
Reference in New Issue
Block a user