class ResourcePicturesController < ApplicationController
- before_filter :authenticate_author!, :except => [:index, :show]
+ before_filter :authenticate_author!, :only => [:index, :show]
+ before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /resource_pictures
# GET /resource_pictures.json
def index
- @resource_pictures = ResourcePicture.all
+ @resource_pictures = ResourcePicture.find(:all,
+ :include => {:original_picture => [:artist, :lisence]}, :order => 'updated_at', :limit => 20
+ )
respond_to do |format|
format.html # index.html.erb
- format.json { render json: @resource_pictures }
+ format.json { render :json => @resource_pictures.to_json(
+ :include => [:original_picture, :artist, :lisence]
+ ) }
end
end
end
end
-=begin
- # GET /resource_pictures/new
- # GET /resource_pictures/new.json
- def new
- @resource_picture = ResourcePicture.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @resource_picture }
- end
- end
-
- # GET /resource_pictures/1/edit
- def edit
- @resource_picture = ResourcePicture.find(params[:id])
- end
-
- # POST /resource_pictures
- # POST /resource_pictures.json
- def create
- @resource_picture = ResourcePicture.new(params[:resource_picture])
+ def list
+ @resource_pictures = ResourcePicture.all
respond_to do |format|
- if @resource_picture.save
- format.html { redirect_to @resource_picture, notice: 'Resource picture was successfully created.' }
- format.json { render json: @resource_picture, status: :created, location: @resource_picture }
- else
- format.html { render action: "new" }
- format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
- end
+ format.html { render layout: 'system' }
+ format.json { render json: @resource_pictures }
end
end
- # PUT /resource_pictures/1
- # PUT /resource_pictures/1.json
- def update
+ def browse
@resource_picture = ResourcePicture.find(params[:id])
respond_to do |format|
- if @resource_picture.update_attributes(params[:resource_picture])
- format.html { redirect_to @resource_picture, notice: 'Resource picture was successfully updated.' }
- format.json { head :ok }
- else
- format.html { render action: "edit" }
- format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
- end
+ format.html { render layout: 'system' }
+ format.json { render json: @resource_picture }
end
end
- # DELETE /resource_pictures/1
- # DELETE /resource_pictures/1.json
- def destroy
- @resource_picture = ResourcePicture.find(params[:id])
- @resource_picture.destroy
-
- respond_to do |format|
- format.html { redirect_to resource_pictures_url }
- format.json { head :ok }
- end
- end
-=end
end