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_original_picture, :by_license, :by_artist, :count, :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]
21 def by_original_picture
33 def show_html_format format
36 @resource_picture = @item
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
58 format.json { render :json => @resource_picture.to_json(ResourcePicture.show_json_opt)}
75 @original_picture = OriginalPicture.edit params[:original_picture_id], @operators
76 @imager = PettanImager.load @original_picture.restore
77 @original_picture_license_group = OriginalPictureLicenseGroup.new params[:original_picture_license_group]
78 @license_group = LicenseGroup.show @original_picture_license_group.license_group_id
79 @resource_picture = @original_picture.resource_picture
80 unless @resource_picture
81 @resource_picture = ResourcePicture.new
82 @resource_picture.supply_default
84 @resource_picture.attributes = params[:resource_picture]
85 @resource_picture.overwrite @original_picture
86 @license = @resource_picture.license
88 respond_to do |format|
89 format.html # new.html.erb
95 @original_picture = OriginalPicture.edit params[:original_picture_id], @operators
96 @imager = PettanImager.load @original_picture.restore
97 @original_picture_license_group = OriginalPictureLicenseGroup.new params[:original_picture_license_group]
98 @license_group = LicenseGroup.show @original_picture_license_group.license_group_id, @operators
99 @resource_picture = @original_picture.resource_picture
100 unless @resource_picture
101 @resource_picture = ResourcePicture.new
102 @resource_picture.supply_default
104 @resource_picture.attributes = params[:resource_picture]
105 @resource_picture.overwrite @original_picture
106 @resource_picture.boosts 'post'
107 @license = @resource_picture.license
109 respond_to do |format|
110 if @resource_picture.store(@imager)
111 format.html { redirect_to @resource_picture }
112 format.json { render json: @resource_picture.to_json(ResourcePicture.show_json_opt), status: :created, location: @resource_picture }
114 format.html { render action: "new" }
115 format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
121 @resource_picture = ResourcePicture.edit(params[:id], @operators)
123 respond_to do |format|
124 if @resource_picture.unpublish
125 format.html { redirect_to :controller => '/home', :action => :resource_pictures }
126 format.json { head :ok }
128 format.html { redirect_to resource_picture_path(@resource_picture) }
129 format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
135 @resource_picture = {:count => ResourcePicture.visible_count}
136 respond_to do |format|
137 format.json { render json: @resource_picture.to_json }