OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / models / story.js.coffee
index d635ff7..625cec7 100644 (file)
@@ -1,25 +1,34 @@
-class Story extends Item\r
-  @single: () ->\r
+class Pettanr.Story extends Peta.Binder\r
+  url: '/stories/'\r
+  \r
+  @singular: () ->\r
     'Story'\r
   \r
   @plural: () ->\r
     'Stories'\r
   \r
   defaults: {\r
-    id: 11\r
+    id: null,\r
+    visible: 0,\r
+    author_id: null\r
   } \r
   \r
-  initialize: () ->\r
-    confirm("Welcome to Panel")\r
+  author: () ->\r
+    new Pettanr.Author({id: @get('author_id')})\r
   \r
-  @test: () ->\r
-    confirm( @single())\r
-    confirm( @plural() )\r
-    confirm( @class_name() )\r
-    confirm( @element_name() )\r
-    confirm( @table_name() )\r
-    \r
+  is_visible: (operators) ->\r
+    switch super(operators)\r
+      when null\r
+        return true\r
+      when false\r
+        return false\r
+      else\r
+        @get('visible') > 0\r
+  \r
+  initialize: () ->\r
+    if @id\r
+      @url = @url + @id\r
   \r
-  test: () ->\r
-\r
-@Panel = Panel\r
+class Pettanr.Story.Collection extends Backbone.Collection\r
+  model: Pettanr.Story\r
+  url: '/stories'\r