Commit Graph

21 Commits

Author SHA1 Message Date
Tim Almdal
9504f71efc Fix for ticket #1118. Create a item::save_with_retries helper method, which encapsulates saving an item and handling name and slug conflicts. Call this instead of doing a save directly. 2010-06-15 14:18:23 -07:00
Tim Almdal
2492280cc0 Change the item rest update processing to call the item::move(source, target) helper when the parent member has changed. Using the move method insures that names and slugs that could conflict in the target album are resolved properly. Changed the item::move method so it returns a message to be displayed if the caller chooses. And changed the move controller to display the message returned by the move if the item name was renamed as part of the move. 2010-06-15 12:52:28 -07:00
Tim Almdal
207f6beb61 Only change the weights of the album children if the item sort_column is set to weight. 2010-06-15 11:40:01 -07:00
Tim Almdal
00c4cb3f63 Revert "Change the item rest update processing to call the itemm::move(source, target) helper when the parent member has changed. Using the move method insures that names and slugs that could conflict in the target album are resolved properly. Also, only change the weights of the album children if the item sort_column is set to weight."
This reverts commit 603d464014.
2010-06-15 11:38:46 -07:00
Tim Almdal
603d464014 Change the item rest update processing to call the itemm::move(source, target) helper when the parent member has changed. Using the move method insures that names and slugs that could conflict in the target album are resolved properly. Also, only change the weights of the album children if the item sort_column is set to weight. 2010-06-15 11:20:04 -07:00
Tim Almdal
d5b80f2944 Don't use the standard error formatting for exceptions that have occurred as part of a REST request. Format the exception as a json encoded text string so the client can extract the fault information if they so choose. 2010-06-08 14:35:35 -07:00
Tim Almdal
097ef934c6 Merge branch 'master' into talmdal_dev 2010-06-06 15:45:03 -07:00
Bharat Mediratta
aeee88031f Fix an unused variable caused by converting straight query params
to $entity based params.
2010-06-06 13:06:08 -07:00
Tim Almdal
ae595795f0 If the file is empty (i.e. the upload failed, then throw a 'bad request' exception before trying to create the item. 2010-05-28 09:42:44 -07:00
Tim Almdal
73c7ec5310 Save the item before updating the order of the children. Also always increment the weight count (even if it is equal to the weight of the current child) 2010-05-18 06:16:47 -07:00
Tim Almdal
a2e0472f83 Only return the members element to the rest client if the item is an album. This makes it consistent to the rest client that collections will have a members element. 2010-04-16 14:30:41 -07:00
Bharat Mediratta
5679e30ef6 REST changes: Allow PUT and POST requests to modify members, not
just entity.

TESTS ARE NOT UPDATED YET.

- Fix item_rest::get() to maintain the proper sort order, which
  requires duplicating some Item_Model code.

- Elide "weight" from the REST version of item

- Adjust the weight of members according to the order they're returned
  from the client.  You can't add or remove members here, you can only
  reorder them.

- Changed the wire protocol to handle more complex values.
  Now "entity" and "members" are JSON encoded.  The Gallery3
  helper does this correctly.

- Changed the wire protocol for tag_item -- now it stores the
  tag and item urls in the entity, not as members.  This is more
  consistent.

- Added missing security for renaming and deleting tags.

- Got rid of vestigial tag_rest::post().  We add/remove tags
  via the relationship.
2010-04-04 11:55:54 -07:00
Bharat Mediratta
c3c2b45280 Update the copyright to 2010. It's only 3 months into the year :-) 2010-03-03 10:15:34 -08:00
Bharat Mediratta
ce71ea6aa7 Revert "1) Add a depth parameter to retrieving an item thru the rest api"
This reverts commit 3439671bcf.
2010-02-12 04:53:26 -08:00
Tim Almdal
3439671bcf 1) Add a depth parameter to retrieving an item thru the rest api
2) Standardize the structure of members so that client programs can consistently
   parse the return information.
3) Added a summary parameter so that client programs can easily determine if the
   information returned is summary (item type, item title) or the full meal deal
2010-02-12 09:52:57 -08:00
Bharat Mediratta
a79d20a361 Use Item_Model::as_restful_array() to simplify tests. 2010-01-30 23:36:41 -08:00
Bharat Mediratta
a161436015 Remap parent_id and album_cover_item_id to and from RESTful urls. 2010-01-30 15:46:35 -08:00
Bharat Mediratta
4b32a71afc Convert back to using ORM::factory(..., $id) instead of calling where(). 2010-01-27 22:34:11 -08:00
Bharat Mediratta
ec0f89f10a Change "resource" to "entity" in REST responses. They're all
resources, but we differentiate resources as collections and entities.
2010-01-27 21:40:48 -08:00
Bharat Mediratta
0efbfcbe61 Return the url of the newly created item from post().
Don't try to access ORM::$changed -- it's protected.
2010-01-22 01:10:31 -08:00
Bharat Mediratta
bcf1caad14 Reshape the rest code to be more consistent with regards to
relationships.  Now when you view a resource, it has 4 top level
elements:

url: the url of this resource
resource: array of key value pairs describing the resource
members: array of urls to members of this collection
relationships: array of array of members.

Relationships are a special type of collection that links two
different resources together.  To remove a relationship, just
DELETE its url.  To create a relationship, POST to its
collection.

Individual modules can add their own relationships to any
resource via a callback mechanism.

Example:
  Array(
    [url] => http://g3.com/rest/item/1
    [resource] => Array (
      [id] => 1
      [album_cover_item_id] => 4
      [captured] =>
      [created] => 1264056417
      [description] =>
      [height] =>
      ...
    )
    [members] => Array(
      [0] => http://g3.com/rest/item/2
      [1] => http://g3.com/rest/item/3
      [2] => http://g3.com/rest/item/4
      [3] => http://g3.com/rest/item/5
      ...
    )
    [relationships] => Array(
      [tags] => Array (
      [0] => http://g3.com/rest/tag_item/2,1
      [1] => http://g3.com/rest/tag_item/23,1
      )
    )
  )
2010-01-22 00:27:00 -08:00