Commit Graph

280 Commits

Author SHA1 Message Date
Bharat Mediratta
923a515ffb The user must have some edit permission somewhere to create a tag 2010-01-30 11:48:43 -08:00
Bharat Mediratta
a04d0d2789 Add missing permission checks.
Make the tag relationship an associative array.
2010-01-29 19:42:38 -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
cfbbf9ef60 Convert __toString() to use (string) cast instead. 2010-01-27 21:58:06 -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
7667864d61 Minor test-only fixes. 2010-01-27 09:55:00 -08:00
Bharat Mediratta
f268128043 Add support for adding tags in the item_tags and tag_items
relationship collections.
2010-01-26 00:24:10 -08:00
Bharat Mediratta
cc79abd0af Simplify tag::add(). 2010-01-24 14:00:07 -08:00
Bharat Mediratta
a609694018 Update tests for recent REST changes. 2010-01-23 12:13:14 -08:00
Bharat Mediratta
eea27c39f1 Create symmetrical relationship collections: item_tags and tag_items
Now when we represent a relationship collection we can refer to it in
proper semantic terms.
2010-01-22 09:43:02 -08:00
Bharat Mediratta
a445a64bcb Return the url of the newly created item from post(). 2010-01-22 01:10:00 -08:00
Bharat Mediratta
ca909a49ae New tests for tag_item_rest 2010-01-22 01:09:38 -08:00
Bharat Mediratta
10dfe9767d Updated tests to pass after recent refactor of tag_rest. 2010-01-22 00:59:37 -08:00
Bharat Mediratta
27acb156bc Updated tests to pass after recent refactor of tags_rest. 2010-01-22 00:51:23 -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
Bharat Mediratta
3665391f8b Guard against division by zero. 2010-01-21 21:29:42 -08:00
Bharat Mediratta
6be5a71cc2 Actually deny permissions in delete_item_from_tag_fails_without_permissions_test().. 2010-01-21 20:16:57 -08:00
Bharat Mediratta
697d84457f Rewrite and greatly simplify the tests for the new tag_rest implementation. 2010-01-20 21:15:11 -08:00
Bharat Mediratta
3d4a6d6336 Remove unused untagging code from put()
Add access permissions to delete()
Remove unnecessary return value from delete()
2010-01-20 21:14:40 -08:00
Bharat Mediratta
8bf73d4b4c New test for tags_rest.php 2010-01-20 00:52:32 -08:00
Bharat Mediratta
276d7de5b6 Simplify and update for model based validation. 2010-01-20 00:14:05 -08:00
Bharat Mediratta
76da85a1a0 Extend Gallery_Unit_Test_Case instead of Unit_Test_Case. 2010-01-19 22:38:19 -08:00
Bharat Mediratta
0b5ce9dbc1 Fix a typo: $item -> $tag. 2010-01-19 01:36:15 -08:00
Bharat Mediratta
549b88643a Fix a typo "tags" -> "tag" 2010-01-19 01:35:59 -08:00
Bharat Mediratta
c590fed132 Change rest::url() to take a module name and a resource. The module
does the rest.  This function is symmetrical to rest::resolve.
2010-01-19 01:33:57 -08:00
Bharat Mediratta
ebb909625c Merge branch 'master' into bharat_dev 2010-01-18 12:54:26 -08:00
Bharat Mediratta
9384f987bb Coerce some integers to strings now that ORM isn't typecasting anymore. 2010-01-18 12:52:52 -08:00
Bharat Mediratta
9e9c5397b7 Qualify the Bad Request output when the name is missing 2010-01-17 16:59:25 -08:00
Bharat Mediratta
bb79a1455a Remove unnecessary comment. 2010-01-17 16:55:11 -08:00
Bharat Mediratta
5c49c041e7 Use "(string) $form" instead of "$form->__toString()" 2010-01-16 22:42:02 -08:00
Bharat Mediratta
31454d37b3 Improve REST tag support.
- Add support for retrieving a list of members from a collection
- Implement put(), post() and delete() for tags.
- Use tag_rest::delete() as a way to remove members from the tag collection
2010-01-05 13:41:06 -08:00
Bharat Mediratta
c5d1443895 $offset should be null by default, not 0. Hold over bug from the K24 migration. 2010-01-05 12:05:37 -08:00
Bharat Mediratta
d18be7fe55 $offset should be null by default, not 0. Hold over bug from the K24 migration. 2010-01-05 12:05:22 -08:00
Bharat Mediratta
3fffa18e65 Further progress on refining the REST server side code.
1) Deal in fully qualified URL resources through the rest
   interface.  All rest methods are now passed the complete url in
   request->url.

2) Create rest::resolve() which lets individual resource definition
   code convert a full url into the appropriate matching resource.
   Implement gallery_rest::resolve() and tag_rest::resolve()

3) Reimplement tag_rest's get() and post() methods.  They're much
   simpler now.

4) Implement the tags_rest helper which supports working with the
   entire tags collection.
2010-01-04 21:48:21 -08:00
Bharat Mediratta
0e3327bca7 Simplify the REST API code. Here's what I did:
1) Simplify gallery_rest to return flat models, no children and do no
   validation for now.
2) Flatten the REST replies and use HTTP codes to indicate
   success/failure instead of additional status messages.
3) Use the message and error code support in the base Exception class,
   instead of brewing our own in Rest_Exception.
4) Get rid of rest::success() and rest::fail() -- we only need
   rest::reply() since all failures are covered by throwing an
   exception.
5) Get rid of /rest/access_key and just use /rest for authentication.
6) Inline and simplify rest::normalize_request since we only use it once
7) Change rest::set_active_user to succeed or throw an exception
8) Extract Rest_Exception::sendHeaders into rest::send_headers()

Here's what's currently broken:
1) Data validation.  There currently is none
2) Logging.  That's gone too
3) image block and tag code is broken
4) Tests are broken
5) No movie support
2010-01-03 20:30:35 -08:00
Tim Almdal
5b9801092b Remove the Rest_Exception::trigger method. 2010-01-02 16:55:06 -08:00
Tim Almdal
ff95c4079e Fix the tag_rest helper tests 2010-01-02 15:48:54 -08:00
Tim Almdal
28597ba533 Correct file structure tests, Have the tests delete the userid they create so as not to impact other tests. 2010-01-02 14:31:59 -08:00
Tim Almdal
40d496edee Remove extra debug statement in rest_controller::access_key() and restructure the Rest_Tag_Helper_Test to only create items as required for test in each test. 2009-12-31 13:24:00 -08:00
Tim Almdal
1a12a5e3c8 Create a Rest_Exception class and use it to convey status to the client instead of calling rest::forbidden and other rest helper error messages. 2009-12-31 11:51:51 -08:00
Tim Almdal
11792a12bb 1) Remove the rest::not_found method and replace it with "throw new Kohana_404_Exception
2) Don't use the input path to lookup the item via relative_path_cache.  Instead use url::get_item_from_uri method.
2009-12-30 17:08:01 -08:00
Bharat Mediratta
5d6e264211 whitespace. 2009-12-30 12:07:24 -08:00
Tim Almdal
bccb6fc021 Clean up validation the check for duplicate names or slugs, finish converting the rest API to Kohana 2.4 2009-12-27 08:32:12 -08:00
Tim Almdal
3060a6f662 Merge branch 'master' into talmdal_dev
Conflicts:
	modules/gallery/controllers/albums.php
	modules/gallery/controllers/movies.php
	modules/gallery/controllers/photos.php
2009-12-26 11:24:50 -08:00
Tim Almdal
586f2d78b8 Add the functionality to add, delete and rename tags via the Gallery3 remote interface. 2009-12-24 19:25:14 -08:00
Bharat Mediratta
057e8d09af Convert a bunch of leftover kohana::show_404 calls to throw
Kohana_404_Exception instead.  These are the ones where we used a
lower-case 'k' so my previous filter didn't catch it.
2009-12-23 20:51:33 -08:00
Tim Almdal
cf6de01f1e Provide a REST interface to retrieve tags or tagged items.
GET  /tag?limit=nn,offset=nn  Retrieve all tags sorted by count descending
GET  /tag/uri/uri/uri         Retrieve all the tags for the resource specified by path
GET  /tag/t1/t2/t3            Retrieve all the items that have the specified tags
                              Can specifiy limit and offset to limit response size
2009-12-23 14:20:23 -08:00
Bharat Mediratta
8b9a02084a Updates for the latest version of Kohana 2.4:
1) Controller::$input is gone -- use Input::instance() now
2) Handle new 'database.<default>.connection.params' parameter
3) Handle new 'cache.<default>.prefix' parameter
2009-12-21 21:27:43 -08:00
Bharat Mediratta
046382c3e7 Remove some unused references to Database::instance() 2009-12-18 11:27:44 -08:00
Bharat Mediratta
2f5c612036 Update database queries. 2009-12-06 21:33:17 -08:00