Upload
mskmoorthy
View
634
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Citation preview
Initial PresentationFebruary 25, 2010
Progress
UIFinished WireframesCreated MockupsDecided on a color schemesIcon Set is going through revisionsUI Implementation - translate Photoshop mockup to CSSHTML structure & Django templates
REST APIManipulate TagsManipulate Audio Objects
Details on our wiki[1]
Mockup
See our blog post on waveform behavior[2]
Representational State Transfer (REST) API
Interface for manipulating resources over HTTP
REST HTTP methods
Resource GET PUT POST DELETE
Collection URI, such ashttp://example.com/resources/
List the collection's members.
Replace the entire collection with another collection.
Create a new entry in the collection.
Delete the entire collection.
Element URI, such ashttp://example.com/resources/142/
Retrieve addressed member of the collection.
Replace the addressed member of the collection, or if it doesn't exist,create it.
Treat the addressed member as a collection and create a new entry in it.
Delete the addressed member of the collection.
REST HTTP methods
Resource GET PUT POST DELETE
Collection URI, such ashttp://example.com/resources/
List the collection's members.
Replace the entire collection with another collection.
Create a new entry in the collection.
Delete the entire collection.
Element URI, such ashttp://example.com/resources/142/
Retrieve addressed member of the collection.
Replace the addressed member of the collection, or if it doesn't exist,create it.
Treat the addressed member as a collection and create a new entry in it.
Delete the addressed member of the collection.
REST HTTP methods
Resource GET PUT POST DELETE
Collection URI, such ashttp://example.com/resources/
List the collection's members.
Replace the entire collection with another collection.
Create a new entry in the collection.
Delete the entire collection.
Element URI, such ashttp://example.com/resources/142/
Retrieve addressed member of the collection.
Replace the addressed member of the collection, or if it doesn't exist,create it.
Treat the addressed member as a collection and create a new entry in it.
Delete the addressed member of the collection.
REST in Concert
Easily modify Django models from the frontend
See our previous presentation on Backbone.js[3]
But what does it all mean?POST http://localhost:8896/api/1/request/
{"collection":"/api/1/collection/1/", "user":"/api/1/user/2/"}
{ "collection": "/api/1/collection/1/", "id": "1", "resource_uri": "/api/1/request/1/", "status": "p", "user": "/api/1/user/2/" }
But what does it all mean?GET http://localhost:8896/api/1/request/
[ { "collection": "/api/1/collection/1/", "id": "1", "resource_uri": "/api/1/request/1/", "status": "p", "user": "/api/1/user/2/" } ]
How we do it.#### A collection join request. Should be deleted when action is taken.###class Request(models.Model): ... user = models.ForeignKey(User) collection = models.ForeignKey(Collection) status = models.CharField(max_length=1, choices=REQUEST_STATUS_CHOICES, default='p') ...
How we do it.
#### This is the resource that is used for a collection request.###class RequestResource(MyResource): user = fields.ForeignKey(UserResource, 'user') collection = fields.ForeignKey(CollectionResource, 'collection', full=True) status = fields.CharField('status', default='p') ...
#### A collection join request. Should be deleted when action is taken.###class Request(models.Model): ... user = models.ForeignKey(User) collection = models.ForeignKey(Collection) status = models.CharField(max_length=1, choices=REQUEST_STATUS_CHOICES, default='p') ...
tastypie
How we do it.
/** * A Collection object represents a django Collection object. * @class **/var Collection = ConcertBackboneModel.extend({ ... /** * When a user wants to join a collection. **/ requestToJoin: function() { var reqs = this.get('requests'); reqs.create({ user: com.concertsoundorganizer.page.user.url(), collection: this.url() }); } ...
#### This is the resource that is used for a collection request.###class RequestResource(MyResource): user = fields.ForeignKey(UserResource, 'user') collection = fields.ForeignKey(CollectionResource, 'collection', full=True) status = fields.CharField('status', default='p') ...
#### A collection join request. Should be deleted when action is taken.###class Request(models.Model): ... user = models.ForeignKey(User) collection = models.ForeignKey(Collection) status = models.CharField(max_length=1, choices=REQUEST_STATUS_CHOICES, default='p') ...
tastypie
How we do it.
/** * A Collection object represents a django Collection object. * @class **/var Collection = ConcertBackboneModel.extend({ ... /** * When a user wants to join a collection. **/ requestToJoin: function() { var reqs = this.get('requests'); reqs.create({ user: com.concertsoundorganizer.page.user.url(), collection: this.url() }); } ...
#### This is the resource that is used for a collection request.###class RequestResource(MyResource): user = fields.ForeignKey(UserResource, 'user') collection = fields.ForeignKey(CollectionResource, 'collection', full=True) status = fields.CharField('status', default='p') ...
#### A collection join request. Should be deleted when action is taken.###class Request(models.Model): ... user = models.ForeignKey(User) collection = models.ForeignKey(Collection) status = models.CharField(max_length=1, choices=REQUEST_STATUS_CHOICES, default='p') ...
tastypie
POST http://localhost:8896/api/1/request/{"collection":"/api/1/collection/1/", "user":"/api/1/user/2/"}
Issues
Concert Events
&
Many-To-Many Relationships
Issues
class Tag(models.Model): segments = models.ManyToManyField('AudioSegment', related_name = "tags") collection = models.ForeignKey('Collection') name = models.CharField(max_length = 100) time = models.DateTimeField(auto_now_add = True) creator = models.ForeignKey(User)
Old Way
Add URL: /add_segment_to_tag
Delete URL: /delete_segment_from_tag
Issues
class Tag(models.Model): segments = models.ManyToManyField('AudioSegment', related_name = "tags") collection = models.ForeignKey('Collection') name = models.CharField(max_length = 100) time = models.DateTimeField(auto_now_add = True) creator = models.ForeignKey(User)
New Way
/api/tag/<tag_id>/Client send a PUT Request(Wants to add an audio segment to a given tag)
Backend UPDATES the tag object instance(HOW AND WHAT DID IT UPDATE?)
Solution
Custom Nested Resources
Solution
/api/tag/<tag_id>
Solution
/api/tag/<tag_id>
/api/tag/<tag_id>/audio_segment/<audio_seg_id>
Thanks & Questions
Especially to Graylin...