OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / assets / javascripts / models / license.js.coffee
index 2e18e58..9f734b5 100644 (file)
@@ -1,4 +1,5 @@
 class Pettanr.License extends Peta.SystemResource\r
+  \r
   @singular: () ->\r
     'License'\r
   \r
@@ -9,18 +10,23 @@ class Pettanr.License extends Peta.SystemResource
     id: null\r
   } \r
   \r
-  license_group: () ->\r
-    r = new Pettanr.LicenseGroup({id: @get('license_group_id')})\r
-    r.fetch({}).done () ->\r
-      r\r
+  @trace_routes: () ->\r
+    {\r
+      symbol: ['system_picture']\r
+    }\r
+  \r
+  caption_with_group: (context, options) ->\r
+    @get_parent('license_group', this, {\r
+      success: (license_group) => \r
+        caption = license_group.escape('caption') + '/' + @escape('caption')\r
+        options.success.call(context, caption)\r
+      fail: (response, opt) =>\r
+        options.fail.call(context, response, opt)\r
+    })\r
   \r
-  caption_with_group: () ->\r
-    @license_group().get('caption') + '/' + @get('caption')\r
+  is_own: () ->\r
+    true\r
   \r
-  initialize: () ->\r
-    if @id\r
-      @url = @url + @id\r
+  initialize: (attr = {}, options = {}) ->\r
+    super(attr, options)\r
   \r
-class Pettanr.License.Collection extends Backbone.Collection\r
-  model: Pettanr.License\r
-  url: '/licenses'\r