mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
use query functions in event user assiment
This commit is contained in:
parent
ac48f50fdf
commit
dd07bbe9b2
1 changed files with 4 additions and 19 deletions
|
|
@ -1,11 +1,9 @@
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from openpype.client import get_asset_by_id, get_asset_by_name
|
||||||
from openpype_modules.ftrack.lib import BaseEvent
|
from openpype_modules.ftrack.lib import BaseEvent
|
||||||
from openpype_modules.ftrack.lib.avalon_sync import CUST_ATTR_ID_KEY
|
from openpype_modules.ftrack.lib.avalon_sync import CUST_ATTR_ID_KEY
|
||||||
from openpype.pipeline import AvalonMongoDB
|
|
||||||
|
|
||||||
from bson.objectid import ObjectId
|
|
||||||
|
|
||||||
from openpype.api import Anatomy, get_project_settings
|
from openpype.api import Anatomy, get_project_settings
|
||||||
|
|
||||||
|
|
@ -36,8 +34,6 @@ class UserAssigmentEvent(BaseEvent):
|
||||||
3) path to publish files of task user was (de)assigned to
|
3) path to publish files of task user was (de)assigned to
|
||||||
"""
|
"""
|
||||||
|
|
||||||
db_con = AvalonMongoDB()
|
|
||||||
|
|
||||||
def error(self, *err):
|
def error(self, *err):
|
||||||
for e in err:
|
for e in err:
|
||||||
self.log.error(e)
|
self.log.error(e)
|
||||||
|
|
@ -101,26 +97,16 @@ class UserAssigmentEvent(BaseEvent):
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
parent = task['parent']
|
parent = task['parent']
|
||||||
self.db_con.install()
|
project_name = task["project"]["full_name"]
|
||||||
self.db_con.Session['AVALON_PROJECT'] = task['project']['full_name']
|
|
||||||
|
|
||||||
avalon_entity = None
|
avalon_entity = None
|
||||||
parent_id = parent['custom_attributes'].get(CUST_ATTR_ID_KEY)
|
parent_id = parent['custom_attributes'].get(CUST_ATTR_ID_KEY)
|
||||||
if parent_id:
|
if parent_id:
|
||||||
parent_id = ObjectId(parent_id)
|
avalon_entity = get_asset_by_id(project_name, parent_id)
|
||||||
avalon_entity = self.db_con.find_one({
|
|
||||||
'_id': parent_id,
|
|
||||||
'type': 'asset'
|
|
||||||
})
|
|
||||||
|
|
||||||
if not avalon_entity:
|
if not avalon_entity:
|
||||||
avalon_entity = self.db_con.find_one({
|
avalon_entity = get_asset_by_name(project_name, parent["name"])
|
||||||
'type': 'asset',
|
|
||||||
'name': parent['name']
|
|
||||||
})
|
|
||||||
|
|
||||||
if not avalon_entity:
|
if not avalon_entity:
|
||||||
self.db_con.uninstall()
|
|
||||||
msg = 'Entity "{}" not found in avalon database'.format(
|
msg = 'Entity "{}" not found in avalon database'.format(
|
||||||
parent['name']
|
parent['name']
|
||||||
)
|
)
|
||||||
|
|
@ -129,7 +115,6 @@ class UserAssigmentEvent(BaseEvent):
|
||||||
'success': False,
|
'success': False,
|
||||||
'message': msg
|
'message': msg
|
||||||
}
|
}
|
||||||
self.db_con.uninstall()
|
|
||||||
return avalon_entity
|
return avalon_entity
|
||||||
|
|
||||||
def _get_hierarchy(self, asset):
|
def _get_hierarchy(self, asset):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue