OSDN Git Service

fix initial page
[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     _this = this\r
21     super(model_attr, {\r
22       success: (model, response, options) ->\r
23         author = new Pettanr.Author(_this.get('author')) if _this.get('author')\r
24         artist = new Pettanr.Artist(_this.get('artist')) if _this.get('artist')\r
25         window.operators = new Pettanr.Operator({\r
26           user: _this, \r
27           author: author, \r
28           artist: artist\r
29         })\r
30         if after_save\r
31           after_save(_this)\r
32       error: (model, response, options) ->\r
33         r = new Pettanr.Views.User.Index({})\r
34         $("#pettanr").html(r.render().el)\r
35     })\r
36   \r
37   initialize: () ->\r
38     @url = '/users/sign_in'\r
39   \r