OSDN Git Service

fix form extend
authoryasushiito <yas@pen-chan.jp>
Mon, 21 Apr 2014 02:56:35 +0000 (11:56 +0900)
committeryasushiito <yas@pen-chan.jp>
Mon, 21 Apr 2014 02:56:35 +0000 (11:56 +0900)
14 files changed:
app/assets/javascripts/manifest/work/controllers.js.coffee.erb
app/assets/javascripts/manifest/work/forms.js.coffee.erb
app/controllers/application_controller.rb
app/controllers/balloons_controller.rb
app/controllers/speech_balloons_controller.rb
app/controllers/speeches_controller.rb
app/views/balloons/show.html.erb
app/views/speeches/show.html.erb
config/routes.rb
lib/peta/content.rb
lib/peta/element.rb
lib/peta/leaf.rb
public/local_manifest.json
public/manifest.json

index 58fd878..dd1a844 100644 (file)
       count_by_author: {\r
         type: 'count',\r
       },\r
+      new: {\r
+        type: 'new',\r
+      },\r
+      edit: {\r
+        type: 'edit',\r
+      },\r
     },\r
   },\r
   speech_balloons: {\r
       count_by_author: {\r
         type: 'count',\r
       },\r
+      new: {\r
+        type: 'new',\r
+      },\r
+      edit: {\r
+        type: 'edit',\r
+      },\r
     },\r
   },\r
   speeches: {\r
       count_by_writing_format: {\r
         type: 'count',\r
       },\r
+      new: {\r
+        type: 'new',\r
+      },\r
+      edit: {\r
+        type: 'edit',\r
+      },\r
     },\r
   },\r
   balloons: {\r
           list_name: 'public',\r
         },\r
       },\r
+      new: {\r
+        type: 'new',\r
+      },\r
+      edit: {\r
+        type: 'edit',\r
+      },\r
     },\r
   },\r
   ground_pictures: {\r
       count_by_author: {\r
         type: 'count',\r
       },\r
+      new: {\r
+        type: 'new',\r
+      },\r
+      edit: {\r
+        type: 'edit',\r
+      },\r
     },\r
   },\r
   ground_colors: {\r
       count_by_author: {\r
         type: 'count',\r
       },\r
+      new: {\r
+        type: 'new',\r
+      },\r
+      edit: {\r
+        type: 'edit',\r
+      },\r
     },\r
   },\r
   original_pictures: {\r
index f01e5a7..b2babf5 100644 (file)
       'name',\r
     ]\r
   },\r
-  circle_speech_balloon_speech_speech_balloon_template: {\r
+  circle_speech_balloon_speech_balloon: {\r
     fields: {\r
-      r: {\r
-        tag: {\r
-          type: 'number',\r
-        },\r
-        row_break: true,\r
-      },\r
     },\r
+    field_names: [\r
+    ]\r
+  },\r
+  circle_speech_balloon_balloon: {\r
+    fields: {\r
+    },\r
+    field_names: [\r
+    ]\r
+  },\r
+  circle_speech_balloon_speech: {\r
+    fields: {\r
+    },\r
+    field_names: [\r
+    ]\r
+  },\r
+  pettanr_simple_format_speech: {\r
+    fields: {\r
+    },\r
+    field_names: [\r
+    ]\r
   },\r
   pettanr_creative_commons_v30_licenses_license: {\r
     fields: {\r
index 8edc583..d34f15c 100644 (file)
@@ -163,12 +163,14 @@ class ApplicationController < ActionController::Base
   def set_new
     set_model
     @item = @my_model_class.new
+    @item.boosts 'post'
     @item.supply_default
   end
   
   def set_edit
     set_model
     @item = @my_model_class.edit(params[:id], @operators)
+    @item.boosts 'post'
   end
   
   def render_form
index 3237c7a..d7d4936 100644 (file)
@@ -1,13 +1,13 @@
 class BalloonsController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   else
     before_filter :authenticate_reader, :only => [
       :index, :show, :by_speech_balloon, :count, :count_by_speech_balloon
     ]
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   end
   before_filter :authenticate_admin!, :only => [:list, :browse]
   
@@ -46,4 +46,12 @@ class BalloonsController < ApplicationController
     list_count
   end
   
+  def new
+    form_new
+  end
+  
+  def edit
+    form_edit
+  end
+  
 end
index be0bdf7..a1551f2 100644 (file)
@@ -54,38 +54,13 @@ class SpeechBalloonsController < ApplicationController
   end
   
   def new
-    raise Pettanr::NotWork unless @operators.author.working_panel
-    @speech_balloon_template = SpeechBalloonTemplate.show params[:speech_balloon_template_id], @operators
-    
-    @panel = Panel.edit(@operators.author.working_panel, @operators)
-    @speech_balloon = SpeechBalloon.new :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
-    @speech_balloon.boost
-    @speech_balloon.supply_default
-    @speech_balloon.get_balloon.supply_default 
-    @speech_balloon.get_speech.supply_default 
-    
-    respond_to do |format|
-      format.html {
-        render @speech_balloon_template.engine_name + '/speech_balloons/new'
-      }
-      format.json { render :json => @speech_balloon.to_json(SpeechBalloon.show_json_opt) }
-    end
+    form_new
   end
-
+  
   def edit
-    @speech_balloon = SpeechBalloon.show(params[:id], @operators)
-    @speech_balloon_template = @speech_balloon.speech_balloon_template
-    @panel = Panel.edit(@speech_balloon.panel.id,@operators)
-    
-    @speech_balloon.boost
-    
-    respond_to do |format|
-      format.html {
-        render @speech_balloon_template.engine_name + '/speech_balloons/edit'
-      }
-    end
+    form_edit
   end
-
+  
   def create
     raise Pettanr::NotWork unless @operators.author.working_panel
     SpeechBalloon.fold_extend_settings params
index 432c696..db947ad 100644 (file)
@@ -1,13 +1,13 @@
 class SpeechesController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   else
     before_filter :authenticate_reader, :only => [
       :index, :show, :by_speech_balloon, :by_writing_format, :count, :count_by_speech_balloon, :count_by_writing_format
     ]
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   end
   before_filter :authenticate_admin!, :only => []
 
@@ -54,4 +54,12 @@ class SpeechesController < ApplicationController
     list_count
   end
   
+  def new
+    form_new
+  end
+  
+  def edit
+    form_edit
+  end
+  
 end
index 51e0115..f6502c1 100644 (file)
@@ -1,3 +1,4 @@
 <h1><%= t('.title') %></h1>
 <p id="notice"><%= notice %></p>
 
+<%= link_to t('link.edit'), edit_balloon_path(@balloon) %>
index 51e0115..ecdefdd 100644 (file)
@@ -1,3 +1,4 @@
 <h1><%= t('.title') %></h1>
 <p id="notice"><%= notice %></p>
 
+<%= link_to t('link.edit'), edit_speech_path(@speech) %>
index c2bdbc9..ebb2dd0 100644 (file)
@@ -262,6 +262,8 @@ Pettanr::Application.routes.draw do
       get :by_speech_balloon
       #get :by_system_picture
       get :count_by_speech_balloon
+      get :edit
+      put :update
     end
   end
   resources :speeches do
@@ -274,6 +276,8 @@ Pettanr::Application.routes.draw do
       get :by_writing_format
       get :count_by_speech_balloon
       get :count_by_writing_format
+      get :edit
+      put :update
     end
   end
   resources :ground_pictures do
index 9c9dd80..6913295 100644 (file)
@@ -17,7 +17,7 @@ module Peta
     end
     
     def self._owner_column
-      self.owner_type.to_s + '_id'
+      self._owner_type.to_s + '_id'
     end
     
     def self.load_manifest
index f1ed101..7f24d98 100644 (file)
@@ -41,8 +41,12 @@ module Peta
       end
     end
     
+    def own? operators
+      self.root.own? operators
+    end
+    
     def visible? operators
-      return false unless super
+      return false unless self.user_visible? operators
       self.root.visible? operators
     end
     
index 5b35555..8510af5 100644 (file)
@@ -26,6 +26,10 @@ module Peta
       self.__send__ self.class.root_model.item_name
     end
     
+    def own? operators
+      self.root.own? operators
+    end
+    
     def visible? operators
       return false unless super
       self.root.visible? operators
index 9f48230..8665bb5 100644 (file)
           "row_break": true\r
         },\r
         "license_group_settings": {\r
-          "boost_name": "license_group",\r
           "row_break": true\r
         },\r
         "credit_picture_settings": {\r
-          "boost_name": "credit_picture",\r
           "row_break": true\r
         }\r
       },\r
         "name"\r
       ]\r
     },\r
-    "circle_speech_balloon_speech_speech_balloon_template": {\r
-      "fields": {\r
-        "r": {\r
-          "tag": {\r
-            "type": "number"\r
-          },\r
-          "row_break": true\r
-        }\r
-      }\r
+    "circle_speech_balloon_speech_balloon": {\r
+      "fields": {},\r
+      "field_names": []\r
+    },\r
+    "circle_speech_balloon_balloon": {\r
+      "fields": {},\r
+      "field_names": []\r
+    },\r
+    "circle_speech_balloon_speech": {\r
+      "fields": {},\r
+      "field_names": []\r
+    },\r
+    "pettanr_simple_format_speech": {\r
+      "fields": {},\r
+      "field_names": []\r
     },\r
     "pettanr_creative_commons_v30_licenses_license": {\r
       "fields": {\r
index d229729..fb4b3ed 100644 (file)
         },\r
         "count_by_author": {\r
           "type": "count"\r
+        },\r
+        "new": {\r
+          "type": "new"\r
+        },\r
+        "edit": {\r
+          "type": "edit"\r
         }\r
       }\r
     },\r
         },\r
         "count_by_author": {\r
           "type": "count"\r
+        },\r
+        "new": {\r
+          "type": "new"\r
+        },\r
+        "edit": {\r
+          "type": "edit"\r
         }\r
       }\r
     },\r
         },\r
         "count_by_writing_format": {\r
           "type": "count"\r
+        },\r
+        "new": {\r
+          "type": "new"\r
+        },\r
+        "edit": {\r
+          "type": "edit"\r
         }\r
       }\r
     },\r
           "args": {\r
             "list_name": "public"\r
           }\r
+        },\r
+        "new": {\r
+          "type": "new"\r
+        },\r
+        "edit": {\r
+          "type": "edit"\r
         }\r
       }\r
     },\r
         },\r
         "count_by_author": {\r
           "type": "count"\r
+        },\r
+        "new": {\r
+          "type": "new"\r
+        },\r
+        "edit": {\r
+          "type": "edit"\r
         }\r
       }\r
     },\r
         },\r
         "count_by_author": {\r
           "type": "count"\r
+        },\r
+        "new": {\r
+          "type": "new"\r
+        },\r
+        "edit": {\r
+          "type": "edit"\r
         }\r
       }\r
     },\r