Merge lp://staging/~mhall119/ubuntu-accomplishments-web/add-json-service into lp://staging/ubuntu-accomplishments-web

Proposed by Michael Hall
Status: Merged
Merged at revision: 162
Proposed branch: lp://staging/~mhall119/ubuntu-accomplishments-web/add-json-service
Merge into: lp://staging/ubuntu-accomplishments-web
Diff against target: 291 lines (+260/-0)
5 files modified
services/__init__.py (+6/-0)
services/handler.py (+161/-0)
services/urls.py (+15/-0)
services/views.py (+77/-0)
urls.py (+1/-0)
To merge this branch: bzr merge lp://staging/~mhall119/ubuntu-accomplishments-web/add-json-service
Reviewer Review Type Date Requested Status
ubuntu-accomplishments-web-editor-drivers Pending
Review via email: mp+110575@code.staging.launchpad.net

Commit message

Add basic REST/JSON service for accomplishments and user trophies

Description of the change

Adds a /api/ base path with the following JSON services:

/api/user/[id] returns users.models.UserProfile (username and id only)
/api/accomplishment/[id] returns common.models.Accomplishment data
/api/collection/[id] returns common.models.Collection data
/api/category/[id] returns common.models.Category data
/api/icon/[id] returns common.models.Icon data

All of the above, when not using an id, can be filtered using ?field=value in the URL

/api/trophies/[username]/ returns the same data as /gallery/trophies/[username]/all/

To post a comment you must log in.
Revision history for this message
Gabriel Patiño (gepatino) wrote :

Very nice, I have some comments/questions:

* if an entity is not found (wrong id in the url) wouldn't it be better to return a 404 status code?
  * the same for the unsupported operations (the api could return a 501 Not Implemented, 400 Bad Request, 403 Forbidden, or something like that)
* I would remove the code not relevant to the web gallery (room, agenda, participant, crew, etc)

my two cents

Revision history for this message
Janos Gyerik (janos-gyerik) wrote :

> * if an entity is not found (wrong id in the url) wouldn't it be better to return a 404 status code?

Yup that would be nice!

>  * the same for the unsupported operations (the api could return a 501 Not Implemented, 400 Bad Request, 403 Forbidden,  or something like that)

Yup yup!

> * I would remove the code not relevant to the web gallery (room, agenda, participant, crew, etc)

Yeah and in fact there's more commented code in editor/models too, I
think they can all go.

Thanks guys!
Janos

--
Janos Gyerik
http://titan2x.com/

Revision history for this message
Janos Gyerik (janos-gyerik) wrote :

Uhm, sorry, I think I answered too fast. See my revised responses below.

>> * if an entity is not found (wrong id in the url) wouldn't it be better to return a 404 status code?
>
> Yup that would be nice!

No, hold that thought. It's like in django when you do a filter and
nothing matches, it returns an empty list, not some error. So for
things that are like filter(..), empty list response is appropriate,
for things like get(..), some http error may be better. Let's come
back to this later.

>>  * the same for the unsupported operations (the api could return a 501 Not Implemented, 400 Bad Request, 403 Forbidden,  or something like that)
>
> Yup yup!

I'm not sure what you mean, and I haven't tested it enough. Let's discuss later.

Cheers,
Janos
--
Janos Gyerik
http://titan2x.com/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches