2 class OriginalPicturesController < ApplicationController
3 layout 'test' if MagicNumber['test_layout']
4 before_filter :authenticate_reader, :only => [:show, :history]
5 before_filter :authenticate_user, :only => [:index, :new, :edit, :create, :update, :destroy]
6 before_filter :authenticate_artist, :only => [:index, :new, :edit, :create, :update, :destroy]
7 before_filter :authenticate_admin!, :only => [:list, :browse]
13 Pettanr::Application::manifest.controller_managers[self.model.item_name]
15 def self.profiler_manager
16 Pettanr::Application::manifest.profiler_managers[self.model.item_name]
20 action_name = params[:action]
21 @action = self.class.controller.open(action_name, params, @operators)
22 @items = @action.items
23 respond_to do |format|
25 @filer = @action.filer
26 render :template => 'system/filer', :locals => {
30 format.json { render json: @items.to_json(self.class.model.list_json_opt) }
37 @item = OriginalPicture.show(params[:id], @operators)
39 respond_to do |format|
40 opt = {:type => @item.mime_type, :disposition=>"inline"}
41 format.png { send_data(@item.restore, opt ) }
42 format.gif { send_data(@item.restore, opt ) }
43 format.jpeg { send_data(@item.restore, opt ) }
45 @original_picture = @item
46 #ライセンス付与のために原画ライセンスグループ作成準備
47 @original_picture_license_group = OriginalPictureLicenseGroup.new :original_picture_id => @item.id
51 format.json { render json: @item.to_json(OriginalPicture.show_json_opt)}
56 @original_picture = OriginalPicture.show(params[:id], [@artist, @admin])
57 @history = @original_picture.history
59 respond_to do |format|
60 format.html # index.html.erb
61 format.json { render json: @history.to_json }
66 @original_pictures = OriginalPicture.all
68 respond_to do |format|
69 format.html { render layout: 'system' }
70 format.json { render json: @original_pictures }
75 @original_picture = OriginalPicture.find(params[:id])
77 respond_to do |format|
78 format.html { render layout: 'system' }
79 format.json { render json: @original_picture }
84 @original_picture = OriginalPicture.new
85 @original_picture.supply_default
87 respond_to do |format|
88 format.html # new.html.erb
90 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt) }
95 @original_picture = OriginalPicture.edit(params[:id], @artist)
96 respond_to do |format|
103 @imager = if params[:original_picture]
104 PettanImager.load set_image params[:original_picture][:file]
108 @original_picture = OriginalPicture.new
109 @original_picture.supply_default
110 @original_picture.overwrite @artist
112 respond_to do |format|
113 if @original_picture.store(@imager)
114 flash[:notice] = I18n.t('flash.notice.created', :model => OriginalPicture.model_name.human)
115 format.html { redirect_to @original_picture }
116 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
118 flash[:notice] = I18n.t('flash.notice.not_created', :model => OriginalPicture.model_name.human)
119 format.html { render action: "new" }
120 format.json { render json: @original_picture.errors, status: :unprocessable_entity }
126 @imager = if params[:original_picture]
127 PettanImager.load set_image params[:original_picture][:file]
131 @original_picture = OriginalPicture.edit(params[:id], @artist)
132 @original_picture.overwrite @artist
134 respond_to do |format|
135 if @original_picture.store(@imager)
136 flash[:notice] = I18n.t('flash.notice.updated', :model => OriginalPicture.model_name.human)
137 format.html { redirect_to @original_picture }
138 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
140 flash[:notice] = I18n.t('flash.notice.not_updated', :model => OriginalPicture.model_name.human)
141 format.html { render action: "edit" }
142 format.json { render json: @original_picture.errors, status: :unprocessable_entity }
148 @original_picture = OriginalPicture.edit(params[:id], @artist)
150 respond_to do |format|
151 if @original_picture.destroy_with_resource_picture
152 format.html { redirect_to original_pictures_url }
153 format.json { head :ok }
155 format.html { redirect_to original_picture_path(@original_picture) }
156 format.json { render json: @original_picture.errors, status: :unprocessable_entity }