OSDN Git Service

fix initial page
[pettanr/pettanr.git] / app / assets / javascripts / models / user.js.coffee
index 469fde4..131c2e8 100644 (file)
@@ -14,3 +14,26 @@ class Pettanr.User extends Backbone.Model
     if @id\r
       @url = @url + @id\r
   \r
+class Pettanr.User.Current extends Pettanr.User\r
+  \r
+  save: (model_attr, after_save = null) ->\r
+    _this = this\r
+    super(model_attr, {\r
+      success: (model, response, options) ->\r
+        author = new Pettanr.Author(_this.get('author')) if _this.get('author')\r
+        artist = new Pettanr.Artist(_this.get('artist')) if _this.get('artist')\r
+        window.operators = new Pettanr.Operator({\r
+          user: _this, \r
+          author: author, \r
+          artist: artist\r
+        })\r
+        if after_save\r
+          after_save(_this)\r
+      error: (model, response, options) ->\r
+        r = new Pettanr.Views.User.Index({})\r
+        $("#pettanr").html(r.render().el)\r
+    })\r
+  \r
+  initialize: () ->\r
+    @url = '/users/sign_in'\r
+  \r