Next/previous now returns a list of multiple photos (Issue #1004)

This commit is contained in:
Pete 2013-02-09 17:10:44 +00:00 committed by sneakypete81
parent 4ccdceb601
commit 895b98dedf
3 changed files with 16 additions and 9 deletions

View file

@ -74,14 +74,21 @@ class Photo(OpenPhotoObject):
raise NotImplementedError()
def next_previous(self, **kwds):
""" Returns a dict containing the next and previous photo objects """
"""
Returns a dict containing the next and previous photo lists
(there may be more than one next/previous photo returned).
"""
result = self._openphoto.get("/photo/%s/nextprevious.json" % self.id,
**kwds)["result"]
value = {}
if "next" in result:
value["next"] = Photo(self._openphoto, result["next"])
value["next"] = []
for photo in result["next"]:
value["next"].append(Photo(self._openphoto, photo))
if "previous" in result:
value["previous"] = Photo(self._openphoto, result["previous"])
value["previous"] = []
for photo in result["previous"]:
value["previous"].append(Photo(self._openphoto, photo))
return value
def transform(self, **kwds):