mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
✨ support product aliases in the publisher
This commit is contained in:
parent
2d0364d155
commit
a1cdaf1015
6 changed files with 45 additions and 23 deletions
|
|
@ -15,6 +15,9 @@ from ayon_core.pipeline.plugin_discover import (
|
|||
deregister_plugin,
|
||||
deregister_plugin_path
|
||||
)
|
||||
|
||||
from ayon_core.pipeline.product_type_aliases import get_alias_for_product_type
|
||||
|
||||
from ayon_core.pipeline.staging_dir import get_staging_dir_info, StagingDir
|
||||
|
||||
from .constants import DEFAULT_VARIANT_VALUE
|
||||
|
|
@ -647,6 +650,16 @@ class BaseCreator(ABC):
|
|||
self.create_context.project_name, instances
|
||||
)
|
||||
|
||||
def get_product_alias(self):
|
||||
"""Return product alias for the creator.
|
||||
|
||||
Returns:
|
||||
str: Product alias.
|
||||
|
||||
"""
|
||||
return get_alias_for_product_type(
|
||||
self.product_type, self.project_settings)
|
||||
|
||||
|
||||
class Creator(BaseCreator):
|
||||
"""Creator that has more information for artist to show in UI.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from ayon_core.lib import (
|
|||
prepare_template_data,
|
||||
)
|
||||
|
||||
from ayon_core.pipeline import get_alias_for_product_type
|
||||
from ayon_core.pipeline.product_type_aliases import get_alias_for_product_type
|
||||
from ayon_core.settings import get_project_settings
|
||||
|
||||
from .constants import DEFAULT_PRODUCT_TEMPLATE
|
||||
|
|
|
|||
|
|
@ -3,27 +3,18 @@ from __future__ import annotations
|
|||
|
||||
from typing import Optional
|
||||
|
||||
from ayon_core.settings import get_project_settings
|
||||
from ayon_core.pipeline import get_current_project_name
|
||||
|
||||
def get_product_type_aliases(
|
||||
project_settings: Optional[dict] = None) -> dict[str, str]:
|
||||
def get_product_type_aliases(project_settings: dict) -> list[dict[str,str]]:
|
||||
"""Get product type aliases from project settings.
|
||||
|
||||
Args:
|
||||
project_settings (Optional[dict], optional): Project settings.
|
||||
Defaults to None. If not passed, the current project settings
|
||||
will be used.
|
||||
project_settings (dict): Project settings.
|
||||
|
||||
Returns:
|
||||
dict[str, str]: A dictionary of product type aliases.
|
||||
list[dict[str, str]: A list of product type aliases.
|
||||
|
||||
"""
|
||||
if project_settings is None:
|
||||
project_settings = get_project_settings(
|
||||
project_name=get_current_project_name())
|
||||
|
||||
product_type_aliases_raw = project_settings.get("product_type_aliases", {})
|
||||
product_type_aliases_raw = project_settings["core"].get(
|
||||
"product_type_aliases", {})
|
||||
if not product_type_aliases_raw:
|
||||
return {}
|
||||
|
||||
|
|
@ -32,19 +23,27 @@ def get_product_type_aliases(
|
|||
|
||||
def get_alias_for_product_type(
|
||||
product_type: str,
|
||||
project_settings: Optional[dict] = None
|
||||
) -> Optional[str]:
|
||||
project_settings: dict
|
||||
) -> str:
|
||||
"""Get the alias for a product type.
|
||||
|
||||
Args:
|
||||
product_type (str): The product type to get the alias for.
|
||||
project_settings (Optional[dict], optional): Project settings.
|
||||
project_settings (dict): Project settings.
|
||||
Defaults to None. If not passed, the current project settings
|
||||
will be used.
|
||||
|
||||
Returns:
|
||||
str: The alias for the product type. If no alias is found,
|
||||
None is returned.
|
||||
product_type is returned.
|
||||
"""
|
||||
product_type_aliases = get_product_type_aliases(project_settings)
|
||||
return product_type_aliases.get(product_type)
|
||||
product_type_aliases: list = get_product_type_aliases(project_settings)
|
||||
|
||||
return next(
|
||||
(
|
||||
alias_pair.get("alias")
|
||||
for alias_pair in product_type_aliases
|
||||
if alias_pair.get("base") == product_type
|
||||
),
|
||||
product_type,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ class CreatorItem:
|
|||
identifier: str,
|
||||
creator_type: CreatorType,
|
||||
product_type: str,
|
||||
product_alias: str,
|
||||
label: str,
|
||||
group_label: str,
|
||||
icon: Union[str, Dict[str, Any], None],
|
||||
|
|
@ -103,6 +104,7 @@ class CreatorItem:
|
|||
self.identifier: str = identifier
|
||||
self.creator_type: CreatorType = creator_type
|
||||
self.product_type: str = product_type
|
||||
self.product_alias: str = product_alias
|
||||
self.label: str = label
|
||||
self.group_label: str = group_label
|
||||
self.icon: Union[str, Dict[str, Any], None] = icon
|
||||
|
|
@ -155,6 +157,7 @@ class CreatorItem:
|
|||
identifier,
|
||||
creator_type,
|
||||
creator.product_type,
|
||||
creator.get_product_alias(),
|
||||
creator.label or identifier,
|
||||
creator.get_group_label(),
|
||||
creator.get_icon(),
|
||||
|
|
@ -179,6 +182,7 @@ class CreatorItem:
|
|||
"identifier": self.identifier,
|
||||
"creator_type": str(self.creator_type),
|
||||
"product_type": self.product_type,
|
||||
"product_alias": self.product_alias,
|
||||
"label": self.label,
|
||||
"group_label": self.group_label,
|
||||
"icon": self.icon,
|
||||
|
|
|
|||
|
|
@ -89,7 +89,13 @@ class CreatorShortDescWidget(QtWidgets.QWidget):
|
|||
description = creator_item.description or ""
|
||||
|
||||
self._icon_widget.set_icon_def(plugin_icon)
|
||||
self._product_type_label.setText("<b>{}</b>".format(creator_item.product_type))
|
||||
if creator_item.product_alias:
|
||||
self._product_type_label.setText(
|
||||
"<b>{}</b> ({})".format(
|
||||
creator_item.product_alias, creator_item.product_type))
|
||||
else:
|
||||
self._product_type_label.setText(
|
||||
"<b>{}</b>".format(creator_item.product_type))
|
||||
self._product_type_label.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
|
||||
self._description_label.setText(description)
|
||||
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ class FilterEnvsProfileModel(BaseSettingsModel):
|
|||
|
||||
|
||||
class ProductAliasMappingItemModel(BaseSettingsModel):
|
||||
_layout = "expanded"
|
||||
_layout = "compact"
|
||||
base: str = SettingsField("", title="Base product type")
|
||||
alias: str = SettingsField("", title="Alias name")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue