summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/models/photo.js.coffee
blob: da7006ac717059d38970b93169e7013e0dbe31e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class csx.Models.Photo extends Backbone.Model
  paramRoot: 'photo'
  fileAttribute: 'image'

  defaults:
    id: null
    cake_id: null
    content_type: null
    original_filename: null
    thumb_url: null
    large_url: null
    original_url: null
    created_at: null
    updated_at: null

  initialize: (options) ->
    @set('cake_id', options.cake_id)
    if options.id
      @url="/api/v1/cakes/#{options.cake_id}/photos/#{options.id}"
    else
      @url="/api/v1/cakes/#{options.cake_id}/photos"

    super(options)

class csx.Collections.PhotosCollection extends Backbone.Collection
  model: csx.Models.Photo

  initialize: (options) ->
    @set('cake_id', options.cake_id)
    @url="/api/v1/cakes/#{options.cake_id}/photos"