1 class SystemPicturesController < ApplicationController
2 layout 'test' if Pettanr::TestLayout
3 before_filter :authenticate_user!, :only => [:index, :show]
4 before_filter :authenticate_admin!, :only => [:list, :browse, :new, :create]
7 # GET /system_pictures.json
9 @page = SystemPicture.page params[:page]
10 @page_size = SystemPicture.page_size params[:page_size]
11 @system_pictures = SystemPicture.list(@page, @page_size)
13 respond_to do |format|
14 format.html # index.html.erb
15 format.json { render json: @system_pictures.to_json(SystemPicture.list_json_opt) }
19 # GET /system_pictures/1
20 # GET /system_pictures/1.json
22 @system_picture = SystemPicture.show(params[:id], @author)
24 respond_to do |format|
25 opt = {:type => @system_picture.mime_type, :disposition=>"inline"}
26 format.png { send_data(@system_picture.restore, opt ) }
27 format.gif { send_data(@system_picture.restore, opt ) }
28 format.jpeg { send_data(@system_picture.restore, opt ) }
29 format.html # show.html.erb
30 format.json { render json: @system_picture.to_json(SystemPicture.show_json_opt)}
35 @system_pictures = SystemPicture.all
37 respond_to do |format|
38 format.html { render layout: 'system' }
39 format.json { render json: @system_pictures }
44 @system_picture = SystemPicture.find(params[:id])
46 respond_to do |format|
47 format.html { render layout: 'system' }
48 format.json { render json: @system_picture}
53 respond_to do |format|
54 format.html # new.html.erb
58 # POST /system_pictures
59 # POST /system_pictures.json
61 @imager = PettanImager.load set_image params[:system_picture][:file]
63 respond_to do |format|
64 @system_picture = SystemPicture.store @imager
66 format.html { redirect_to @system_picture, notice: 'system picture was successfully created.' }
67 format.json { render json: @system_picture.to_json(SystemPicture.show_json_opt), status: :created, location: @system_picture }
69 format.html { render action: "new" }
70 format.json { render json: {}, status: :unprocessable_entity }