OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / controllers / writing_formats_controller.rb
index 5e72055..4f9e0ec 100644 (file)
@@ -1,23 +1,24 @@
 class WritingFormatsController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
+    before_action :authenticate_user, :only => []
   else
-    before_filter :authenticate_reader, :only => [:index, :show, :count]
-    before_filter :authenticate_user, :only => []
-  end
-  before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
-
-  def self.model
-    WritingFormat
+    before_action :authenticate_reader, :only => [
+      :index, :by_system_picture, :show
+    ]
+    before_action :authenticate_user, :only => []
   end
+  before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
   
   def index
     filer_list
   end
-
+  
+  def by_system_picture
+    filer_list param: params[:id]
+  end
+  
   def show_html_format format
     format.html {
-      @writing_format = @item
     }
   end
   
@@ -30,10 +31,6 @@ class WritingFormatsController < ApplicationController
     end
   end
   
-  def count
-    list_count
-  end
-  
   def new
     form_new
   end
@@ -42,4 +39,28 @@ class WritingFormatsController < ApplicationController
     form_edit
   end
   
+  def create
+    set_model
+    @item = @my_model_class.new
+    @item.supply_default 
+    @my_model_class.fold_extend_settings params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
+    @item.overwrite 
+    render_create
+  end
+  
+  def update
+    set_edit
+    @my_model_class.fold_extend_settings params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
+    @item.overwrite 
+    render_update
+  end
+  
+  def destroy
+    set_model
+    @item = @my_model_class.edit(params[:id], @operators)
+    render_destroy '/' + @my_model_class.path_name
+  end
+  
 end