2 class OriginalPicturesController < ApplicationController
3 before_filter :authenticate_reader, :only => [:show, :history]
4 before_filter :authenticate_user, :only => [:index, :new, :edit, :create, :update, :destroy]
5 before_filter :authenticate_artist, :only => [:index, :new, :edit, :create, :update, :destroy]
16 @item = OriginalPicture.show(params[:id], @operators)
18 respond_to do |format|
19 opt = {:type => @item.mime_type, :disposition=>"inline"}
20 format.png { send_data(@item.restore, opt ) }
21 format.gif { send_data(@item.restore, opt ) }
22 format.jpeg { send_data(@item.restore, opt ) }
24 @original_picture = @item
25 #ライセンス付与のために原画ライセンスグループ作成準備
26 @original_picture_license_group = OriginalPictureLicenseGroup.new :original_picture_id => @item.id
30 format.json { render json: @item.to_json(OriginalPicture.show_json_opt)}
35 @original_picture = OriginalPicture.show(params[:id], @operators)
36 @history = @original_picture.history
38 respond_to do |format|
40 format.json { render json: @history.to_json }
45 @original_picture = OriginalPicture.new
46 @original_picture.supply_default
48 respond_to do |format|
51 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt) }
56 @original_picture = OriginalPicture.edit(params[:id], @operators)
57 respond_to do |format|
64 @imager = if params[:original_picture]
65 PettanImager.load set_image params[:original_picture][:file]
69 @original_picture = OriginalPicture.new
70 @original_picture.supply_default
71 @original_picture.overwrite @operators
73 respond_to do |format|
74 if @original_picture.store(@imager)
75 flash[:notice] = I18n.t('flash.notice.created', :model => OriginalPicture.model_name.human)
76 format.html { redirect_to @original_picture }
77 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
79 flash[:notice] = I18n.t('flash.notice.not_created', :model => OriginalPicture.model_name.human)
80 format.html { render action: "new" }
81 format.json { render json: @original_picture.errors, status: :unprocessable_entity }
87 @imager = if params[:original_picture]
88 PettanImager.load set_image params[:original_picture][:file]
92 @original_picture = OriginalPicture.edit(params[:id], @operators)
93 @original_picture.overwrite @operators
95 respond_to do |format|
96 if @original_picture.store(@imager)
97 flash[:notice] = I18n.t('flash.notice.updated', :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_updated', :model => OriginalPicture.model_name.human)
102 format.html { render action: "edit" }
103 format.json { render json: @original_picture.errors, status: :unprocessable_entity }
109 @original_picture = OriginalPicture.edit(params[:id], @operators)
111 respond_to do |format|
112 if @original_picture.destroy_with_resource_picture
113 format.html { redirect_to original_pictures_url }
114 format.json { head :ok }
116 format.html { redirect_to original_picture_path(@original_picture) }
117 format.json { render json: @original_picture.errors, status: :unprocessable_entity }