Skip to content
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

Implement custom view objects #1195

Merged
merged 7 commits into from
Feb 21, 2023
Merged

Implement custom view objects #1195

merged 7 commits into from
Feb 21, 2023

Conversation

jacalata
Copy link
Contributor

They are not quite the same as normal views so they got their own class.

You can

  • Get a list of custom views on a site
  • Get the details of a custom view
  • Export an image of a custom view.
  • Delete a custom view
  • Update the name or owner of a custom view.

Note that you can only export as image(png) - no csv or pdf export is available.
This will enable the feature to be added to tabcmd - yay!

Also added custom view operations to the workbook sample
I removed the user_model tests because I already removed the requirement for user.name to be populated. The custom view owner might only have an id.
@@ -74,6 +74,10 @@ def main():
if all_workbooks:
# Pick one workbook from the list
sample_workbook = all_workbooks[0]
sample_workbook.name = "Name me something cooler"
sample_workbook.description = "That doesn't work"

Choose a reason for hiding this comment

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

To confirm, updating the description doesn't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - it's an open bug, hopefully fixed soon.

if not view_item.id:
error = "Custom view item missing ID."
raise MissingRequiredFieldError(error)
if not (view_item.owner or view_item.name or view_item.shared):

Choose a reason for hiding this comment

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

I don't see anything about updating the shared property in the REST API docs. Is the check on view_item.shared necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's aspirational. Actually sending a value now wouldn't work, but this means that it will work in tsc as soon as the REST API supports it.

Choose a reason for hiding this comment

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

Gotcha. But might this condition prevent someone from changing a shared CV to be not-shared?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No - this condition is just saying that if the user hasn't set any values on the view_item, don't bother sending an update request. Currently we'll send a request if they change the shared attribute, but that will fail.

Copy link

Choose a reason for hiding this comment

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

Hmm, if a user did not specify a value for either owner or name but set shared to False, we'd still not bother to send an update request? Does Python distinguish between None and False in conditional statements?

if parsed_views and len(parsed_views) > 0:
cv_item._view = parsed_views[0]

if workbook_id:

Choose a reason for hiding this comment

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

For my knowledge, what is the reasoning behind favoring this workbook_id override instead of always parsing the XML response?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is matching the behavior in view_item.py, where I believe the reasoning was
a) our Fields implementation means a View response doesn't have to contain a workbook element, but the user quite likely has the workbook id available
and b) if both the parameter and the xml element are available, we want a consistent priority order and chose this order as least likely to surprise a user: if they pass in a value, they will know where it came from when it shows up.

@jacalata jacalata merged commit c7d0ba5 into development Feb 21, 2023
@jacalata jacalata deleted the jac/custom-views branch February 21, 2023 11:21
jacalata added a commit that referenced this pull request Mar 16, 2023
* Implement custom view objects (#1195)
* Fix bug in update-datasources before 3.15 (#1203) (fixes #1072)
* catch exceptions from ServerInfo (#1204)
* add query-tagging attribute to connection (#1202) (add explanation for why it doesn't work on hyper)

---------

Co-authored-by: Marwan Baghdad <mrwanbaghdad76@gmail.com>
Co-authored-by: jorwoods <jorwoods@users.noreply.github.com>
Co-authored-by: Brian Cantoni <bcantoni@salesforce.com>
Co-authored-by: TrimPeachu <77048868+TrimPeachu@users.noreply.github.com>
Co-authored-by: Stu Tomlinson <stu@nosnilmot.com>
Co-authored-by: Jeremy Harris <jercharris89@gmail.com>
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.

None yet

2 participants