diff --git a/atst/app.py b/atst/app.py index 4c206878..7c74ebd0 100644 --- a/atst/app.py +++ b/atst/app.py @@ -64,11 +64,6 @@ def make_app(config): def make_flask_callbacks(app): @app.before_request def _set_globals(): - g.navigationContext = ( - "workspace" - if re.match("\/workspaces\/[A-Za-z0-9]*", request.path) - else "global" - ) g.dev = os.getenv("FLASK_ENV", "dev") == "dev" g.matchesPath = lambda href: re.match("^" + href, request.path) g.modal = request.args.get("modal", None) diff --git a/atst/domain/workspaces.py b/atst/domain/workspaces.py index 6ec0b856..64d7ce50 100644 --- a/atst/domain/workspaces.py +++ b/atst/domain/workspaces.py @@ -1,14 +1,33 @@ +class Workspaces(object): + MOCK_WORKSPACES = [ + { + "name": "Unclassified IaaS and PaaS for Defense Digital Service (DDS)", + "id": "5966187a-eff9-44c3-aa15-4de7a65ac7ff", + "task_order": {"number": 123456}, + "user_count": 23, + } + ] + + @classmethod + def get(cls, workspace_id): + return cls.MOCK_WORKSPACES[0] + + @classmethod + def get_many(cls): + return cls.MOCK_WORKSPACES + class Projects(object): - def __init__(self): + + @classmethod + def create(cls, creator_id, body): pass - def create(self, creator_id, body): + @classmethod + def get(cls, project_id): pass - def get(self, project_id): - pass - - def get_many(self, workspace_id): + @classmethod + def get_many(cls, workspace_id): return [ { "id": "187c9bea-9541-45d7-801f-cf8e7a642e93", @@ -41,21 +60,23 @@ class Projects(object): }, ] - def update(self, request_id, request_delta): + @classmethod + def update(cls, request_id, request_delta): pass class Members(object): - def __init__(self): + + @classmethod + def create(cls, creator_id, body): pass - def create(self, creator_id, body): + @classmethod + def get(cls, request_id): pass - def get(self, request_id): - pass - - def get_many(self, workspace_id): + @classmethod + def get_many(cls, workspace_id): return [ { "first_name": "Danny", @@ -86,5 +107,6 @@ class Members(object): }, ] - def update(self, request_id, request_delta): + @classmethod + def update(cls, request_id, request_delta): pass diff --git a/atst/routes/workspaces.py b/atst/routes/workspaces.py index 13ba6115..40be4aee 100644 --- a/atst/routes/workspaces.py +++ b/atst/routes/workspaces.py @@ -1,45 +1,35 @@ -from flask import Blueprint, render_template +from flask import Blueprint, render_template, request as http_request -from atst.domain.workspaces import Projects, Members +from atst.domain.workspaces import Members, Projects, Workspaces bp = Blueprint("workspaces", __name__) -mock_workspaces = [ - { - "name": "Unclassified IaaS and PaaS for Defense Digital Service (DDS)", - "id": "5966187a-eff9-44c3-aa15-4de7a65ac7ff", - "task_order": {"number": 123456}, - "user_count": 23, - } -] +@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(): - return render_template("workspaces.html", page=5, workspaces=mock_workspaces) + return render_template("workspaces.html", page=5, workspaces=Workspaces.get_many()) @bp.route("/workspaces//projects") def workspace_projects(workspace_id): - projects_repo = Projects() - projects = projects_repo.get_many(workspace_id) - return render_template( - "workspace_projects.html", workspace_id=workspace_id, projects=projects - ) + projects = Projects.get_many(workspace_id) + return render_template("workspace_projects.html", projects=projects) @bp.route("/workspaces//members") def workspace_members(workspace_id): - members_repo = Members() - members = members_repo.get_many(workspace_id) - return render_template( - "workspace_members.html", workspace_id=workspace_id, members=members - ) + members = Members.get_many(workspace_id) + 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/base.html b/templates/base.html index 3f5125ce..bbb49fe5 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,7 +1,3 @@ -{# TODO: set this context elsewhere #} -{# set context='workspace' #} -{% set context=g.navigationContext %} - diff --git a/templates/error_base.html b/templates/error_base.html index a9d8c0de..5ef0878d 100644 --- a/templates/error_base.html +++ b/templates/error_base.html @@ -1,7 +1,3 @@ -{# TODO: set this context elsewhere #} -{# set context='workspace' #} -{% set context=g.navigationContext %} - diff --git a/templates/navigation/global_navigation.html b/templates/navigation/global_navigation.html index b2311665..4b259e2b 100644 --- a/templates/navigation/global_navigation.html +++ b/templates/navigation/global_navigation.html @@ -1,6 +1,6 @@ {% from "components/sidenav_item.html" import SidenavItem %} -