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]
15 def show_html_format format
18 @original_picture = @item
19 #ライセンス付与のために原画ライセンスグループ作成準備
20 @original_picture_license_group = OriginalPictureLicenseGroup.new :original_picture_id => @item.id
27 respond_to do |format|
28 opt = {:type => @item.mime_type, :disposition=>"inline"}
29 format.png { send_data(@item.restore(params[:subdir]), opt ) }
30 format.gif { send_data(@item.restore(params[:subdir]), opt ) }
31 format.jpeg { send_data(@item.restore(params[:subdir]), opt ) }
32 show_html_format format
33 show_prof_format format
34 show_json_format format
39 @original_picture = OriginalPicture.show(params[:id], @operators)
40 @history = @original_picture.history
42 respond_to do |format|
44 format.json { render json: @history.to_json }
53 @original_picture = OriginalPicture.new
54 @original_picture.supply_default
56 respond_to do |format|
59 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt) }
64 @original_picture = OriginalPicture.edit(params[:id], @operators)
65 respond_to do |format|
72 @imager = if params[:original_picture]
73 PettanImager.load set_image params[:original_picture][:file]
77 @original_picture = OriginalPicture.new
78 @original_picture.supply_default
79 @original_picture.overwrite @operators
81 respond_to do |format|
82 if @original_picture.store(@imager)
83 flash[:notice] = I18n.t('flash.notice.created', :model => OriginalPicture.model_name.human)
84 format.html { redirect_to @original_picture }
85 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
87 flash[:notice] = I18n.t('flash.notice.not_created', :model => OriginalPicture.model_name.human)
88 format.html { render action: "new" }
89 format.json { render json: @original_picture.errors, status: :unprocessable_entity }
95 @imager = if params[:original_picture]
96 PettanImager.load set_image params[:original_picture][:file]
100 @original_picture = OriginalPicture.edit(params[:id], @operators)
101 @original_picture.overwrite @operators
103 respond_to do |format|
104 if @original_picture.store(@imager)
105 flash[:notice] = I18n.t('flash.notice.updated', :model => OriginalPicture.model_name.human)
106 format.html { redirect_to @original_picture }
107 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
109 flash[:notice] = I18n.t('flash.notice.not_updated', :model => OriginalPicture.model_name.human)
110 format.html { render action: "edit" }
111 format.json { render json: @original_picture.errors, status: :unprocessable_entity }
117 @original_picture = OriginalPicture.edit(params[:id], @operators)
119 respond_to do |format|
120 if @original_picture.destroy_with_resource_picture
121 format.html { redirect_to original_pictures_url }
122 format.json { head :ok }
124 format.html { redirect_to original_picture_path(@original_picture) }
125 format.json { render json: @original_picture.errors, status: :unprocessable_entity }