Class: SponsoredProjectAllocationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/sponsored_project_allocations_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#robot?

Instance Method Details

#archiveObject



54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/sponsored_project_allocations_controller.rb', line 54

def archive
  authorize! :archive, SponsoredProjectAllocation
  @allocation = SponsoredProjectAllocation.find(params[:id])
  if @allocation.update_attributes({:is_archived => true})
    flash[:notice] = 'Allocation was successfully archived.'
    redirect_to(sponsored_project_allocations_path)
  else
    flash[:notice] = 'Allocation could not be archived.'
    redirect_to(sponsored_project_allocations_path)
  end
end

#createObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/sponsored_project_allocations_controller.rb', line 26

def create
  authorize! :create, SponsoredProjectAllocation
  @allocation = SponsoredProjectAllocation.new(params[:sponsored_project_allocation])
  @users = User.staff
  @projects = SponsoredProject.current

  if @allocation.save
    flash[:notice] = 'Allocation was successfully created.'
    redirect_to(sponsored_project_allocations_path)
  else
    render "new"
  end
end

#editObject



19
20
21
22
23
24
# File 'app/controllers/sponsored_project_allocations_controller.rb', line 19

def edit
  authorize! :update, SponsoredProjectAllocation
  @allocation = SponsoredProjectAllocation.find(params[:id])
  @users = User.staff
  @projects = SponsoredProject.current
end

#indexObject



7
8
9
10
# File 'app/controllers/sponsored_project_allocations_controller.rb', line 7

def index
  authorize! :read, SponsoredProjectAllocation
  @allocations = SponsoredProjectAllocation.current
end

#newObject



12
13
14
15
16
17
# File 'app/controllers/sponsored_project_allocations_controller.rb', line 12

def new
  authorize! :create, SponsoredProjectAllocation
  @allocation = SponsoredProjectAllocation.new
  @users = User.staff
  @projects = SponsoredProject.current
end

#updateObject



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/sponsored_project_allocations_controller.rb', line 40

def update
  authorize! :update, SponsoredProjectAllocation
  @allocation = SponsoredProjectAllocation.find(params[:id])
  @users = User.staff
  @projects = SponsoredProject.current

  if @allocation.update_attributes(params[:sponsored_project_allocation])
    flash[:notice] = 'Allocation was successfully updated.'
    redirect_to(sponsored_project_allocations_path)
  else
    render "edit"
  end
end