workspace_projects route working

This commit is contained in:
richard-dds 2018-08-21 11:25:44 -04:00
parent dcd69f6b9f
commit 0de8866919
4 changed files with 20 additions and 55 deletions

View File

@ -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):

View File

@ -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")

View File

@ -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/<workspace_id>/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/<workspace_id>/reports")

View File

@ -4,21 +4,21 @@
{% block workspace_content %}
{% for project in projects %}
{% for project in workspace.projects %}
<div class='block-list project-list-item'>
<header class='block-list__header'>
<h2 class='block-list__title'>{{ project['name'] }} ({{ project['environments']|length }} environments)</h2>
<a class='icon-link' href=''>
<h2 class='block-list__title'>{{ project.name }} ({{ project.environments|length }} environments)</h2>
<a class='icon-link' href='/workspaces/123456/projects/789/edit'>
{{ Icon('edit') }}
<span>edit</span>
</a>
</header>
<ul>
{% for environment in project['environments'] %}
{% for environment in project.environments %}
<li class='block-list__item project-list-item__environment'>
<a href='/' target='_blank' rel='noopener noreferrer' class='project-list-item__environment__link'>
{{ Icon('link') }}
<span>{{ environment["name"]}}</span>
<span>{{ environment.name }}</span>
</a>
<div class='project-list-item__environment__members'>