Added children function

Allows to retrieve children of a file record.
This commit is contained in:
2015-09-08 15:09:05 +02:00
parent 991cc27e30
commit 680195c7b4

View File

@@ -37,3 +37,17 @@ class File(List, Find, Create, Post, Update, Delete, Replace):
url = utils.join_url(self.build_previews_server_path, path)
api.get(url)
return self.success()
def children(self, api=None):
"""Collect children (variations) of the current file. Used to connect
different resolutions of the same picture, or multiple versions of the
same video in different formats/containers.
TODO: add params to support pagination.
"""
api = api or self.api
files = self.all({'where': '{"parent": "%s"}' % self._id}, api=api)
print files._items
if not files._items:
return None
return files