Update query to also return events that update the workspace
This commit is contained in:
parent
466f2565b5
commit
a48b814263
@ -1,3 +1,5 @@
|
|||||||
|
from sqlalchemy import or_
|
||||||
|
|
||||||
from atst.database import db
|
from atst.database import db
|
||||||
from atst.domain.common import Query
|
from atst.domain.common import Query
|
||||||
from atst.domain.authz import Authorization, Permissions
|
from atst.domain.authz import Authorization, Permissions
|
||||||
@ -16,7 +18,12 @@ class AuditEventQuery(Query):
|
|||||||
def get_ws_events(cls, workspace_id, pagination_opts):
|
def get_ws_events(cls, workspace_id, pagination_opts):
|
||||||
query = (
|
query = (
|
||||||
db.session.query(cls.model)
|
db.session.query(cls.model)
|
||||||
.filter(cls.model.workspace_id == workspace_id)
|
.filter(
|
||||||
|
or_(
|
||||||
|
cls.model.workspace_id == workspace_id,
|
||||||
|
cls.model.resource_id == workspace_id,
|
||||||
|
)
|
||||||
|
)
|
||||||
.order_by(cls.model.time_created.desc())
|
.order_by(cls.model.time_created.desc())
|
||||||
)
|
)
|
||||||
return cls.paginate(query, pagination_opts)
|
return cls.paginate(query, pagination_opts)
|
||||||
|
@ -99,4 +99,4 @@ def test_ws_audit_log_only_includes_current_ws_events():
|
|||||||
|
|
||||||
events = AuditLog.get_workspace_events(workspace.owner, workspace)
|
events = AuditLog.get_workspace_events(workspace.owner, workspace)
|
||||||
for event in events:
|
for event in events:
|
||||||
assert event.workspace_id == workspace.id
|
assert event.workspace_id == workspace.id or event.resource_id == workspace.id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user