1 class ResourcePicturesController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 if MagicNumber['run_mode'] == 0
4 before_filter :authenticate_user, :only => [:new, :create, :update, :destroy]
5 before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy]
7 before_filter :authenticate_resource_reader, :only => [:index, :show, :credit]
8 before_filter :authenticate_user, :only => [:new, :create, :update, :destroy]
9 before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy]
11 before_filter :authenticate_admin!, :only => [:list, :browse]
14 @page = ResourcePicture.page params[:page]
15 @page_size = ResourcePicture.page_size params[:page_size]
16 @resource_pictures = ResourcePicture.list(@page, @page_size)
18 respond_to do |format|
20 @paginate = ResourcePicture.list_paginate(@page, @page_size)
22 format.json { render :json => @resource_pictures.to_json(ResourcePicture.list_json_opt) }
27 @resource_picture = ResourcePicture.show(params[:id], [@user, @admin, @demand_user])
29 respond_to do |format|
30 opt = {:type => @resource_picture.mime_type, :disposition=>"inline"}
31 format.png { send_data(@resource_picture.restore(params[:subdir]), opt ) }
32 format.gif { send_data(@resource_picture.restore(params[:subdir]), opt ) }
33 format.jpeg { send_data(@resource_picture.restore(params[:subdir]), opt ) }
34 format.html # show.html.erb
35 format.prof { render :template => 'top/prof', :layout => true }
36 format.json { render :json => @resource_picture.to_json(ResourcePicture.show_json_opt)}
41 @resource_picture = ResourcePicture.show(params[:id], [@user, @admin, @demand_user])
43 respond_to do |format|
44 format.html { render :layout => false } # show.html.erb
45 format.json { render :json => @resource_picture.to_json(ResourcePicture.show_json_opt)}
50 @original_picture = OriginalPicture.edit params[:original_picture_id], @artist
51 @imager = PettanImager.load @original_picture.restore
52 @original_picture_license_group = OriginalPictureLicenseGroup.new params[:original_picture_license_group]
53 @license_group = LicenseGroup.show @original_picture_license_group.license_group_id
54 @resource_picture = @original_picture.resource_picture
55 unless @resource_picture
56 @resource_picture = ResourcePicture.new
57 @resource_picture.supply_default
59 @resource_picture.attributes = params[:resource_picture]
60 @resource_picture.overwrite @original_picture
61 @license = @resource_picture.license
63 respond_to do |format|
64 format.html # new.html.erb
70 @original_picture = OriginalPicture.edit params[:original_picture_id], @artist
71 @imager = PettanImager.load @original_picture.restore
72 @original_picture_license_group = OriginalPictureLicenseGroup.new params[:original_picture_license_group]
73 @license_group = LicenseGroup.show @original_picture_license_group.license_group_id
74 @resource_picture = @original_picture.resource_picture
75 unless @resource_picture
76 @resource_picture = ResourcePicture.new
77 @resource_picture.supply_default
79 @resource_picture.attributes = params[:resource_picture]
80 @resource_picture.overwrite @original_picture
81 @license = @resource_picture.license
83 respond_to do |format|
84 if @resource_picture.store(@imager)
85 format.html { redirect_to @resource_picture }
86 format.json { render json: @resource_picture.to_json(ResourcePicture.show_json_opt), status: :created, location: @resource_picture }
88 format.html { render action: "new" }
89 format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
95 @resource_picture = ResourcePicture.edit(params[:id], @artist)
97 respond_to do |format|
98 if @resource_picture.unpublish
99 format.html { redirect_to :controller => '/home', :action => :resource_picture }
100 format.json { head :ok }
102 format.html { redirect_to resource_picture_path(@resource_picture) }
103 format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
109 @resource_picture = {:count => ResourcePicture.visible_count}
110 respond_to do |format|
111 format.json { render json: @resource_picture.to_json }
116 @resource_pictures = ResourcePicture.all
118 respond_to do |format|
119 format.html { render layout: 'system' }
120 format.json { render json: @resource_pictures }
125 @resource_picture = ResourcePicture.find(params[:id])
127 respond_to do |format|
128 format.html { render layout: 'system' }
129 format.json { render json: @resource_picture }