OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / models / user.js.coffee
index ab77bd0..4e95aff 100644 (file)
@@ -14,6 +14,25 @@ class Pettanr.User extends Backbone.Model
     if @id\r
       @url = @url + @id\r
   \r
-class Pettanr.User.Collection extends Backbone.Collection\r
-  model: Pettanr.User\r
-  url: '/users'\r
+class Pettanr.User.Current extends Pettanr.User\r
+  \r
+  save: (model_attr, after_save = null) ->\r
+    super(model_attr, {\r
+      success: (model, response, options) =>\r
+        author = new Pettanr.Author(@get('author')) if @get('author')\r
+        artist = new Pettanr.Artist(@get('artist')) if @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