-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ticket/28441 hide template projects by default #79
Draft
nemoDreamer
wants to merge
3
commits into
master
Choose a base branch
from
ticket/28441_hide_template_projects_by_default
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+345
−54
Draft
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
For #28441: refactored to clean up duplication in flag checks
commit d5914e49b00ef605ce213d3a174004091088499b
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,7 +134,7 @@ def __init__(self, host, meta): | |
self.is_dev = False | ||
|
||
self.version = tuple(self.version[:3]) | ||
self._ensure_json_supported() | ||
self.ensure_json_supported() | ||
|
||
|
||
def _ensure_support(self, feature, raise_hell=True): | ||
|
@@ -157,23 +157,23 @@ def _ensure_support(self, feature, raise_hell=True): | |
return True | ||
|
||
|
||
def _ensure_json_supported(self): | ||
def ensure_json_supported(self): | ||
"""Wrapper for ensure_support""" | ||
self._ensure_support({ | ||
return self._ensure_support({ | ||
'version': (2, 4, 0), | ||
'label': 'JSON API' | ||
}) | ||
|
||
def ensure_include_archived_projects(self): | ||
"""Wrapper for ensure_support""" | ||
self._ensure_support({ | ||
return self._ensure_support({ | ||
'version': (5, 3, 14), | ||
'label': 'include_archived_projects parameter' | ||
}) | ||
|
||
def ensure_include_template_projects(self): | ||
"""Wrapper for ensure_support""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. value not documented. |
||
self._ensure_support({ | ||
return self._ensure_support({ | ||
'version': (6, 0, 0), | ||
'label': 'include_template_projects parameter' | ||
}) | ||
|
@@ -525,7 +525,7 @@ def find_one(self, entity_type, filters, fields=None, order=None, | |
:param include_template_projects: Optional, flag to include entities | ||
belonging to template projects. Default: False | ||
|
||
:returns: Result | ||
:returns: dict of requested entity's fields, or None if not found. | ||
""" | ||
|
||
results = self.find(entity_type, filters, fields, order, | ||
|
@@ -588,22 +588,13 @@ def find(self, entity_type, filters, fields=None, order=None, | |
raise ShotgunError("Deprecated: Use of filter_operator for find()" | ||
" is not valid any more. See the documentation on find()") | ||
|
||
if not include_archived_projects: | ||
# This defaults to True on the server (no argument is sent) | ||
# So we only need to check the server version if it is False | ||
self.server_caps.ensure_include_archived_projects() | ||
|
||
if include_template_projects: | ||
# This defaults to False on the server (no argument is sent) | ||
# So we only need to check the server version if it is True | ||
self.server_caps.ensure_include_template_projects() | ||
|
||
|
||
params = self._construct_read_parameters(entity_type, | ||
fields, | ||
filters, | ||
retired_only, | ||
order, | ||
order) | ||
|
||
params = self._construct_flag_parameters(params, | ||
include_archived_projects, | ||
include_template_projects) | ||
|
||
|
@@ -642,31 +633,24 @@ def find(self, entity_type, filters, fields=None, order=None, | |
return self._parse_records(records) | ||
|
||
|
||
|
||
def _construct_read_parameters(self, | ||
entity_type, | ||
fields, | ||
filters, | ||
retired_only, | ||
order, | ||
include_archived_projects, | ||
include_template_projects): | ||
params = {} | ||
params["type"] = entity_type | ||
params["return_fields"] = fields or ["id"] | ||
params["filters"] = filters | ||
params["return_only"] = (retired_only and 'retired') or "active" | ||
params["return_paging_info"] = True | ||
params["paging"] = { "entities_per_page": self.config.records_per_page, | ||
"current_page": 1 } | ||
|
||
if include_archived_projects is False: | ||
# Defaults to True on the server, so only pass it if it's False | ||
params["include_archived_projects"] = False | ||
order): | ||
|
||
if include_template_projects is True: | ||
# Defaults to False on the server, so only pass it if it's True | ||
params["include_template_projects"] = True | ||
params = { | ||
"type": entity_type, | ||
"return_fields": fields or ["id"], | ||
"filters": filters, | ||
"return_only": (retired_only and 'retired') or "active", | ||
"return_paging_info": True, | ||
"paging": { | ||
"entities_per_page": self.config.records_per_page, | ||
"current_page": 1 | ||
} | ||
} | ||
|
||
if order: | ||
sort_list = [] | ||
|
@@ -680,6 +664,29 @@ def _construct_read_parameters(self, | |
'direction' : sort['direction'] | ||
}) | ||
params['sorts'] = sort_list | ||
|
||
return params | ||
|
||
|
||
def _construct_flag_parameters(self, | ||
params, | ||
include_archived_projects, | ||
include_template_projects): | ||
|
||
if not include_archived_projects: | ||
# This defaults to True on the server (no argument is sent) | ||
# So we only need to check the server version if it's False | ||
self.server_caps.ensure_include_archived_projects() | ||
# Only pass it if it's False | ||
params["include_archived_projects"] = False | ||
|
||
if include_template_projects: | ||
# This defaults to False on the server (no argument is sent) | ||
# So we only need to check the server version if it's True | ||
self.server_caps.ensure_include_template_projects() | ||
# Only pass it if it's True | ||
params["include_template_projects"] = True | ||
|
||
return params | ||
|
||
|
||
|
@@ -715,19 +722,9 @@ def summarize(self, | |
"summaries": summary_fields, | ||
"filters": filters} | ||
|
||
if not include_archived_projects: | ||
# This defaults to True on the server (no argument is sent) | ||
# So we only need to check the server version if it is False | ||
self.server_caps.ensure_include_archived_projects() | ||
# Only pass it if it's False | ||
params["include_archived_projects"] = False | ||
|
||
if include_template_projects: | ||
# This defaults to False on the server (no argument is sent) | ||
# So we only need to check the server version if it is True | ||
self.server_caps.ensure_include_template_projects() | ||
# Only pass it if it's True | ||
params["include_template_projects"] = True | ||
params = self._construct_flag_parameters(params, | ||
include_archived_projects, | ||
include_template_projects) | ||
|
||
if grouping != None: | ||
params['grouping'] = grouping | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value not documented.