Class | UploadsController
In: | app/controllers/uploads_controller.rb
Parent: | ApplicationController

Copyright (c) 2006 Logica

### Methods

destroy edit index list new show update

### Public Instance methods

destroy()

[Source]

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

edit()

[Source]

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

index()

[Source]

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

list()

[Source]

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

new()

[Source]

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

show()

[Source]

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

update()

[Source]

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

[Validate]