added get_project_from_entity to ftrack base event handler

This commit is contained in:
iLLiCiTiT 2020-04-14 11:19:12 +02:00
parent 4a3b98c945
commit 0b2c1fc99f

View file

@ -623,3 +623,19 @@ class BaseHandler(object):
self.log.debug((
"Publishing event: {}"
).format(str(event.__dict__)))
def get_project_from_entity(self, entity):
low_entity_type = entity.entity_type.lower()
if low_entity_type == "project":
return entity
if low_entity_type == "reviewsession":
return entity["project"]
if low_entity_type == "filecomponent":
entity = entity["version"]
project_data = entity["link"][0]
return self.session.query(
"Project where id is {}".format(project_data["id"])
).one()