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]
9 @@model = OriginalPicture
13 respond_to do |format|
15 format.json { render json: @items.to_json(@@model.list_json_opt) }
20 @item = OriginalPicture.show(params[:id], @operators)
22 respond_to do |format|
23 opt = {:type => @item.mime_type, :disposition=>"inline"}
24 format.png { send_data(@item.restore, opt ) }
25 format.gif { send_data(@item.restore, opt ) }
26 format.jpeg { send_data(@item.restore, opt ) }
28 @original_picture = @item
29 #ライセンス付与のために原画ライセンスグループ作成準備
30 @original_picture_license_group = OriginalPictureLicenseGroup.new :original_picture_id => @item.id
34 format.json { render json: @item.to_json(OriginalPicture.show_json_opt)}
39 @original_picture = OriginalPicture.show(params[:id], [@artist, @admin])
40 @history = @original_picture.history
42 respond_to do |format|
43 format.html # index.html.erb
44 format.json { render json: @history.to_json }
49 @original_pictures = OriginalPicture.all
51 respond_to do |format|
52 format.html { render layout: 'system' }
53 format.json { render json: @original_pictures }
58 @original_picture = OriginalPicture.find(params[:id])
60 respond_to do |format|
61 format.html { render layout: 'system' }
62 format.json { render json: @original_picture }
67 @original_picture = OriginalPicture.new
68 @original_picture.supply_default
70 respond_to do |format|
71 format.html # new.html.erb
73 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt) }
78 @original_picture = OriginalPicture.edit(params[:id], @artist)
79 respond_to do |format|
86 @imager = if params[:original_picture]
87 PettanImager.load set_image params[:original_picture][:file]
91 @original_picture = OriginalPicture.new
92 @original_picture.supply_default
93 @original_picture.overwrite @artist
95 respond_to do |format|
96 if @original_picture.store(@imager)
97 flash[:notice] = I18n.t('flash.notice.created', :model => OriginalPicture.model_name.human)
98 format.html { redirect_to @original_picture }
99 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
101 flash[:notice] = I18n.t('flash.notice.not_created', :model => OriginalPicture.model_name.human)
102 format.html { render action: "new" }
103 format.json { render json: @original_picture.errors, status: :unprocessable_entity }
109 @imager = if params[:original_picture]
110 PettanImager.load set_image params[:original_picture][:file]
114 @original_picture = OriginalPicture.edit(params[:id], @artist)
115 @original_picture.overwrite @artist
117 respond_to do |format|
118 if @original_picture.store(@imager)
119 flash[:notice] = I18n.t('flash.notice.updated', :model => OriginalPicture.model_name.human)
120 format.html { redirect_to @original_picture }
121 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
123 flash[:notice] = I18n.t('flash.notice.not_updated', :model => OriginalPicture.model_name.human)
124 format.html { render action: "edit" }
125 format.json { render json: @original_picture.errors, status: :unprocessable_entity }
131 @original_picture = OriginalPicture.edit(params[:id], @artist)
133 respond_to do |format|
134 if @original_picture.destroy_with_resource_picture
135 format.html { redirect_to original_pictures_url }
136 format.json { head :ok }
138 format.html { redirect_to original_picture_path(@original_picture) }
139 format.json { render json: @original_picture.errors, status: :unprocessable_entity }