Skip to content

Conversation

@jfboismenu
Copy link
Contributor

Adds support for updating field visibility through the API.

This can be achieved by the following code:

sg.schema_field_update("Asset", "sg_my_custom_field", {"visible": False}, project)

where project is a dictionary referring to project in which we want to hide "sg_my_custom_field". Restoring visibility can be done via

sg.schema_field_update("Asset", "sg_my_custom_field", {"visible": True}, project)

Note: The build is currently failing because the feature hasn't been released in Shotgun. Once the feature is released the test will be updated to the right version check and the feature commited.

]
}

params = self._add_project_param(params, project_entity)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The server side simply expects the project to be passed in.

@jfboismenu jfboismenu requested a review from willis102 September 9, 2019 19:36
Copy link
Contributor

@willis102 willis102 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pointed out a couple little things. I'm guessing we'll need to wait for the feature release to get the version # for tests before we can release this? (Looks like CI is failing because of that now, anyways)

``visible`` property for. If the ``visible`` is present in ``properties`` and
``project_entity`` is not set, an exception will be raised. Example:
``{'type': 'Project', 'id': 3}``
:param project_entity: Link to the project we wish to change the field visibility for.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you've documented project_entity twice here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, does project_entity only apply for visible property? Is that something we want to call out more explicitly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Let me know what you think of my update.

Ensure the visibility of a field can be edited via the API.
"""
# If the version of Shotgun is too old, do not run this test.
# TODO: Update this with the real version number once the feature is released.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just highlighting this TODO.

@coveralls
Copy link

coveralls commented Sep 9, 2019

Pull Request Test Coverage Report for Build 1248

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 159 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.9%) to 68.723%

Files with Coverage Reduction New Missed Lines %
shotgun_api3/shotgun.py 159 82.78%
Totals Coverage Status
Change from base Build 1207: -0.9%
Covered Lines: 6752
Relevant Lines: 9825

💛 - Coveralls

@jfboismenu jfboismenu merged commit 0259a4c into master Sep 17, 2019
@jfboismenu jfboismenu deleted the ticket/SG-10151_set_visibility_via_api branch September 17, 2019 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants