2009-05-22 14:13:46 +02:00
|
|
|
class AlbumsController < ApplicationController
|
2009-06-02 00:08:57 +02:00
|
|
|
before_filter :require_user, :only => [:new, :create, :edit, :update, :delete, :destroy, :upload]
|
2009-05-22 14:13:46 +02:00
|
|
|
|
|
|
|
def index
|
|
|
|
@albums = Album.find(:all)
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json { render :json => @albums }
|
|
|
|
format.xml { render :xml => @albums }
|
|
|
|
end
|
|
|
|
end
|
2009-06-03 01:33:39 +02:00
|
|
|
|
|
|
|
def untouched
|
|
|
|
@albums = Album.untouched()
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json { render :json => @albums }
|
|
|
|
format.xml { render :xml => @albums }
|
|
|
|
end
|
|
|
|
end
|
2009-05-22 14:13:46 +02:00
|
|
|
|
|
|
|
def show
|
|
|
|
@album = Album.find( params[:id])
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json { render :json => @album }
|
|
|
|
format.xml { render :xml => @album }
|
2009-05-25 21:39:43 +02:00
|
|
|
format.pdf { render :pdf => @album.title }
|
2009-05-22 14:13:46 +02:00
|
|
|
end
|
|
|
|
end
|
2009-05-25 21:39:43 +02:00
|
|
|
|
2009-05-22 21:04:41 +02:00
|
|
|
def new
|
|
|
|
@album = Album.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@album = Album.new(params[:album])
|
2009-06-02 00:08:57 +02:00
|
|
|
@album.path = @album.title
|
2009-05-22 21:04:41 +02:00
|
|
|
if @album.save
|
|
|
|
flash[:notice] = "Album created!"
|
|
|
|
redirect_to @album
|
|
|
|
else
|
|
|
|
render :action => :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@album = Album.find( params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@album = Album.find( params[:id])
|
|
|
|
if @album.update_attributes(params[:album])
|
|
|
|
flash[:notice] = "Account updated!"
|
|
|
|
redirect_to @album
|
|
|
|
else
|
|
|
|
render :action => :edit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-06-02 00:08:57 +02:00
|
|
|
def destroy
|
2009-05-22 21:04:41 +02:00
|
|
|
@album = Album.find( params[:id])
|
2009-06-02 00:08:57 +02:00
|
|
|
if @album.destroy
|
|
|
|
redirect_to albums_path
|
2009-05-22 21:04:41 +02:00
|
|
|
else
|
|
|
|
redirect_to @album
|
|
|
|
end
|
|
|
|
end
|
2009-05-22 14:13:46 +02:00
|
|
|
|
2009-06-02 00:08:57 +02:00
|
|
|
def upload
|
|
|
|
@user = current_user_session
|
|
|
|
@album = Album.find( params[:id])
|
|
|
|
end
|
|
|
|
|
2009-05-22 14:13:46 +02:00
|
|
|
end
|