diff --git a/atst/domain/workspaces.py b/atst/domain/workspaces.py index b0f8819c..8f5da292 100644 --- a/atst/domain/workspaces.py +++ b/atst/domain/workspaces.py @@ -1,9 +1,10 @@ from sqlalchemy.orm.exc import NoResultFound from atst.database import db -from atst.domain.exceptions import NotFoundError, UnauthorizedError from atst.models.workspace import Workspace from atst.models.workspace_role import WorkspaceRole +from atst.models.project import Project +from atst.domain.exceptions import NotFoundError, UnauthorizedError from atst.domain.roles import Roles @@ -55,54 +56,14 @@ class Workspaces(object): class Projects(object): - def __init__(self): - pass - @classmethod - def create(cls, creator_id, body): - pass + def create(cls, workspace, name, description): + project = Project(workspace=workspace, name=name, description=description) - @classmethod - def get(cls, project_id): - pass + db.session.add(project) + db.session.commit() - @classmethod - def get_many(cls, workspace_id): - return [ - { - "id": "187c9bea-9541-45d7-801f-cf8e7a642e93", - "name": "Code.mil", - "environments": [ - { - "id": "b1154fdd-31c9-437f-b580-2e4d757de5cb", - "name": "Development", - }, - {"id": "b1e2077a-6a3d-4e7f-a80c-bf1143433adf", "name": "Sandbox"}, - { - "id": "8ea95eea-7cc0-4500-adf7-8a13eaa6b752", - "name": "production", - }, - ], - }, - { - "id": "ececfd73-b19d-45aa-9199-a950ba2c7269", - "name": "Digital Dojo", - "environments": [ - { - "id": "f56167cb-ca3d-4e29-8b60-91052957a118", - "name": "Development", - }, - { - "id": "7c18689c-5b77-4b68-8d64-d4d8a830bf47", - "name": "production", - }, - ], - }, - ] - - @classmethod - def update(cls, request_id, request_delta): - pass + return project class Members(object): diff --git a/atst/models/project.py b/atst/models/project.py index 05ee853e..46562e82 100644 --- a/atst/models/project.py +++ b/atst/models/project.py @@ -15,4 +15,4 @@ class Project(Base, TimestampsMixin): workspace_id = Column(ForeignKey("workspaces.id"), nullable=False) workspace = relationship("Workspace") - projects = relationship("Environment", back_populates="project") + environments = relationship("Environment", back_populates="project") diff --git a/atst/routes/workspaces.py b/atst/routes/workspaces.py index a94a6224..3dd193de 100644 --- a/atst/routes/workspaces.py +++ b/atst/routes/workspaces.py @@ -1,6 +1,6 @@ from flask import Blueprint, render_template, request as http_request, g -from atst.domain.workspaces import Workspaces +from atst.domain.workspaces import Workspaces, Members bp = Blueprint("workspaces", __name__) @@ -26,8 +26,12 @@ def workspace_projects(workspace_id): @bp.route("/workspaces//members") def workspace_members(workspace_id): - members = Members.get_many(workspace_id) - return render_template("workspace_members.html", members=members) + workspace = Workspaces.get(g.current_user, workspace_id) + members_repo = Members() + members = members_repo.get_many(workspace_id) + return render_template( + "workspace_members.html", workspace=workspace, members=members + ) @bp.route("/workspaces//reports") diff --git a/templates/workspace_projects.html b/templates/workspace_projects.html index ccc99759..d299897a 100644 --- a/templates/workspace_projects.html +++ b/templates/workspace_projects.html @@ -4,21 +4,21 @@ {% block workspace_content %} -{% for project in projects %} +{% for project in workspace.projects %}
-

{{ project['name'] }} ({{ project['environments']|length }} environments)

- +

{{ project.name }} ({{ project.environments|length }} environments)

+
{{ Icon('edit') }} edit