photomix/app/controllers/collections_controller.rb

63 lines
1.5 KiB
Ruby
Raw Normal View History

2009-06-03 01:33:39 +02:00
class CollectionsController < ApplicationController
2009-08-03 16:39:33 +02:00
before_filter :check_public_access
before_filter :require_role_admin, :only => [:new, :create, :edit, :update, :destroy]
2009-06-03 01:33:39 +02:00
def index
2009-11-09 13:55:15 +01:00
@collections = Collection.find(:all, :order => 'title')
2009-06-03 01:33:39 +02:00
respond_to do |format|
format.html
format.json { render :json => @collections }
format.xml { render :xml => @collections }
end
end
def show
2009-06-16 01:18:42 +02:00
@collection = Collection.find( params[:id] )
2009-11-09 13:54:11 +01:00
@albums = @collection.albums.find(:all, :order => 'title')
2009-06-03 01:33:39 +02:00
respond_to do |format|
format.html
format.json { render :json => @collection }
format.xml { render :xml => @collection }
format.pdf { render :pdf => @collection.title }
end
end
def new
@collection = Collection.new
end
def create
@collection = Collection.new(params[:collection])
if @collection.save
flash[:notice] = "Collection created!"
redirect_to @collection
else
render :action => :new
end
end
def edit
2009-06-16 01:22:51 +02:00
@collection = Collection.find( params[:id])
2009-06-03 01:33:39 +02:00
end
def update
2009-06-16 01:22:51 +02:00
@collection = Collection.find( params[:id])
2009-06-03 01:33:39 +02:00
if @collection.update_attributes(params[:collection])
2009-06-09 00:30:22 +02:00
flash[:notice] = "Collection updated!"
2009-06-03 01:33:39 +02:00
redirect_to @collection
else
render :action => :edit
end
end
def destroy
2009-06-16 01:22:51 +02:00
@collection = Collection.find( params[:id])
2009-06-03 01:33:39 +02:00
if @collection.destroy
redirect_to collections_path
else
redirect_to @collection
end
end
end