1 class ResourcePicturesController < ApplicationController
2 if Manifest.manifest.magic_numbers['run_mode'] == 0
3 before_filter :authenticate_user, :only => [:new, :create, :update, :destroy]
4 before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy]
6 before_filter :authenticate_resource_reader, :only => [
7 :index, :show, :credit, :by_license_group, :by_license, :by_artist, :count, :count_by_license_group, :count_by_license, :count_by_artist
9 before_filter :authenticate_user, :only => [:new, :create, :update, :destroy]
10 before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy]
29 def show_html_format format
37 respond_to do |format|
38 opt = {:type => @item.mime_type, :disposition=>"inline"}
39 format.png { send_data(@item.restore(params[:subdir]), opt ) }
40 format.gif { send_data(@item.restore(params[:subdir]), opt ) }
41 format.jpeg { send_data(@item.restore(params[:subdir]), opt ) }
42 show_html_format format
43 show_prof_format format
44 show_json_format format
49 @resource_picture = ResourcePicture.show(params[:id], @operators)
51 respond_to do |format|
52 format.html { render :layout => false } # show.html.erb
60 def count_by_license_group
73 # use @item, @original_picture
74 respond_to do |format|
80 @original_picture = OriginalPicture.edit params[:original_picture_id], @operators
81 @imager = PettanImager.load @original_picture.restore
84 jsn = JSON.parse_no_except(params[:json])
86 @prm = if params[:resource_picture] == nil or params[:resource_picture].empty?
89 params[:resource_picture]
91 @item = @original_picture.resource_picture || ResourcePicture.new
92 @item.attributes = @prm
93 @item.overwrite @original_picture
96 respond_to do |format|
97 if @item.store(@imager)
98 format.html { redirect_to @item }
99 format.json { render json: @item.to_json, status: :created, location: @item }
101 format.html { render action: "new" }
102 format.json { render json: @item.errors, status: :unprocessable_entity }
108 @resource_picture = ResourcePicture.edit(params[:id], @operators)
110 respond_to do |format|
111 if @resource_picture.unpublish
112 format.html { redirect_to :controller => '/home', :action => :resource_pictures }
113 format.json { head :ok }
115 format.html { redirect_to resource_picture_path(@resource_picture) }
116 format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
122 @resource_picture = {:count => ResourcePicture.visible_count}
123 respond_to do |format|
124 format.json { render json: @resource_picture.to_json }