OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / controllers / writing_formats_controller.rb
index 520cf61..ab11f80 100644 (file)
@@ -5,7 +5,7 @@ class WritingFormatsController < ApplicationController
     before_filter :authenticate_reader, :only => [:index, :show, :count]
     before_filter :authenticate_user, :only => []
   end
-  before_filter :authenticate_admin!, :only => [:destroy]
+  before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
 
   def self.model
     WritingFormat
@@ -17,7 +17,6 @@ class WritingFormatsController < ApplicationController
 
   def show_html_format format
     format.html {
-      @writing_format = @item
     }
   end
   
@@ -29,9 +28,44 @@ class WritingFormatsController < ApplicationController
       show_json_format format
     end
   end
-
+  
   def count
     list_count
   end
   
+  def new
+    form_new
+  end
+  
+  def edit
+    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 = params[@my_model_class.item_name]
+    @item.overwrite 
+    render_create
+  end
+  
+  def update
+    set_edit
+    @my_model_class.fold_extend_settings params[@my_model_class.item_name]
+    @item.attributes = params[@my_model_class.item_name]
+    @item.overwrite 
+    render_update
+  end
+  
+  def destroy
+    @item = self.class.model.edit(params[:id], @operators)
+    respond_to do |format|
+        flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => self.class.model.model_name.human)
+        format.html { redirect_to @item }
+        format.json { render json: @item.errors, status: :unprocessable_entity }
+    end
+  end
+  
 end