21
Initial Presentation February 25, 2010

Concert spring 2011_presentation_1

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Concert spring 2011_presentation_1

Initial PresentationFebruary 25, 2010

Page 2: Concert spring 2011_presentation_1

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

Mockup

See our blog post on waveform behavior[2]

Page 4: Concert spring 2011_presentation_1

Representational State Transfer (REST) API

Interface for manipulating resources over HTTP

Page 5: Concert spring 2011_presentation_1

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

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

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

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

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

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

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

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

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

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

Issues

Concert Events

&

Many-To-Many Relationships

Page 16: Concert spring 2011_presentation_1

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

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

Solution

Custom Nested Resources

Page 19: Concert spring 2011_presentation_1

Solution

/api/tag/<tag_id>

Page 20: Concert spring 2011_presentation_1

Solution

/api/tag/<tag_id>

/api/tag/<tag_id>/audio_segment/<audio_seg_id>

Page 21: Concert spring 2011_presentation_1

Thanks & Questions

Especially to Graylin...