concert spring 2011_presentation_1
DESCRIPTION
TRANSCRIPT
![Page 1: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/1.jpg)
Initial PresentationFebruary 25, 2010
![Page 2: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/2.jpg)
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]
![Page 3: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/3.jpg)
Mockup
See our blog post on waveform behavior[2]
![Page 4: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/4.jpg)
Representational State Transfer (REST) API
Interface for manipulating resources over HTTP
![Page 5: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/5.jpg)
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.
![Page 6: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/6.jpg)
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.
![Page 7: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/7.jpg)
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.
![Page 8: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/8.jpg)
REST in Concert
Easily modify Django models from the frontend
See our previous presentation on Backbone.js[3]
![Page 9: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/9.jpg)
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/" }
![Page 10: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/10.jpg)
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/" } ]
![Page 11: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/11.jpg)
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') ...
![Page 12: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/12.jpg)
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
![Page 13: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/13.jpg)
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
![Page 14: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/14.jpg)
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/"}
![Page 15: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/15.jpg)
Issues
Concert Events
&
Many-To-Many Relationships
![Page 16: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/16.jpg)
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
![Page 17: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/17.jpg)
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?)
![Page 18: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/18.jpg)
Solution
Custom Nested Resources
![Page 19: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/19.jpg)
Solution
/api/tag/<tag_id>
![Page 20: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/20.jpg)
Solution
/api/tag/<tag_id>
/api/tag/<tag_id>/audio_segment/<audio_seg_id>
![Page 21: Concert spring 2011_presentation_1](https://reader034.vdocuments.us/reader034/viewer/2022051411/545b684aaf79592b448b626f/html5/thumbnails/21.jpg)
Thanks & Questions
Especially to Graylin...