From af2430005964da01c6dd632ea30268d278b023f3 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Thu, 14 Feb 2019 11:46:39 +0100 Subject: [PATCH 1/3] status changes based on presets more specifically --- pype/ftrack/lib/ftrack_app_handler.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pype/ftrack/lib/ftrack_app_handler.py b/pype/ftrack/lib/ftrack_app_handler.py index 422d3b96dc..68f69bbe7b 100644 --- a/pype/ftrack/lib/ftrack_app_handler.py +++ b/pype/ftrack/lib/ftrack_app_handler.py @@ -306,24 +306,26 @@ class AppAction(BaseHandler): # Change status of task to In progress config = get_config_data() - if ( - 'status_on_app_launch' in config and - 'sync_to_avalon' in config and - 'statuses_name_change' in config['sync_to_avalon'] - ): - statuses = config['sync_to_avalon']['statuses_name_change'] - if entity['status']['name'].lower() in statuses: - status_name = config['status_on_app_launch'] + if 'status_update' in config: + statuses = config['status_update'] + actual_status = entity['status']['name'].lower() + next_status_name = None + for key, value in statuses.items(): + if actual_status in value: + next_status_name = key + break + + if next_status_name is not None: try: - query = 'Status where name is "{}"'.format(status_name) + query = 'Status where name is "{}"'.format(next_status_name) status = session.query(query).one() - task['status'] = status + entity['status'] = status session.commit() - except Exception as e: + except Exception: msg = ( 'Status "{}" in config wasn\'t found on Ftrack' - ).format(status_name) + ).format(next_status_name) self.log.warning(msg) # Set origin avalon environments From 90187e94b3632909d81033f3e337bebf7256251e Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Thu, 14 Feb 2019 11:54:47 +0100 Subject: [PATCH 2/3] added possibility of usage _any_ so from any status will be changed to one specific --- pype/ftrack/lib/ftrack_app_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/ftrack/lib/ftrack_app_handler.py b/pype/ftrack/lib/ftrack_app_handler.py index 68f69bbe7b..6123048701 100644 --- a/pype/ftrack/lib/ftrack_app_handler.py +++ b/pype/ftrack/lib/ftrack_app_handler.py @@ -312,7 +312,7 @@ class AppAction(BaseHandler): actual_status = entity['status']['name'].lower() next_status_name = None for key, value in statuses.items(): - if actual_status in value: + if actual_status in value or '_any_' in value: next_status_name = key break From 305262936e6954a7182c0705a4f73070f4a25056 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Thu, 14 Feb 2019 21:34:10 +0000 Subject: [PATCH 3/3] added "_ignore_" possibility --- pype/ftrack/lib/ftrack_app_handler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pype/ftrack/lib/ftrack_app_handler.py b/pype/ftrack/lib/ftrack_app_handler.py index 6123048701..9aed3d74da 100644 --- a/pype/ftrack/lib/ftrack_app_handler.py +++ b/pype/ftrack/lib/ftrack_app_handler.py @@ -313,7 +313,8 @@ class AppAction(BaseHandler): next_status_name = None for key, value in statuses.items(): if actual_status in value or '_any_' in value: - next_status_name = key + if key != '_ignore_': + next_status_name = key break if next_status_name is not None: