Workarounds for APIv1 issues

This commit is contained in:
sneakypete81 2013-05-06 21:27:31 +01:00
parent 853256cc1f
commit c4ea338f49
2 changed files with 14 additions and 2 deletions

View file

@ -114,6 +114,11 @@ class Photo(OpenPhotoObject):
""" """
new_dict = self._openphoto.post("/photo/%s/transform.json" % self.id, new_dict = self._openphoto.post("/photo/%s/transform.json" % self.id,
**kwds)["result"] **kwds)["result"]
# APIv1 doesn't return the transformed photo (frontend issue #955)
if isinstance(new_dict, bool):
new_dict = self._openphoto.get("/photo/%s/view.json" % self.id)["result"]
self._replace_fields(new_dict) self._replace_fields(new_dict)
class Tag(OpenPhotoObject): class Tag(OpenPhotoObject):
@ -173,6 +178,11 @@ class Album(OpenPhotoObject):
""" Update this album with the specified parameters """ """ Update this album with the specified parameters """
new_dict = self._openphoto.post("/album/%s/update.json" % self.id, new_dict = self._openphoto.post("/album/%s/update.json" % self.id,
**kwds)["result"] **kwds)["result"]
# APIv1 doesn't return the updated album (frontend issue #937)
if isinstance(new_dict, bool):
new_dict = self._openphoto.get("/album/%s/view.json" % self.id)["result"]
self._replace_fields(new_dict) self._replace_fields(new_dict)
self._update_fields_with_objects() self._update_fields_with_objects()

View file

@ -1,3 +1,4 @@
import unittest
from tests import test_albums, test_photos, test_tags from tests import test_albums, test_photos, test_tags
class TestAlbumsV1(test_albums.TestAlbums): class TestAlbumsV1(test_albums.TestAlbums):
@ -6,5 +7,6 @@ class TestAlbumsV1(test_albums.TestAlbums):
class TestPhotosV1(test_photos.TestPhotos): class TestPhotosV1(test_photos.TestPhotos):
api_version = 1 api_version = 1
class TestTagsV1(test_tags.TestTags): # The tag API didn't work at v1 - see frontend issue #927
api_version = 1 # class TestTagsV1(test_tags.TestTags):
# api_version = 1