6772312ea7
The primary license of the project is changing to: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later with some specific files to be licensed under the one of two licenses: CC0-1.0 LGPL-3.0-or-later This commit is one of the many steps to relicense the entire codebase. Documentation granting permission for this relicensing (from all past contributors who hold copyrights) is on file with Software Freedom Conservancy, Inc.
78 lines
2.4 KiB
Ruby
78 lines
2.4 KiB
Ruby
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
module Nonprofits
|
|
class PaymentsController < ApplicationController
|
|
include NonprofitHelper
|
|
|
|
before_filter :authenticate_nonprofit_user!
|
|
|
|
|
|
# get /nonprofit/:nonprofit_id/payments
|
|
def index
|
|
@nonprofit = current_nonprofit
|
|
respond_to do |format|
|
|
format.html do
|
|
@panels_layout = true
|
|
end
|
|
|
|
format.json do
|
|
@response = QueryPayments.full_search(params[:nonprofit_id], params)
|
|
render json: @response, status: :ok
|
|
end
|
|
end
|
|
end # def index
|
|
|
|
def export
|
|
begin
|
|
@nonprofit = current_nonprofit
|
|
@user = current_user_id
|
|
ExportPayments::initiate_export(@nonprofit.id, params, @user)
|
|
rescue => e
|
|
e
|
|
end
|
|
if e.nil?
|
|
flash[:notice] = "Your export was successfully initiated and you'll be emailed at #{current_user.email} as soon as it's available. Feel free to use the site in the meantime."
|
|
render json: {}, status: :ok
|
|
else
|
|
render json: e, status: :ok
|
|
end
|
|
end
|
|
|
|
def show
|
|
@nonprofit = current_nonprofit
|
|
@payment = @nonprofit.payments.find(params[:id])
|
|
end # def show
|
|
|
|
def update
|
|
@payment = current_nonprofit.payments.find(params[:id])
|
|
@payment.update_attributes(params[:payment])
|
|
json_saved @payment
|
|
end
|
|
|
|
def destroy
|
|
@payment = current_nonprofit.payments.find(params[:id])
|
|
if @payment.offsite_payment.nil?
|
|
render json: {}, status: :unprocessable_entity
|
|
return # You may only destroy offline payments
|
|
else
|
|
@payment.donation.destroy if @payment.donation.present?
|
|
@payment.tickets.destroy_all if @payment.tickets.present?
|
|
@payment.offsite_payment.destroy
|
|
@payment.destroy
|
|
Qx.delete_from(:activities).where(attachment_id: params[:id]).execute
|
|
render json: @payment, status: :ok
|
|
end
|
|
end
|
|
|
|
# post /nonprofits/:nonprofit_id/payments/:id/resend_donor_receipt
|
|
def resend_donor_receipt
|
|
PaymentMailer.resend_donor_receipt(params[:id])
|
|
render json: {}
|
|
end
|
|
# post /nonprofits/:nonprofit_id/payments/:id/resend_admin_receipt
|
|
# pass user_id of the admin to send to
|
|
def resend_admin_receipt
|
|
PaymentMailer.resend_admin_receipt(params[:id], current_user.id)
|
|
render json: {}
|
|
end
|
|
end # class PaymentsController
|
|
end # module Nonprofits
|