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
17 @original_picture = @item
18 #ライセンス付与のために原画ライセンスグループ作成準備
19 @original_picture_license_group = OriginalPictureLicenseGroup.new :original_picture_id => @item.id
26 respond_to do |format|
27 opt = {:type => @item.mime_type, :disposition=>"inline"}
28 format.png { send_data(@item.restore(params[:subdir]), opt ) }
29 format.gif { send_data(@item.restore(params[:subdir]), opt ) }
30 format.jpeg { send_data(@item.restore(params[:subdir]), opt ) }
31 show_html_format format
32 show_prof_format format
33 show_json_format format
38 @original_picture = OriginalPicture.show(params[:id], @operators)
39 @history = @original_picture.history
41 respond_to do |format|
43 format.json { render json: @history.to_json }
52 @original_picture = OriginalPicture.new
53 @original_picture.supply_default
55 respond_to do |format|
58 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt) }
63 @original_picture = OriginalPicture.edit(params[:id], @operators)
64 respond_to do |format|
71 @imager = if params[:original_picture]
72 PettanImager.load set_image params[:original_picture][:file]
76 @original_picture = OriginalPicture.new
77 @original_picture.supply_default
78 @original_picture.overwrite @operators
80 respond_to do |format|
81 if @original_picture.store(@imager)
82 flash[:notice] = I18n.t('flash.notice.created', :model => OriginalPicture.model_name.human)
83 format.html { redirect_to @original_picture }
84 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
86 flash[:notice] = I18n.t('flash.notice.not_created', :model => OriginalPicture.model_name.human)
87 format.html { render action: "new" }
88 format.json { render json: @original_picture.errors, status: :unprocessable_entity }
94 @imager = if params[:original_picture]
95 PettanImager.load set_image params[:original_picture][:file]
99 @original_picture = OriginalPicture.edit(params[:id], @operators)
100 @original_picture.overwrite @operators
102 respond_to do |format|
103 if @original_picture.store(@imager)
104 flash[:notice] = I18n.t('flash.notice.updated', :model => OriginalPicture.model_name.human)
105 format.html { redirect_to @original_picture }
106 format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt), status: :created, location: @original_picture }
108 flash[:notice] = I18n.t('flash.notice.not_updated', :model => OriginalPicture.model_name.human)
109 format.html { render action: "edit" }
110 format.json { render json: @original_picture.errors, status: :unprocessable_entity }
116 @original_picture = OriginalPicture.edit(params[:id], @operators)
118 respond_to do |format|
119 if @original_picture.destroy_with_resource_picture
120 format.html { redirect_to original_pictures_url }
121 format.json { head :ok }
123 format.html { redirect_to original_picture_path(@original_picture) }
124 format.json { render json: @original_picture.errors, status: :unprocessable_entity }