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.
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.
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.
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.
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.
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 😃