Class: PresentationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/presentations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
# File 'app/controllers/presentations_controller.rb', line 17

def create
  @presentation = @project.presentations.new(presentation_params)

  if @presentation.save
    redirect_to project_presentations_path(@project)
  else
    render :action => :new
  end
end

#destroyObject



37
38
39
40
41
# File 'app/controllers/presentations_controller.rb', line 37

def destroy
  presentation && presentation.destroy
  flash[:notice] = l(:presentation_deleted_message)
  redirect_to project_presentations_path(@project)
end

#downloadObject



64
65
66
67
68
69
# File 'app/controllers/presentations_controller.rb', line 64

def download
  send_file presentation.contents.path,
            :filename => presentation.contents_file_name,
            :type => presentation.contents.content_type,
            :streaming => true
end

#editObject



43
44
45
46
47
48
49
50
# File 'app/controllers/presentations_controller.rb', line 43

def edit
  if presentation.blank?
    flash[:error] = "The requested presentation does not exist. Please verify the link or send the project owner a message."
    redirect_to(project_presentations_path(@project))
  else
    @versions = @project.versions.open.push(presentation.version).compact.sort.uniq
  end
end

#indexObject



6
7
8
# File 'app/controllers/presentations_controller.rb', line 6

def index
  @presentations = @project.presentations
end

#instructionsObject



10
11
# File 'app/controllers/presentations_controller.rb', line 10

def instructions
end

#newObject



13
14
15
# File 'app/controllers/presentations_controller.rb', line 13

def new
  @versions = @project.versions.open
end

#showObject

Defers serving files to nginx via the X-Accel-Redirect header



28
29
30
31
32
33
34
35
# File 'app/controllers/presentations_controller.rb', line 28

def show
  if presentation.blank?
    flash[:error] = "The requested presentation does not exist. Please verify the link or send the project owner a message."
    redirect_to(project_presentations_path(@project))
  end

  head :x_accel_redirect => presentation.x_accel_redirect_path_to(params[:static_asset_path]), :content_type => requested_content_type
end

#updateObject



52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/presentations_controller.rb', line 52

def update
  if presentation.blank?
    flash[:error] = "Hmmm....we couldn't find the presentation you were editing. Someone may have deleted it while you were performing your edits. You may want to send an email to the project owner to find out who has permissions to administer the project presentations."
  else
    presentation.title = presentation_params[:title]
    presentation.description = presentation_params[:description]
    presentation.save!
  end

  redirect_to project_presentations_path(@project)
end