OSDN Git Service

temp
[pettanr/pettanr.git] / app / controllers / original_pictures_controller.rb
index fb6a7a3..2154f18 100644 (file)
@@ -3,38 +3,52 @@ class OriginalPicturesController < ApplicationController
   layout 'test' if MagicNumber['test_layout']
   before_filter :authenticate_reader, :only => [:show, :history]
   before_filter :authenticate_user, :only => [:index, :new, :edit, :create, :update, :destroy]
+  before_filter :authenticate_artist, :only => [:index, :new, :edit, :create, :update, :destroy]
   before_filter :authenticate_admin!, :only => [:list, :browse]
-  before_filter :authenticate_artist, :only => [:index, :show, :history, :new, :edit, :create, :update, :destroy]
   
-  # GET /original_pictures
-  # GET /original_pictures.json
+  def self.model
+    OriginalPicture
+  end
+  def self.controller
+    Pettanr::Application::manifest.controller_managers[self.model.item_name]
+  end
+  def self.profiler_manager
+    Pettanr::Application::manifest.profiler_managers[self.model.item_name]
+  end
+  
   def index
-    @page = OriginalPicture.page params[:page]
-    @page_size = OriginalPicture.page_size params[:page_size]
-    @original_pictures = OriginalPicture.mylist(@artist.id, @page, @page_size)
-
+    action_name = params[:action]
+    @action = self.class.controller.open(action_name, params, @operators)
+    @items = @action.items 
     respond_to do |format|
-      format.html # index.html.erb
-      format.json { render json: @original_pictures.to_json(OriginalPicture.list_json_opt) }
+      format.html {
+        @filer = @action.filer
+        render :template => 'system/filer', :locals => {
+          :filer => @filer
+        }
+      }
+      format.json { render json: @items.to_json(self.class.model.list_json_opt) }
+      format.atom 
+      format.rss
     end
   end
 
-  # GET /original_pictures/1
-  # GET /original_pictures/1.json
   def show
-    @original_picture = OriginalPicture.show(params[:id], [@artist, @admin])
+    @item = OriginalPicture.show(params[:id], @operators)
     
     respond_to do |format|
-      opt = {:type => @original_picture.mime_type, :disposition=>"inline"}
-      format.png { send_data(@original_picture.restore, opt ) }
-      format.gif { send_data(@original_picture.restore, opt ) }
-      format.jpeg { send_data(@original_picture.restore, opt ) }
+      opt = {:type => @item.mime_type, :disposition=>"inline"}
+      format.png { send_data(@item.restore, opt ) }
+      format.gif { send_data(@item.restore, opt ) }
+      format.jpeg { send_data(@item.restore, opt ) }
       format.html {
+        @original_picture = @item
         #ライセンス付与のために原画ライセンスグループ作成準備
-        @original_picture_license_group  = OriginalPictureLicenseGroup.new :original_picture_id => @original_picture.id
+        @original_picture_license_group  = OriginalPictureLicenseGroup.new :original_picture_id => @item.id
         render
       }
-      format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt)}
+      format_prof format
+      format.json { render json: @item.to_json(OriginalPicture.show_json_opt)}
     end
   end
 
@@ -101,6 +115,7 @@ class OriginalPicturesController < ApplicationController
         format.html { redirect_to @original_picture }
         format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
       else
+        flash[:notice] = I18n.t('flash.notice.not_created', :model => OriginalPicture.model_name.human)
         format.html { render action: "new" }
         format.json { render json: @original_picture.errors, status: :unprocessable_entity }
       end
@@ -122,6 +137,7 @@ class OriginalPicturesController < ApplicationController
         format.html { redirect_to @original_picture }
         format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
       else
+        flash[:notice] = I18n.t('flash.notice.not_updated', :model => OriginalPicture.model_name.human)
         format.html { render action: "edit" }
         format.json { render json: @original_picture.errors, status: :unprocessable_entity }
       end