OSDN Git Service

fix Manifest
[pettanr/pettanr.git] / app / controllers / system_pictures_controller.rb
1 class SystemPicturesController < ApplicationController
2   if Manifest.manifest.magic_numbers['run_mode'] == 0
3     before_filter :authenticate_user, :only => []
4     before_filter :authenticate_author, :only => []
5   else
6     before_filter :authenticate_resource_reader, :only => [:index, :show, :speech_balloon_templates, :licenses]
7     before_filter :authenticate_user, :only => []
8     before_filter :authenticate_author, :only => []
9   end
10   before_filter :authenticate_admin!, :only => [:list, :browse, :new, :create]
11
12   def self.model
13     SystemPicture
14   end
15   
16   def index
17     public_list
18   end
19   
20   def speech_balloon_templates
21     has_many_list
22   end
23   
24   def licenses
25     has_many_list
26   end
27   
28   def show
29     @item = SystemPicture.show(params[:id], @operators)
30     
31     respond_to do |format|
32       opt = {:type => @item.mime_type, :disposition=>"inline"}
33       format.png { send_data(@item.restore, opt ) }
34       format.gif { send_data(@item.restore, opt ) }
35       format.jpeg { send_data(@item.restore, opt ) }
36       format.html {
37         @system_picture = @item
38       }
39       format_prof format
40       format.json { render json: @item.to_json(SystemPicture.show_json_opt)}
41     end
42   end
43
44   def list
45     @system_pictures = SystemPicture.all
46
47     respond_to do |format|
48       format.html { render layout: 'system' }
49       format.json { render json: @system_pictures }
50     end
51   end
52
53   def browse
54     @system_picture = SystemPicture.find(params[:id])
55
56     respond_to do |format|
57       format.html { render layout: 'system' }
58       format.json { render json: @system_picture}
59     end
60   end
61
62 end