OSDN Git Service

fix summary
[pettanr/pettanr.git] / app / assets / javascripts / models / user.js.coffee
1 class Pettanr.User extends Backbone.Model\r
2   \r
3   url: '/users/'\r
4   \r
5   defaults: {\r
6     id: null\r
7   } \r
8   \r
9   author: () ->\r
10   \r
11   artist: () ->\r
12   \r
13   initialize: () ->\r
14     if @id\r
15       @url = @url + @id\r
16   \r
17 class Pettanr.User.Current extends Pettanr.User\r
18   \r
19   save: (model_attr, after_save = null) ->\r
20     super(model_attr, {\r
21       success: (model, response, options) =>\r
22         author = new Pettanr.Author(@get('author')) if @get('author')\r
23         artist = new Pettanr.Artist(@get('artist')) if @get('artist')\r
24         window.operators = new Pettanr.Operator({\r
25           user: this, \r
26           author: author, \r
27           artist: artist\r
28         })\r
29         if after_save\r
30           after_save(this)\r
31       error: (model, response, options) ->\r
32         r = new Pettanr.Views.User.Index({})\r
33         $("#pettanr").html(r.render().el)\r
34     })\r
35   \r
36   initialize: () ->\r
37     @url = '/users/sign_in'\r
38   \r