Class: ContributionsController

Inherits:
ArtfullyOseController show all
Defined in:
app/controllers/contributions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



45
46
47
48
49
# File 'app/controllers/contributions_controller.rb', line 45

def create
  @contribution = create_contribution
  @contribution.save
  redirect_to person_path params[:contribution][:person_id]
end

#destroyObject



37
38
39
40
41
42
43
# File 'app/controllers/contributions_controller.rb', line 37

def destroy
  @order = Order.find(params[:id])
  authorize! :edit, @order
  @order.destroy
  flash[:notice] = "Your order has been deleted"
  redirect_to contributions_path
end

#editObject



20
21
22
23
24
25
# File 'app/controllers/contributions_controller.rb', line 20

def edit
  @order = Order.find(params[:id])
  authorize! :edit, @order
  @contribution = Contribution.for(@order)
  render :layout => false
end

#indexObject



2
3
4
5
6
7
8
# File 'app/controllers/contributions_controller.rb', line 2

def index
  authorize! :manage, Order

  @search = DonationSearch.new(params[:start], params[:stop], current_user.current_organization) do |results|
    results.sort{|a,b| b.created_at <=> a.created_at }.paginate(:page => params[:page], :per_page => 25)
  end
end

#newObject



10
11
12
13
14
15
16
17
18
# File 'app/controllers/contributions_controller.rb', line 10

def new
  @contribution = create_contribution
  if @contribution.has_contributor?
    render :new
  else
    @contributors = contributors
    render :find_person
  end
end

#updateObject



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

def update
  @order = Order.find(params[:order_id])
  authorize! :edit, @order
  @contribution = Contribution.for(@order)
  new_contribution = Contribution.new(params[:contribution])
  @contribution.update(new_contribution)
  flash[:notice] = "Your order has been edited"
  redirect_to order_path(@order)
end