OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / controllers / writing_formats_controller.rb
index 0e952f5..4f9e0ec 100644 (file)
@@ -1,40 +1,66 @@
 class WritingFormatsController < ApplicationController
-  layout 'test' if MagicNumber['test_layout']
-  if MagicNumber['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
+  if Manifest.manifest.magic_numbers['run_mode'] == 0
+    before_action :authenticate_user, :only => []
   else
-    before_filter :authenticate_reader, :only => [:index, :show]
-    before_filter :authenticate_user, :only => []
+    before_action :authenticate_reader, :only => [
+      :index, :by_system_picture, :show
+    ]
+    before_action :authenticate_user, :only => []
   end
-  before_filter :authenticate_admin!, :only => [:list, :browse, :destroy]
-
+  before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
+  
   def index
-    @writing_formats = WritingFormat.enable_list
-
-    respond_to do |format|
-      format.html {
-        render :template => 'system/filer', :locals => {
-          :items => @writing_formats, :model => WritingFormat, 
-          :roles => [@user, @admin], :pager => nil
-        }
-      }
-      format.json { render json: @writing_formats.to_json(WritingFormat.list_json_opt) }
-    end
+    filer_list
+  end
+  
+  def by_system_picture
+    filer_list param: params[:id]
   end
-
+  
+  def show_html_format format
+    format.html {
+    }
+  end
+  
   def show
-    @item = WritingFormat.show(params[:id], [@user, @admin])
-
+    set_show
     respond_to do |format|
-      format.html # show.html.erb
-      format_prof format
-      format.json {
-        render :json => @item.to_json(WritingFormat.show_json_opt)
-      }
-      format.jsonp {
-        render :json => "callback(" + @item.to_json() + ")"
-      }
+      show_html_format format
+      show_prof_format format
+      show_json_format format
     end
   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 = @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