mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
use folder naming
This commit is contained in:
parent
262cbda493
commit
c3296b1322
11 changed files with 110 additions and 106 deletions
|
|
@ -81,15 +81,19 @@ class WebServerTool:
|
|||
await client.connect()
|
||||
|
||||
context = get_global_context()
|
||||
project = context["project_name"]
|
||||
asset = context["folder_path"]
|
||||
task = context["task_name"]
|
||||
log.info("Sending context change to {}-{}-{}".format(project,
|
||||
asset,
|
||||
task))
|
||||
project_name = context["project_name"]
|
||||
folder_path = context["folder_path"]
|
||||
task_name = context["task_name"]
|
||||
log.info("Sending context change to {}{}/{}".format(
|
||||
project_name, folder_path, task_name
|
||||
))
|
||||
|
||||
await client.call('{}.set_context'.format(host),
|
||||
project=project, asset=asset, task=task)
|
||||
await client.call(
|
||||
'{}.set_context'.format(host),
|
||||
project=project_name,
|
||||
folder=folder_path,
|
||||
task=task_name
|
||||
)
|
||||
await client.close()
|
||||
|
||||
def port_occupied(self, host_name, port):
|
||||
|
|
|
|||
|
|
@ -277,8 +277,8 @@ class ContextDialogController:
|
|||
def is_initial_context_valid(self):
|
||||
return self._initial_folder_found and self._initial_project_found
|
||||
|
||||
def set_initial_context(self, project_name=None, asset_name=None):
|
||||
result = self._prepare_initial_context(project_name, asset_name)
|
||||
def set_initial_context(self, project_name=None, folder_path=None):
|
||||
result = self._prepare_initial_context(project_name, folder_path)
|
||||
|
||||
self._initial_project_name = project_name
|
||||
self._initial_folder_id = result["folder_id"]
|
||||
|
|
@ -352,7 +352,7 @@ class ContextDialogController:
|
|||
with open(self._output_path, "w") as stream:
|
||||
json.dump(self.get_selected_context(), stream, indent=4)
|
||||
|
||||
def _prepare_initial_context(self, project_name, asset_name):
|
||||
def _prepare_initial_context(self, project_name, folder_path):
|
||||
project_found = True
|
||||
output = {
|
||||
"project_found": project_found,
|
||||
|
|
@ -362,26 +362,26 @@ class ContextDialogController:
|
|||
"tasks_found": True,
|
||||
}
|
||||
if project_name is None:
|
||||
asset_name = None
|
||||
folder_path = None
|
||||
else:
|
||||
project = ayon_api.get_project(project_name)
|
||||
project_found = project is not None
|
||||
output["project_found"] = project_found
|
||||
if not project_found or not asset_name:
|
||||
if not project_found or not folder_path:
|
||||
return output
|
||||
|
||||
output["folder_label"] = asset_name
|
||||
output["folder_label"] = folder_path
|
||||
|
||||
folder_id = None
|
||||
folder_found = False
|
||||
# First try to find by path
|
||||
folder = ayon_api.get_folder_by_path(project_name, asset_name)
|
||||
folder = ayon_api.get_folder_by_path(project_name, folder_path)
|
||||
# Try to find by name if folder was not found by path
|
||||
# - prevent to query by name if 'asset_name' contains '/'
|
||||
if not folder and "/" not in asset_name:
|
||||
# - prevent to query by name if 'folder_path' contains '/'
|
||||
if not folder and "/" not in folder_path:
|
||||
folder = next(
|
||||
ayon_api.get_folders(
|
||||
project_name, folder_names=[asset_name], fields=["id"]),
|
||||
project_name, folder_names=[folder_path], fields=["id"]),
|
||||
None
|
||||
)
|
||||
|
||||
|
|
@ -496,10 +496,10 @@ class ContextDialog(QtWidgets.QDialog):
|
|||
|
||||
Context has 3 parts:
|
||||
- Project
|
||||
- Asset
|
||||
- Folder
|
||||
- Task
|
||||
|
||||
It is possible to predefine project and asset. In that case their widgets
|
||||
It is possible to predefine project and folder. In that case their widgets
|
||||
will have passed preselected values and will be disabled.
|
||||
"""
|
||||
def __init__(self, controller=None, parent=None):
|
||||
|
|
@ -521,7 +521,7 @@ class ContextDialog(QtWidgets.QDialog):
|
|||
# UI initialization
|
||||
main_splitter = QtWidgets.QSplitter(self)
|
||||
|
||||
# Left side widget contains project combobox and asset widget
|
||||
# Left side widget contains project combobox and folders widget
|
||||
left_side_widget = QtWidgets.QWidget(main_splitter)
|
||||
|
||||
project_combobox = ProjectsCombobox(
|
||||
|
|
@ -531,7 +531,7 @@ class ContextDialog(QtWidgets.QDialog):
|
|||
)
|
||||
project_combobox.set_select_item_visible(True)
|
||||
|
||||
# Assets widget
|
||||
# Folders widget
|
||||
folders_widget = FoldersWidget(
|
||||
controller,
|
||||
parent=left_side_widget,
|
||||
|
|
@ -661,11 +661,7 @@ class ContextDialog(QtWidgets.QDialog):
|
|||
self._controller.set_strict(enabled)
|
||||
|
||||
def refresh(self):
|
||||
"""Refresh all widget one by one.
|
||||
|
||||
When asset refresh is triggered we have to wait when is done so
|
||||
this method continues with `_on_asset_widget_refresh_finished`.
|
||||
"""
|
||||
"""Refresh all widget one by one."""
|
||||
|
||||
self._controller.reset()
|
||||
|
||||
|
|
@ -673,10 +669,10 @@ class ContextDialog(QtWidgets.QDialog):
|
|||
"""Result of dialog."""
|
||||
return self._controller.get_selected_context()
|
||||
|
||||
def set_context(self, project_name=None, asset_name=None):
|
||||
def set_context(self, project_name=None, folder_path=None):
|
||||
"""Set context which will be used and locked in dialog."""
|
||||
|
||||
self._controller.set_initial_context(project_name, asset_name)
|
||||
self._controller.set_initial_context(project_name, folder_path)
|
||||
|
||||
def _on_projects_refresh(self):
|
||||
initial_context = self._controller.get_initial_context()
|
||||
|
|
@ -784,14 +780,14 @@ class ContextDialog(QtWidgets.QDialog):
|
|||
def main(
|
||||
path_to_store,
|
||||
project_name=None,
|
||||
asset_name=None,
|
||||
folder_path=None,
|
||||
strict=True
|
||||
):
|
||||
# Run Qt application
|
||||
app = get_ayon_qt_app()
|
||||
controller = ContextDialogController()
|
||||
controller.set_strict(strict)
|
||||
controller.set_initial_context(project_name, asset_name)
|
||||
controller.set_initial_context(project_name, folder_path)
|
||||
controller.set_output_json_path(path_to_store)
|
||||
window = ContextDialog(controller=controller)
|
||||
window.show()
|
||||
|
|
|
|||
|
|
@ -309,9 +309,11 @@ class ActionsModel:
|
|||
task_name = None
|
||||
task_type = None
|
||||
if task_id is not None:
|
||||
task = self._controller.get_task_entity(project_name, task_id)
|
||||
task_name = task["name"]
|
||||
task_type = task["taskType"]
|
||||
task_entity = self._controller.get_task_entity(
|
||||
project_name, task_id
|
||||
)
|
||||
task_name = task_entity["name"]
|
||||
task_type = task_entity["taskType"]
|
||||
|
||||
output = should_start_last_workfile(
|
||||
project_name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue