Class: ContributionsController
- Inherits:
-
ArtfullyOseController
- Object
- ActionController::Base
- ArtfullyOseController
- ContributionsController
- Defined in:
- app/controllers/contributions_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
66 67 68 69 70 |
# File 'app/controllers/contributions_controller.rb', line 66 def create @contribution = create_contribution @contribution.save redirect_to person_path params_contribution_person_id end |
#destroy ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/controllers/contributions_controller.rb', line 58 def destroy @order = Order.find(params[:id]) :edit, @order @order.destroy flash[:notice] = "Your order has been deleted" redirect_to contributions_path end |
#edit ⇒ Object
41 42 43 44 45 46 |
# File 'app/controllers/contributions_controller.rb', line 41 def edit @order = Order.find(params[:id]) :edit, @order @contribution = Contribution.for(@order) render :layout => false end |
#index ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/contributions_controller.rb', line 2 def index :manage, Order request.format = :csv if params[:commit] == "Download" # # I hate doing this search two different ways but the CSV just wasn't working with DonationSearch # TODO: make these two methods of getting donations the same # respond_to do |format| format.html do @search = DonationSearch.new(params[:start], params[:stop], current_user.current_organization) do |results| #TODO: This sort has got to hurt. Move it into DonationSearch results.sort!{|a,b| b.created_at <=> a.created_at } results.paginate(:page => params[:page], :per_page => 25) end end format.csv do filename = "Artfully-Donations-Export-#{DateTime.now.strftime("%m-%d-%y")}.csv" csv_string = ItemView.where(:product_type => "Donation") .where('created_at > ? ', params[:start]) .where('created_at < ?', Sundial.midnightish(current_organization, params[:stop])) .where('organization_id = ?', current_organization) .all .to_comma(:donation) send_data csv_string, :filename => filename, :type => "text/csv", :disposition => "attachment" end end end |
#new ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/contributions_controller.rb', line 31 def new @contribution = create_contribution if @contribution.has_contributor? render :new, :layout => false else @contributors = contributors render :find_person end end |
#update ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/contributions_controller.rb', line 48 def update @order = Order.find(params[:order_id]) :edit, @order @contribution = Contribution.for(@order) new_contribution = Contribution.new(params[:contribution]) @contribution.update(new_contribution) flash[:notice] = "Your edits have been saved" redirect_to request.referer end |