1 class ResourcePicturesController < ApplicationController
2 if Manifest.manifest.magic_numbers['run_mode'] == 0
3 before_action :authenticate_user, :only => [:new, :create, :update, :destroy]
4 before_action :authenticate_artist, :only => [:new, :create, :update, :destroy]
6 before_action :authenticate_resource_reader, :only => [
7 :index, :show, :credit,
8 :by_original_picture, :by_license_group, :by_license, :by_artist
10 before_action :authenticate_user, :only => [:new, :create, :update, :destroy]
11 before_action :authenticate_artist, :only => [:new, :create, :update, :destroy]
18 def by_original_picture
34 def show_html_format format
42 respond_to do |format|
43 opt = {:type => @item.mime_type, :disposition=>"inline"}
44 format.png { send_data(@item.restore(params[:subdir]), opt ) }
45 format.gif { send_data(@item.restore(params[:subdir]), opt ) }
46 format.jpeg { send_data(@item.restore(params[:subdir]), opt ) }
47 show_html_format format
48 show_prof_format format
49 show_json_format format
54 @resource_picture = ResourcePicture.show(params[:id], @operators)
56 respond_to do |format|
57 format.html { render :layout => false } # show.html.erb
62 # use @item, @original_picture
63 respond_to do |format|
69 @original_picture = OriginalPicture.edit params[:original_picture_id], @operators
70 @imager = PettanImager.load @original_picture.restore
73 jsn = JSON.parse_no_except(params[:json])
75 @prm = if params[:resource_picture] == nil or params[:resource_picture].empty?
78 @item.permit_params(:resource_picture)
80 @item = @original_picture.resource_picture || ResourcePicture.new
81 @item.attributes = @prm
82 @item.overwrite @original_picture
85 respond_to do |format|
86 if @item.store(@imager)
87 format.html { redirect_to @item }
88 format.json { render json: @item.to_json, status: :created, location: @item }
90 format.html { render action: "new" }
91 format.json { render json: @item.errors, status: :unprocessable_entity }
98 @item = @my_model_class.edit(params[:id], @operators)
99 render_destroy_by 'unpublish', '/home/' + @item.path_name
103 @resource_picture = {:count => ResourcePicture.visible_count}
104 respond_to do |format|
105 format.json { render json: @resource_picture.to_json }