blob: 7df33ee2a743ac18e2ad974daa172cc170f5ce28 (
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
|
class csx.Models.Cake extends Backbone.Model
paramRoot: 'cake'
defaults:
id: null
name: null
story: null
created_at: null
updated_at: null
category_id: null
validate: (attributes, options) ->
return "Name can't be blank" unless attributes.name && attributes.name.trim()
return "Category can't be blank" unless attributes.category_id
photos: ->
csx.Application.request('PhotosRepository', @id)
public_url: ->
"#{window.location.origin}/creations/#{@get('slug')}"
category_id: ->
@get('category_id') || @get('category').id
class csx.Collections.CakesCollection extends Backbone.Collection
model: csx.Models.Cake
url: '/api/v1/cakes'
|