Class | UploadsController
In: | test/functional/uploads_controller_test.rb app/controllers/uploads_controller.rb
Parent: | Object

Copyright (c) 2006 Logica

### Methods

destroy edit index list new rescue_action show update

### Public Instance methods

destroy()

[Source]

        # File app/controllers/uploads_controller.rb, line 80
    80:   def destroy
    81:     @upload = Upload.find(params[:id])
    82:     @upload.destroy
    83:     redirect_to request.referer
    84:   end

edit()

[Source]

        # File app/controllers/uploads_controller.rb, line 61
    61:   def edit
    62:     @upload = Upload.find(params[:id])
    63:   end

index()

[Source]

        # File app/controllers/uploads_controller.rb, line 25
    25:   def index
    26:     list
    27:     render :action => 'list'
    28:   end

list()

[Source]

        # File app/controllers/uploads_controller.rb, line 33
    33:   def list
    34:     @upload_pages, @uploads = paginate :uploads, :order => 'created_on DESC',  :per_page => 10
    35:   end

new()

[Source]

        # File app/controllers/uploads_controller.rb, line 41
    41:   def new
    42:     if request.get?
    43:       @upload = Upload.new
    44:     else
    45:       @upload = Upload.new(params[:upload].merge(:user => session['user']))
    46:       if @upload.save
    47:         @upload.save_file
    48:         flash[:notice] = 'Upload was successfully created.'
    49:         users = User.find(:all, :conditions => ['notify_immediate=?', 1])
    50:         unless users.empty?
    51:           subject = "New upload from #{@upload.user.name}"
    52:           introduction = "<p>User #{@upload.user.name} uploaded a document or image <a href=\"#{@upload.url(true, request.host + (request.port == 80 ? '' : ':' + request.port.to_s))}\">#{@upload.filename}</a></p>"
    53:           Notifier::deliver_notification(users,subject,introduction, @upload.description, request.host + (request.port == 80 ? '' : ':' + request.port.to_s))
    54:         end
    55:         redirect_to :action => 'list'
    56:         #render :action => 'new'
    57:       end
    58:     end
    59:   end

rescue_action(e)

[Source]

        # File test/functional/uploads_controller_test.rb, line 18
    18:                          def rescue_action(e) raise e end

show()

[Source]

        # File app/controllers/uploads_controller.rb, line 37
    37:   def show
    38:     @upload = Upload.find(params[:id])
    39:   end

update()

[Source]

        # File app/controllers/uploads_controller.rb, line 65
    65:   def update
    66:     @upload = Upload.find(params[:id])
    67:     if mine?(@upload) || admin?
    68:       if @upload.update_attributes(params[:upload])
    69:         flash[:notice] = 'Upload was successfully updated.'
    70:         redirect_to :action => 'list'
    71:       else
    72:         render :action => 'edit'
    73:       end
    74:     else
    75:       flash['error'] = ::FLASH_NOT_OWNER
    76:       render :action => 'edit'
    77:     end
    78:   end

[Validate]