2 class OriginalPicturesController < ApplicationController
3 before_filter :authenticate_reader, :only => [:show, :history, :count]
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 }
49 @original_picture = OriginalPicture.new
50 @original_picture.supply_default
52 respond_to do |format|
55 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt) }
60 @original_picture = OriginalPicture.edit(params[:id], @operators)
61 respond_to do |format|
68 @imager = if params[:original_picture]
69 PettanImager.load set_image params[:original_picture][:file]
73 @original_picture = OriginalPicture.new
74 @original_picture.supply_default
75 @original_picture.overwrite @operators
77 respond_to do |format|
78 if @original_picture.store(@imager)
79 flash[:notice] = I18n.t('flash.notice.created', :model => OriginalPicture.model_name.human)
80 format.html { redirect_to @original_picture }
81 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
83 flash[:notice] = I18n.t('flash.notice.not_created', :model => OriginalPicture.model_name.human)
84 format.html { render action: "new" }
85 format.json { render json: @original_picture.errors, status: :unprocessable_entity }
91 @imager = if params[:original_picture]
92 PettanImager.load set_image params[:original_picture][:file]
96 @original_picture = OriginalPicture.edit(params[:id], @operators)
97 @original_picture.overwrite @operators
99 respond_to do |format|
100 if @original_picture.store(@imager)
101 flash[:notice] = I18n.t('flash.notice.updated', :model => OriginalPicture.model_name.human)
102 format.html { redirect_to @original_picture }
103 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
105 flash[:notice] = I18n.t('flash.notice.not_updated', :model => OriginalPicture.model_name.human)
106 format.html { render action: "edit" }
107 format.json { render json: @original_picture.errors, status: :unprocessable_entity }
113 @original_picture = OriginalPicture.edit(params[:id], @operators)
115 respond_to do |format|
116 if @original_picture.destroy_with_resource_picture
117 format.html { redirect_to original_pictures_url }
118 format.json { head :ok }
120 format.html { redirect_to original_picture_path(@original_picture) }
121 format.json { render json: @original_picture.errors, status: :unprocessable_entity }