capture status and no history cases on workspace role model

This commit is contained in:
Montana 2018-11-13 11:21:12 -05:00
parent adad5adfa6
commit e51de11a28
2 changed files with 10 additions and 4 deletions

View File

@ -45,10 +45,15 @@ class WorkspaceRole(Base, mixins.TimestampsMixin, mixins.AuditableMixin):
@property
def history(self):
previous_state = mixins.AuditableMixin.get_history(self)
auditable_previous_state = {}
if "role_id" in previous_state:
from_role_id = previous_state["role_id"]
from_role = db.session.query(Role).filter(Role.id == from_role_id).one()
to_role = self.role_displayname
return {"role": [from_role.display_name, to_role]}
auditable_previous_state["role"] = [from_role.display_name, to_role]
if "status" in previous_state:
auditable_previous_state["status"]= previous_state["status"].value
return auditable_previous_state
@property
def event_details(self):

View File

@ -326,6 +326,7 @@ class WorkspaceRoleFactory(Base):
workspace = factory.SubFactory(WorkspaceFactory)
role = factory.SubFactory(RoleFactory)
user = factory.SubFactory(UserFactory)
status = WorkspaceRoleStatus.PENDING
class EnvironmentRoleFactory(Base):