Add Workspace.roles
This commit is contained in:
parent
43263f35cc
commit
ee17ca6633
@ -11,10 +11,10 @@ class Workspace(Base, TimestampsMixin):
|
||||
|
||||
id = Id()
|
||||
name = Column(String, unique=True)
|
||||
|
||||
request_id = Column(ForeignKey("requests.id"), nullable=False)
|
||||
request = relationship("Request")
|
||||
projects = relationship("Project", back_populates="workspace")
|
||||
roles = relationship("WorkspaceRole")
|
||||
|
||||
@property
|
||||
def owner(self):
|
||||
|
@ -11,7 +11,7 @@ class WorkspaceRole(Base):
|
||||
|
||||
id = Id()
|
||||
workspace_id = Column(UUID(as_uuid=True), ForeignKey("workspaces.id"), index=True)
|
||||
workspace = relationship("Workspace")
|
||||
workspace = relationship("Workspace", back_populates="roles")
|
||||
|
||||
role_id = Column(UUID(as_uuid=True), ForeignKey("roles.id"))
|
||||
role = relationship("Role")
|
||||
|
@ -18,7 +18,6 @@ def test_can_create_workspace():
|
||||
def test_default_workspace_name_is_request_id():
|
||||
request = RequestFactory.create()
|
||||
workspace = Workspaces.create(request)
|
||||
assert workspace.request == request
|
||||
assert workspace.name == str(request.id)
|
||||
|
||||
|
||||
@ -51,3 +50,9 @@ def test_workspace_has_timestamps():
|
||||
request = RequestFactory.create()
|
||||
workspace = Workspaces.create(request)
|
||||
assert workspace.time_created == workspace.time_updated
|
||||
|
||||
|
||||
def test_workspace_has_roles():
|
||||
request = RequestFactory.create()
|
||||
workspace = Workspaces.create(request)
|
||||
assert workspace.roles[0].user == request.creator
|
||||
|
Loading…
x
Reference in New Issue
Block a user