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, :count,
8 :by_original_picture, :by_license_group, :by_license, :by_artist,
9 :count_by_original_picture, :count_by_license_group, :count_by_license, :count_by_artist
11 before_filter :authenticate_user, :only => [:new, :create, :update, :destroy]
12 before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy]
19 def by_original_picture
35 def show_html_format format
43 respond_to do |format|
44 opt = {:type => @item.mime_type, :disposition=>"inline"}
45 format.png { send_data(@item.restore(params[:subdir]), opt ) }
46 format.gif { send_data(@item.restore(params[:subdir]), opt ) }
47 format.jpeg { send_data(@item.restore(params[:subdir]), opt ) }
48 show_html_format format
49 show_prof_format format
50 show_json_format format
55 @resource_picture = ResourcePicture.show(params[:id], @operators)
57 respond_to do |format|
58 format.html { render :layout => false } # show.html.erb
66 def count_by_original_picture
70 def count_by_license_group
83 # use @item, @original_picture
84 respond_to do |format|
90 @original_picture = OriginalPicture.edit params[:original_picture_id], @operators
91 @imager = PettanImager.load @original_picture.restore
94 jsn = JSON.parse_no_except(params[:json])
96 @prm = if params[:resource_picture] == nil or params[:resource_picture].empty?
99 params[:resource_picture]
101 @item = @original_picture.resource_picture || ResourcePicture.new
102 @item.attributes = @prm
103 @item.overwrite @original_picture
106 respond_to do |format|
107 if @item.store(@imager)
108 format.html { redirect_to @item }
109 format.json { render json: @item.to_json, status: :created, location: @item }
111 format.html { render action: "new" }
112 format.json { render json: @item.errors, status: :unprocessable_entity }
118 @resource_picture = ResourcePicture.edit(params[:id], @operators)
120 respond_to do |format|
121 if @resource_picture.unpublish
122 format.html { redirect_to :controller => '/home', :action => :resource_pictures }
123 format.json { head :ok }
125 format.html { redirect_to resource_picture_path(@resource_picture) }
126 format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
132 @resource_picture = {:count => ResourcePicture.visible_count}
133 respond_to do |format|
134 format.json { render json: @resource_picture.to_json }