Skip to content

Commit

Permalink
Modify shotgrid server settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jlorrain authored and ClementHector committed Feb 7, 2022
1 parent cbee6f9 commit 63223d3
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 47 deletions.
6 changes: 1 addition & 5 deletions openpype/settings/defaults/project_settings/shotgrid.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"shotgrid_project_id": 0,
"auth": {
"project_shotgrid_url": "",
"project_shotgrid_script_name": "",
"project_shotgrid_script_key": ""
},
"shotgrid_server": "",
"event": {
"enabled": false
},
Expand Down
6 changes: 2 additions & 4 deletions openpype/settings/defaults/system_settings/modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@
"shotgrid": {
"enabled": true,
"module_server_url": "",
"shotgrid_url": "",
"shotgrid_script_name": "",
"shotgrid_script_key": ""
"shotgrid_settings": {}
},
"timers_manager": {
"enabled": true,
Expand Down Expand Up @@ -212,4 +210,4 @@
"linux": ""
}
}
}
}
2 changes: 2 additions & 0 deletions openpype/settings/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
TaskTypeEnumEntity,
DeadlineUrlEnumEntity,
AnatomyTemplatesEnumEntity,
ShotgridUrlEnumEntity
)

from .list_entity import ListEntity
Expand Down Expand Up @@ -171,6 +172,7 @@
"ToolsEnumEntity",
"TaskTypeEnumEntity",
"DeadlineUrlEnumEntity",
"ShotgridUrlEnumEntity",
"AnatomyTemplatesEnumEntity",

"ListEntity",
Expand Down
39 changes: 39 additions & 0 deletions openpype/settings/entities/enum_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,45 @@ def set_override_state(self, *args, **kwargs):
self._current_value = tuple(self.valid_keys)[0]


class ShotgridUrlEnumEntity(BaseEnumEntity):
schema_types = ["shotgrid_url-enum"]

def _item_initialization(self):
self.multiselection = False

self.enum_items = []
self.valid_keys = set()

self.valid_value_types = (STRING_TYPE,)
self.value_on_not_set = ""

# GUI attribute
self.placeholder = self.schema_data.get("placeholder")

def _get_enum_values(self):
shotgrid_settings = self.get_entity_from_path(
"system_settings/modules/shotgrid/shotgrid_settings"
)

valid_keys = set()
enum_items_list = []
for server_name, settings in shotgrid_settings.items():
enum_items_list.append(
{server_name: "{}: {}".format(server_name, settings['shotgrid_url'].value)})
valid_keys.add(server_name)
return enum_items_list, valid_keys

def set_override_state(self, *args, **kwargs):
super(ShotgridUrlEnumEntity, self).set_override_state(*args, **kwargs)

self.enum_items, self.valid_keys = self._get_enum_values()
if not self.valid_keys:
self._current_value = ""

elif self._current_value not in self.valid_keys:
self._current_value = tuple(self.valid_keys)[0]


class AnatomyTemplatesEnumEntity(BaseEnumEntity):
schema_types = ["anatomy-templates-enum"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,9 @@
"label": "Shotgrid project id"
},
{
"type": "dict",
"key": "auth",
"label": "Authentication",
"collapsible": true,
"children": [
{
"type": "label",
"label": "You can specify a shotgun instance here, use System settings if you leave it blank"
},
{
"type": "text",
"key": "project_shotgrid_url",
"label": "Server URL"
},
{
"type": "text",
"key": "project_shotgrid_script_name",
"label": "Script Name"
},
{
"type": "text",
"key": "project_shotgrid_script_key",
"label": "Script Key"
}
]
"type": "shotgrid_url-enum",
"key": "shotgrid_server",
"label": "Shotgrid Server"
},
{
"type": "dict",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,29 @@
"label": "Module Server URL"
},
{
"type": "text",
"key": "shotgrid_url",
"label": "Shotgrid Server URL"
},
{
"type": "text",
"key": "shotgrid_script_name",
"label": "Shotgrid Script Name"
},
{
"type": "text",
"key": "shotgrid_script_key",
"label": "Shotgrid Script Key"
"type": "dict-modifiable",
"key": "shotgrid_settings",
"label": "Shotgrid Servers",
"object_type": {
"type": "dict",
"children": [
{
"key": "shotgrid_url",
"label": "Server URL",
"type": "text"
},
{
"key": "shotgrid_script_name",
"label": "Script Name",
"type": "text"
},
{
"key": "shotgrid_script_key",
"label": "Script api key",
"type": "text"
}
]
}
}
]
},
Expand Down

0 comments on commit 63223d3

Please sign in to comment.