houdini/app/controllers/super_admins_controller.rb
Bradley M. Kuhn 6772312ea7 Relicense all .rb files under new project license.
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.
2018-03-25 15:10:40 -04:00

81 lines
2.6 KiB
Ruby

# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
class SuperAdminsController < ApplicationController
layout "layouts/page"
before_filter :authenticate_super_associate!
def index
end
def search_nonprofits
render json: QueryNonprofits.for_admin(params)
end
def search_profiles
render json: QueryProfiles.for_admin(params)
end
def search_fullcontact
begin
result = FullContact.person(email: params[:search])
rescue Exception => e
result = ''
end
render json: [result]
end
def resend_user_confirmation
ParamValidation.new(params || {}, {
profile_id: {:required => true, is_integer: true}
})
profile = Profile.includes(:user).where('id = ?', params[:profile_id]).first
unless (profile.user)
raise ArgumentError.new("#{params[:profile_id]} is a profile without a valid user")
end
profile.user.send_confirmation_instructions
render json: {status: :ok}
end
def recurring_donations_without_cards
odd_donations = QueryRecurringDonations::recurring_donations_without_cards
respond_to do |format|
format.html
format.csv do
csv_out = CSV.generate { |csv|
csv << ['supporter id', 'recurring donation id', 'rd created date', 'rd modified', 'donation id', 'donation card id',
'edit_token', 'nonprofit id',
'last charge succeeded id', 'last charge succeeded created at', 'last charge attempted id', 'last charge attempted created at', 'amount']
odd_donations.each { |rd|
csv << [rd.supporter.id, rd.id, rd.created_at, rd.updated_at, rd.donation.id, rd.donation.card_id, rd.edit_token, rd.nonprofit.id,
rd.most_recent_paid_charge.id, rd.most_recent_paid_charge.created_at, rd.most_recent_charge.id, rd.most_recent_charge.created_at,
rd.amount]
}
}
send_data(csv_out, filename: "recurring_donations_without_cards-#{Time.now.to_date()}.csv")
end
end
end
def export_supporters_with_rds
np = params[:np]
ids = params[:ids]
results = QuerySupporters.for_export(np, {ids: ids})
results[0].push("Management URLS")
results.drop(1).each {|row|
rds = Supporter.includes(:recurring_donations).find(row.last).recurring_donations.select{|rd| rd.active}.map{|rd| "* #{root_url}recurring_donations/#{rd.id}/edit?t=#{rd.edit_token}"}.join("\n")
row.push(rds)
}
send_data(Format::Csv.from_vectors(results), filename: "supporters_with_multiple_donations.csv")
end
end