-
Notifications
You must be signed in to change notification settings - Fork 57
Support "List/Edit Custom Fields" endpoints #181
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
base: master
Are you sure you want to change the base?
Support "List/Edit Custom Fields" endpoints #181
Conversation
…ed to collection items
|
Great news! Please go ahead and tell me when it's ready for a first review. No comments so far! |
| release_id = release.id if isinstance(release, Release) else release | ||
| return PaginatedList(self.client,self.fetch('resource_url') + "/collection/releases/{}".format(release_id) , "releases", CollectionItemInstance) | ||
|
|
||
| def update_collection_item_field(self, instance, field_id, value): |
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.
This was a bit difficult to find a place for as the endpoint needs the users username, so this method cannot be in CollectionItemInstance directly.
|
|
||
| resp = self.client._get(self.fetch('resource_url') + "/collection/fields") | ||
| # CollectionField's are keyed by their ID so they can be queried with field IDs from CollectionItemInstance's notes | ||
| return {int(field["id"]): CollectionField(self.client, field) for field in resp.get("fields", [])} |
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.
Not sure about using a simple dict {folder_id, CollectionField}.
Should this be a class that holds the collection of CollectionFields and maybe has a find_by_id() method for searching by field_id?
| rating = SimpleField() #: | ||
| folder_id = SimpleField() #: | ||
| notes = SimpleField() #: | ||
| notes = ListField('Note') #: |
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.
This needs proper testing as this could potentially be a breaking change if we are not careful.
| Returns: | ||
| list: The list of available options for the collection field. | ||
| """ | ||
| return self.fetch('options', []) |
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.
Not sure if this should be a SimpleField instead...
A getter would provide a better dev experience to not have to check for None.
print(", ".join(field.options))
# VS.
print(", ".join(field.options or [])Thoughts?
| def __repr__(self): | ||
| return '<CollectionField {0!r} {1!r}>'.format(self.id, self.name) | ||
|
|
||
| class Note(SecondaryAPIObject, dict): |
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.
Added this so the client api would be a bit cleaner and not need dict.get('value', '') or such.
Added support for the following endpoints:
Tasklist:
Usage:
Finding the matching field and its information for each assigned note/field in a collection item.
Editing/Adding custom fields / notes in a collection item
#TODO@JOJ0 I'll be working on this for the weekend at least. If you can give some feedback on this (improvements, bugs, documentation), it would be much appreciated 😃