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]
33 def show_html_format format
41 respond_to do |format|
42 opt = {:type => @item.mime_type, :disposition=>"inline"}
43 format.png { send_data(@item.restore(params[:subdir]), opt ) }
44 format.gif { send_data(@item.restore(params[:subdir]), opt ) }
45 format.jpeg { send_data(@item.restore(params[:subdir]), opt ) }
46 show_html_format format
47 show_prof_format format
48 show_json_format format
53 @resource_picture = ResourcePicture.show(params[:id], @operators)
55 respond_to do |format|
56 format.html { render :layout => false } # show.html.erb
64 def count_by_license_group
77 # use @item, @original_picture
78 respond_to do |format|
84 @original_picture = OriginalPicture.edit params[:original_picture_id], @operators
85 @imager = PettanImager.load @original_picture.restore
88 jsn = JSON.parse_no_except(params[:json])
90 @prm = if params[:resource_picture] == nil or params[:resource_picture].empty?
93 params[:resource_picture]
95 @item = @original_picture.resource_picture || ResourcePicture.new
96 @item.attributes = @prm
97 @item.overwrite @original_picture
100 respond_to do |format|
101 if @item.store(@imager)
102 format.html { redirect_to @item }
103 format.json { render json: @item.to_json, status: :created, location: @item }
105 format.html { render action: "new" }
106 format.json { render json: @item.errors, status: :unprocessable_entity }
112 @resource_picture = ResourcePicture.edit(params[:id], @operators)
114 respond_to do |format|
115 if @resource_picture.unpublish
116 format.html { redirect_to :controller => '/home', :action => :resource_pictures }
117 format.json { head :ok }
119 format.html { redirect_to resource_picture_path(@resource_picture) }
120 format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
126 @resource_picture = {:count => ResourcePicture.visible_count}
127 respond_to do |format|
128 format.json { render json: @resource_picture.to_json }