mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Merge pull request #3671 from pypeclub/feature/OP-3727_Sync-to-avalon-logs
Ftrack: More logs related to auto sync value change
This commit is contained in:
commit
40a667c3cf
1 changed files with 35 additions and 6 deletions
|
|
@ -697,13 +697,22 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
continue
|
||||
|
||||
auto_sync = changes[CUST_ATTR_AUTO_SYNC]["new"]
|
||||
if auto_sync == "1":
|
||||
turned_on = auto_sync == "1"
|
||||
ft_project = self.cur_project
|
||||
username = self._get_username(session, event)
|
||||
message = (
|
||||
"Auto sync was turned {} for project \"{}\" by \"{}\"."
|
||||
).format(
|
||||
"on" if turned_on else "off",
|
||||
ft_project["full_name"],
|
||||
username
|
||||
)
|
||||
if turned_on:
|
||||
message += " Triggering syncToAvalon action."
|
||||
self.log.debug(message)
|
||||
|
||||
if turned_on:
|
||||
# Trigger sync to avalon action if auto sync was turned on
|
||||
ft_project = self.cur_project
|
||||
self.log.debug((
|
||||
"Auto sync was turned on for project <{}>."
|
||||
" Triggering syncToAvalon action."
|
||||
).format(ft_project["full_name"]))
|
||||
selection = [{
|
||||
"entityId": ft_project["id"],
|
||||
"entityType": "show"
|
||||
|
|
@ -851,6 +860,26 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
self.report()
|
||||
return True
|
||||
|
||||
def _get_username(self, session, event):
|
||||
username = "Unknown"
|
||||
event_source = event.get("source")
|
||||
if not event_source:
|
||||
return username
|
||||
user_info = event_source.get("user")
|
||||
if not user_info:
|
||||
return username
|
||||
user_id = user_info.get("id")
|
||||
if not user_id:
|
||||
return username
|
||||
|
||||
user_entity = session.query(
|
||||
"User where id is {}".format(user_id)
|
||||
).first()
|
||||
if user_entity:
|
||||
username = user_entity["username"] or username
|
||||
return username
|
||||
|
||||
|
||||
def process_removed(self):
|
||||
"""
|
||||
Handles removed entities (not removed tasks - handle separately).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue