Merge pull request #14 from debtcollective/rails_v5
Upgrade to Rails v5.2.3
This commit is contained in:
commit
23603f0b1c
770 changed files with 15668 additions and 15164 deletions
1
.ruby-gemset
Normal file
1
.ruby-gemset
Normal file
|
@ -0,0 +1 @@
|
||||||
|
fundraising
|
|
@ -1 +1 @@
|
||||||
2.3.7
|
2.5.1
|
||||||
|
|
73
Gemfile
73
Gemfile
|
@ -1,15 +1,16 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
ruby '2.3.7'
|
ruby '2.5.1'
|
||||||
|
gem 'rails', '= 5.2.3'
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
gem 'rails', '3.2.22.5'
|
|
||||||
gem 'rails_12factor'
|
|
||||||
# https://stripe.com/docs/api
|
# https://stripe.com/docs/api
|
||||||
gem 'stripe'
|
gem 'stripe'
|
||||||
|
|
||||||
# Compression of assets on heroku
|
# Compression of assets on heroku
|
||||||
# https://github.com/romanbsd/heroku-deflater
|
# https://github.com/romanbsd/heroku-deflater
|
||||||
gem 'heroku-deflater', :group => :production
|
gem 'heroku-deflater', group: :production
|
||||||
|
|
||||||
# json serialization
|
# json serialization
|
||||||
# https://github.com/nesquena/rabl
|
# https://github.com/nesquena/rabl
|
||||||
|
@ -17,23 +18,20 @@ gem 'rabl'
|
||||||
|
|
||||||
gem 'parallel'
|
gem 'parallel'
|
||||||
|
|
||||||
gem 'puma'
|
|
||||||
gem 'bootsnap', require: false
|
gem 'bootsnap', require: false
|
||||||
gem 'rack-timeout'
|
gem 'puma'
|
||||||
gem 'puma_worker_killer'
|
gem 'puma_worker_killer'
|
||||||
|
gem 'rack-ssl'
|
||||||
|
gem 'rack-timeout'
|
||||||
|
|
||||||
gem 'test-unit', '~> 3.0'
|
|
||||||
gem 'hamster'
|
gem 'hamster'
|
||||||
|
gem 'test-unit', '~> 3.0'
|
||||||
|
|
||||||
|
gem 'aws-sdk', '~> 1'
|
||||||
gem 'aws-ses'
|
gem 'aws-ses'
|
||||||
gem 'aws-sdk'
|
|
||||||
|
|
||||||
# for blocking ip addressses
|
# for blocking ip addressses
|
||||||
gem 'rack-attack'
|
gem 'rack-attack'
|
||||||
|
|
||||||
# For modularizing javascript
|
|
||||||
# https://github.com/browserify-rails/browserify-rails
|
|
||||||
gem 'browserify-rails'
|
|
||||||
gem 'sprockets'
|
gem 'sprockets'
|
||||||
|
|
||||||
# for serving fonts on cdn
|
# for serving fonts on cdn
|
||||||
|
@ -41,12 +39,13 @@ gem 'sprockets'
|
||||||
gem 'font_assets', '~> 0.1.14'
|
gem 'font_assets', '~> 0.1.14'
|
||||||
|
|
||||||
# Database (postgres)
|
# Database (postgres)
|
||||||
gem 'pg' # Postgresql
|
|
||||||
|
gem 'pg', '~> 0.11'
|
||||||
gem 'qx', path: 'gems/ruby-qx'
|
gem 'qx', path: 'gems/ruby-qx'
|
||||||
|
|
||||||
gem 'dalli'
|
gem 'dalli'
|
||||||
gem 'memcachier'
|
gem 'memcachier'
|
||||||
|
|
||||||
|
|
||||||
gem 'param_validation', path: 'gems/ruby-param-validation'
|
gem 'param_validation', path: 'gems/ruby-param-validation'
|
||||||
|
|
||||||
# Print colorized text lol
|
# Print colorized text lol
|
||||||
|
@ -73,7 +72,7 @@ gem 'httparty'
|
||||||
|
|
||||||
# User authentication
|
# User authentication
|
||||||
# https://github.com/plataformatec/devise
|
# https://github.com/plataformatec/devise
|
||||||
gem 'devise'
|
gem 'devise', '~> 4.4'
|
||||||
gem 'devise-async'
|
gem 'devise-async'
|
||||||
|
|
||||||
# http://www.rubygeocoder.com/
|
# http://www.rubygeocoder.com/
|
||||||
|
@ -91,41 +90,41 @@ gem 'table_print'
|
||||||
|
|
||||||
gem 'bunny', '>= 2.6.3'
|
gem 'bunny', '>= 2.6.3'
|
||||||
|
|
||||||
gem 'rails-i18n', '~> 3.0.0' # For 3.x
|
|
||||||
gem 'i18n-js'
|
|
||||||
gem 'countries'
|
gem 'countries'
|
||||||
|
gem 'i18n-js'
|
||||||
|
gem 'rails-i18n'
|
||||||
|
|
||||||
group :development, :ci do
|
group :development, :ci do
|
||||||
gem 'traceroute'
|
|
||||||
gem 'debase'
|
gem 'debase'
|
||||||
gem 'ruby-debug-ide'
|
gem 'ruby-debug-ide'
|
||||||
|
gem 'traceroute'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :ci, :test do
|
group :development, :ci, :test do
|
||||||
gem 'timecop'
|
gem 'pry'
|
||||||
gem 'pry'
|
# gem 'pry-byebug'
|
||||||
#gem 'pry-byebug'
|
gem 'binding_of_caller'
|
||||||
gem 'binding_of_caller'
|
|
||||||
gem 'rspec'
|
|
||||||
gem 'rspec-rails'
|
|
||||||
gem 'database_cleaner'
|
|
||||||
gem 'dotenv-rails'
|
gem 'dotenv-rails'
|
||||||
gem 'ruby-prof', '0.15.9'
|
gem 'ruby-prof', '0.15.9'
|
||||||
gem 'stripe-ruby-mock', '~> 2.4.1', :require => 'stripe_mock', git: 'https://github.com/commitchange/stripe-ruby-mock.git', :branch => '2.4.1'
|
gem 'solargraph'
|
||||||
gem 'factory_bot'
|
|
||||||
gem 'factory_bot_rails'
|
|
||||||
gem 'action_mailer_matchers'
|
|
||||||
gem 'simplecov', '~> 0.16.1', require: false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :ci, :test do
|
||||||
|
gem 'timecop'
|
||||||
gem 'webmock'
|
gem 'webmock'
|
||||||
|
gem 'rspec'
|
||||||
|
gem 'rspec-rails'
|
||||||
|
gem 'factory_bot'
|
||||||
|
gem 'factory_bot_rails'
|
||||||
|
gem 'simplecov', '~> 0.16.1', require: false
|
||||||
|
gem 'database_cleaner'
|
||||||
|
gem 'action_mailer_matchers'
|
||||||
|
gem 'stripe-ruby-mock', '~> 2.4.1', require: 'stripe_mock', git: 'https://github.com/commitchange/stripe-ruby-mock.git', branch: '2.4.1'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Gems used for asset compilation
|
# Gems used for asset compilation
|
||||||
gem 'sass', '3.2.19'
|
gem 'sass', '3.2.19'
|
||||||
gem 'sass-rails', '3.2.6'
|
gem 'sass-rails'
|
||||||
gem 'uglifier'
|
gem 'uglifier'
|
||||||
|
|
||||||
# make logging less terrible in rails
|
# make logging less terrible in rails
|
||||||
|
@ -136,10 +135,10 @@ gem 'dry-validation' # used only for config validation
|
||||||
|
|
||||||
gem 'foreman'
|
gem 'foreman'
|
||||||
|
|
||||||
gem 'grape', '~> 1.1.0'
|
gem 'grape'
|
||||||
gem 'grape-entity', git: 'https://github.com/ruby-grape/grape-entity.git', ref: '0e04aa561373b510c2486282979085eaef2ae663'
|
gem 'grape-entity'
|
||||||
gem 'grape-swagger'
|
gem 'grape-swagger'
|
||||||
gem 'grape-swagger-entity'
|
gem 'grape-swagger-entity'
|
||||||
gem 'grape_url_validator'
|
|
||||||
gem 'grape_logging'
|
|
||||||
gem 'grape_devise', path: 'gems/grape_devise'
|
gem 'grape_devise', path: 'gems/grape_devise'
|
||||||
|
gem 'grape_logging'
|
||||||
|
gem 'grape_url_validator'
|
||||||
|
|
562
Gemfile.lock
562
Gemfile.lock
|
@ -8,15 +8,6 @@ GIT
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
stripe (>= 1.31.0, <= 1.58.0)
|
stripe (>= 1.31.0, <= 1.58.0)
|
||||||
|
|
||||||
GIT
|
|
||||||
remote: https://github.com/ruby-grape/grape-entity.git
|
|
||||||
revision: 0e04aa561373b510c2486282979085eaef2ae663
|
|
||||||
ref: 0e04aa561373b510c2486282979085eaef2ae663
|
|
||||||
specs:
|
|
||||||
grape-entity (0.7.1)
|
|
||||||
activesupport (>= 3.0.0)
|
|
||||||
multi_json (>= 1.3.2)
|
|
||||||
|
|
||||||
PATH
|
PATH
|
||||||
remote: gems/grape_devise
|
remote: gems/grape_devise
|
||||||
specs:
|
specs:
|
||||||
|
@ -42,169 +33,201 @@ GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
action_mailer_matchers (1.0.0)
|
action_mailer_matchers (1.0.0)
|
||||||
actionmailer (3.2.22.5)
|
actioncable (5.2.3)
|
||||||
actionpack (= 3.2.22.5)
|
actionpack (= 5.2.3)
|
||||||
mail (~> 2.5.4)
|
nio4r (~> 2.0)
|
||||||
actionpack (3.2.22.5)
|
websocket-driver (>= 0.6.1)
|
||||||
activemodel (= 3.2.22.5)
|
actionmailer (5.2.3)
|
||||||
activesupport (= 3.2.22.5)
|
actionpack (= 5.2.3)
|
||||||
builder (~> 3.0.0)
|
actionview (= 5.2.3)
|
||||||
erubis (~> 2.7.0)
|
activejob (= 5.2.3)
|
||||||
journey (~> 1.0.4)
|
mail (~> 2.5, >= 2.5.4)
|
||||||
rack (~> 1.4.5)
|
rails-dom-testing (~> 2.0)
|
||||||
rack-cache (~> 1.2)
|
actionpack (5.2.3)
|
||||||
rack-test (~> 0.6.1)
|
actionview (= 5.2.3)
|
||||||
sprockets (~> 2.2.1)
|
activesupport (= 5.2.3)
|
||||||
activemodel (3.2.22.5)
|
rack (~> 2.0)
|
||||||
activesupport (= 3.2.22.5)
|
rack-test (>= 0.6.3)
|
||||||
builder (~> 3.0.0)
|
rails-dom-testing (~> 2.0)
|
||||||
activerecord (3.2.22.5)
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||||
activemodel (= 3.2.22.5)
|
actionview (5.2.3)
|
||||||
activesupport (= 3.2.22.5)
|
activesupport (= 5.2.3)
|
||||||
arel (~> 3.0.2)
|
builder (~> 3.1)
|
||||||
tzinfo (~> 0.3.29)
|
erubi (~> 1.4)
|
||||||
activeresource (3.2.22.5)
|
rails-dom-testing (~> 2.0)
|
||||||
activemodel (= 3.2.22.5)
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||||
activesupport (= 3.2.22.5)
|
activejob (5.2.3)
|
||||||
activesupport (3.2.22.5)
|
activesupport (= 5.2.3)
|
||||||
i18n (~> 0.6, >= 0.6.4)
|
globalid (>= 0.3.6)
|
||||||
multi_json (~> 1.0)
|
activemodel (5.2.3)
|
||||||
addressable (2.3.8)
|
activesupport (= 5.2.3)
|
||||||
amq-protocol (2.2.0)
|
activerecord (5.2.3)
|
||||||
|
activemodel (= 5.2.3)
|
||||||
|
activesupport (= 5.2.3)
|
||||||
|
arel (>= 9.0)
|
||||||
|
activestorage (5.2.3)
|
||||||
|
actionpack (= 5.2.3)
|
||||||
|
activerecord (= 5.2.3)
|
||||||
|
marcel (~> 0.3.1)
|
||||||
|
activesupport (5.2.3)
|
||||||
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||||
|
i18n (>= 0.7, < 2)
|
||||||
|
minitest (~> 5.1)
|
||||||
|
tzinfo (~> 1.1)
|
||||||
|
addressable (2.5.2)
|
||||||
|
public_suffix (>= 2.0.2, < 4.0)
|
||||||
|
amq-protocol (2.3.0)
|
||||||
andand (1.3.3)
|
andand (1.3.3)
|
||||||
arel (3.0.3)
|
arel (9.0.0)
|
||||||
aws-sdk (1.66.0)
|
ast (2.4.0)
|
||||||
aws-sdk-v1 (= 1.66.0)
|
aws-eventstream (1.0.1)
|
||||||
aws-sdk-v1 (1.66.0)
|
aws-partitions (1.110.0)
|
||||||
|
aws-sdk (1.67.0)
|
||||||
|
aws-sdk-v1 (= 1.67.0)
|
||||||
|
aws-sdk-core (3.37.0)
|
||||||
|
aws-eventstream (~> 1.0)
|
||||||
|
aws-partitions (~> 1.0)
|
||||||
|
aws-sigv4 (~> 1.0)
|
||||||
|
jmespath (~> 1.0)
|
||||||
|
aws-sdk-kms (1.11.0)
|
||||||
|
aws-sdk-core (~> 3, >= 3.26.0)
|
||||||
|
aws-sigv4 (~> 1.0)
|
||||||
|
aws-sdk-s3 (1.23.1)
|
||||||
|
aws-sdk-core (~> 3, >= 3.26.0)
|
||||||
|
aws-sdk-kms (~> 1)
|
||||||
|
aws-sigv4 (~> 1.0)
|
||||||
|
aws-sdk-v1 (1.67.0)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
nokogiri (>= 1.4.4)
|
nokogiri (~> 1)
|
||||||
aws-ses (0.6.0)
|
aws-ses (0.6.0)
|
||||||
builder
|
builder
|
||||||
mail (> 2.2.5)
|
mail (> 2.2.5)
|
||||||
mime-types
|
mime-types
|
||||||
xml-simple
|
xml-simple
|
||||||
|
aws-sigv4 (1.0.3)
|
||||||
axiom-types (0.1.1)
|
axiom-types (0.1.1)
|
||||||
descendants_tracker (~> 0.0.4)
|
descendants_tracker (~> 0.0.4)
|
||||||
ice_nine (~> 0.11.0)
|
ice_nine (~> 0.11.0)
|
||||||
thread_safe (~> 0.3, >= 0.3.1)
|
thread_safe (~> 0.3, >= 0.3.1)
|
||||||
bcrypt (3.1.11)
|
backport (0.3.0)
|
||||||
binding_of_caller (0.7.2)
|
bcrypt (3.1.12)
|
||||||
|
binding_of_caller (0.8.0)
|
||||||
debug_inspector (>= 0.0.1)
|
debug_inspector (>= 0.0.1)
|
||||||
bootsnap (1.1.7)
|
bootsnap (1.3.2)
|
||||||
msgpack (~> 1.0)
|
msgpack (~> 1.0)
|
||||||
browserify-rails (0.9.3)
|
builder (3.2.3)
|
||||||
sprockets (~> 2.2)
|
bunny (2.12.0)
|
||||||
builder (3.0.4)
|
amq-protocol (~> 2.3, >= 2.3.0)
|
||||||
bunny (2.7.1)
|
carrierwave (1.2.3)
|
||||||
amq-protocol (>= 2.2.0)
|
activemodel (>= 4.0.0)
|
||||||
carrierwave (0.10.0)
|
activesupport (>= 4.0.0)
|
||||||
activemodel (>= 3.2.0)
|
|
||||||
activesupport (>= 3.2.0)
|
|
||||||
json (>= 1.7)
|
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
carrierwave-aws (0.5.0)
|
carrierwave-aws (1.3.0)
|
||||||
aws-sdk (~> 1.58)
|
aws-sdk-s3 (~> 1.0)
|
||||||
carrierwave (~> 0.7)
|
carrierwave (>= 0.7, < 2.0)
|
||||||
chronic (0.10.2)
|
chronic (0.10.2)
|
||||||
coderay (1.1.2)
|
coderay (1.1.2)
|
||||||
coercible (1.0.0)
|
coercible (1.0.0)
|
||||||
descendants_tracker (~> 0.0.1)
|
descendants_tracker (~> 0.0.1)
|
||||||
colorize (0.8.1)
|
colorize (0.8.1)
|
||||||
concurrent-ruby (1.0.5)
|
concurrent-ruby (1.1.5)
|
||||||
config (1.7.0)
|
config (1.7.0)
|
||||||
activesupport (>= 3.0)
|
activesupport (>= 3.0)
|
||||||
deep_merge (~> 1.2.1)
|
deep_merge (~> 1.2.1)
|
||||||
dry-validation (>= 0.10.4)
|
dry-validation (>= 0.10.4)
|
||||||
countries (2.1.2)
|
countries (2.1.4)
|
||||||
i18n_data (~> 0.8.0)
|
i18n_data (~> 0.8.0)
|
||||||
money (~> 6.9)
|
money (~> 6.9)
|
||||||
sixarm_ruby_unaccent (~> 1.1)
|
sixarm_ruby_unaccent (~> 1.1)
|
||||||
unicode_utils (~> 1.4)
|
unicode_utils (~> 1.4)
|
||||||
crack (0.4.2)
|
crack (0.4.3)
|
||||||
safe_yaml (~> 1.0.0)
|
safe_yaml (~> 1.0.0)
|
||||||
css_parser (1.3.6)
|
crass (1.0.4)
|
||||||
|
css_parser (1.6.0)
|
||||||
addressable
|
addressable
|
||||||
dalli (2.7.6)
|
dalli (2.7.9)
|
||||||
dante (0.2.0)
|
dante (0.2.0)
|
||||||
database_cleaner (1.6.1)
|
database_cleaner (1.7.0)
|
||||||
debase (0.2.2)
|
debase (0.2.2)
|
||||||
debase-ruby_core_source (>= 0.10.2)
|
debase-ruby_core_source (>= 0.10.2)
|
||||||
debase-ruby_core_source (0.10.3)
|
debase-ruby_core_source (0.10.3)
|
||||||
debug_inspector (0.0.2)
|
debug_inspector (0.0.3)
|
||||||
deep_merge (1.2.1)
|
deep_merge (1.2.1)
|
||||||
delayed_job (4.1.2)
|
delayed_job (4.1.5)
|
||||||
activesupport (>= 3.0, < 5.1)
|
activesupport (>= 3.0, < 5.3)
|
||||||
delayed_job_active_record (4.1.1)
|
delayed_job_active_record (4.1.3)
|
||||||
activerecord (>= 3.0, < 5.1)
|
activerecord (>= 3.0, < 5.3)
|
||||||
delayed_job (>= 3.0, < 5)
|
delayed_job (>= 3.0, < 5)
|
||||||
descendants_tracker (0.0.4)
|
descendants_tracker (0.0.4)
|
||||||
thread_safe (~> 0.3, >= 0.3.1)
|
thread_safe (~> 0.3, >= 0.3.1)
|
||||||
devise (3.5.10)
|
devise (4.5.0)
|
||||||
bcrypt (~> 3.0)
|
bcrypt (~> 3.0)
|
||||||
orm_adapter (~> 0.1)
|
orm_adapter (~> 0.1)
|
||||||
railties (>= 3.2.6, < 5)
|
railties (>= 4.1.0, < 6.0)
|
||||||
responders
|
responders
|
||||||
thread_safe (~> 0.1)
|
|
||||||
warden (~> 1.2.3)
|
warden (~> 1.2.3)
|
||||||
devise-async (0.9.0)
|
devise-async (1.0.0)
|
||||||
devise (~> 3.2)
|
activejob (>= 5.0)
|
||||||
diff-lcs (1.2.5)
|
devise (>= 4.0)
|
||||||
|
diff-lcs (1.3)
|
||||||
docile (1.3.1)
|
docile (1.3.1)
|
||||||
domain_name (0.5.20160615)
|
domain_name (0.5.20180417)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
dotenv (2.0.1)
|
dotenv (2.5.0)
|
||||||
dotenv-rails (2.0.1)
|
dotenv-rails (2.5.0)
|
||||||
dotenv (= 2.0.1)
|
dotenv (= 2.5.0)
|
||||||
|
railties (>= 3.2, < 6.0)
|
||||||
dry-configurable (0.7.0)
|
dry-configurable (0.7.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
dry-container (0.6.0)
|
dry-container (0.6.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
dry-configurable (~> 0.1, >= 0.1.3)
|
dry-configurable (~> 0.1, >= 0.1.3)
|
||||||
dry-core (0.4.5)
|
dry-core (0.4.7)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
dry-equalizer (0.2.0)
|
dry-equalizer (0.2.1)
|
||||||
|
dry-inflector (0.1.2)
|
||||||
dry-logic (0.4.2)
|
dry-logic (0.4.2)
|
||||||
dry-container (~> 0.2, >= 0.2.6)
|
dry-container (~> 0.2, >= 0.2.6)
|
||||||
dry-core (~> 0.2)
|
dry-core (~> 0.2)
|
||||||
dry-equalizer (~> 0.2)
|
dry-equalizer (~> 0.2)
|
||||||
dry-types (0.12.2)
|
dry-types (0.13.2)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
dry-configurable (~> 0.1)
|
|
||||||
dry-container (~> 0.3)
|
dry-container (~> 0.3)
|
||||||
dry-core (~> 0.2, >= 0.2.1)
|
dry-core (~> 0.4, >= 0.4.4)
|
||||||
dry-equalizer (~> 0.2)
|
dry-equalizer (~> 0.2)
|
||||||
|
dry-inflector (~> 0.1, >= 0.1.2)
|
||||||
dry-logic (~> 0.4, >= 0.4.2)
|
dry-logic (~> 0.4, >= 0.4.2)
|
||||||
inflecto (~> 0.0.0, >= 0.0.2)
|
dry-validation (0.12.2)
|
||||||
dry-validation (0.11.1)
|
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
dry-configurable (~> 0.1, >= 0.1.3)
|
dry-configurable (~> 0.1, >= 0.1.3)
|
||||||
dry-core (~> 0.2, >= 0.2.1)
|
dry-core (~> 0.2, >= 0.2.1)
|
||||||
dry-equalizer (~> 0.2)
|
dry-equalizer (~> 0.2)
|
||||||
dry-logic (~> 0.4, >= 0.4.0)
|
dry-logic (~> 0.4, >= 0.4.0)
|
||||||
dry-types (~> 0.12.0)
|
dry-types (~> 0.13.1)
|
||||||
equalizer (0.0.11)
|
equalizer (0.0.11)
|
||||||
erubis (2.7.0)
|
erubi (1.8.0)
|
||||||
execjs (2.5.2)
|
execjs (2.7.0)
|
||||||
factory_bot (4.8.2)
|
factory_bot (4.11.1)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
factory_bot_rails (4.8.2)
|
factory_bot_rails (4.11.1)
|
||||||
factory_bot (~> 4.8.2)
|
factory_bot (~> 4.11.1)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
faraday (0.9.1)
|
faraday (0.11.0)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
faraday_middleware (0.9.1)
|
faraday_middleware (0.13.0)
|
||||||
faraday (>= 0.7.4, < 0.10)
|
faraday (>= 0.7.4, < 1.0)
|
||||||
font_assets (0.1.14)
|
font_assets (0.1.14)
|
||||||
rack
|
rack
|
||||||
foreman (0.84.0)
|
foreman (0.85.0)
|
||||||
thor (~> 0.19.1)
|
thor (~> 0.19.1)
|
||||||
fullcontact (0.9.0)
|
fullcontact (0.18.0)
|
||||||
faraday (~> 0.9.0)
|
faraday (~> 0.11.0)
|
||||||
faraday_middleware (>= 0.9)
|
faraday_middleware (>= 0.10)
|
||||||
hashie (>= 2.0, < 4.0)
|
hashie (>= 2.0, < 4.0)
|
||||||
plissken
|
geocoder (1.5.0)
|
||||||
geocoder (1.2.11)
|
get_process_mem (0.2.3)
|
||||||
get_process_mem (0.2.1)
|
globalid (0.4.2)
|
||||||
|
activesupport (>= 4.2.0)
|
||||||
grape (1.1.0)
|
grape (1.1.0)
|
||||||
activesupport
|
activesupport
|
||||||
builder
|
builder
|
||||||
|
@ -212,11 +235,14 @@ GEM
|
||||||
rack (>= 1.3.0)
|
rack (>= 1.3.0)
|
||||||
rack-accept
|
rack-accept
|
||||||
virtus (>= 1.0.0)
|
virtus (>= 1.0.0)
|
||||||
grape-swagger (0.28.0)
|
grape-entity (0.7.1)
|
||||||
|
activesupport (>= 4.0)
|
||||||
|
multi_json (>= 1.3.2)
|
||||||
|
grape-swagger (0.31.1)
|
||||||
grape (>= 0.16.2)
|
grape (>= 0.16.2)
|
||||||
grape-swagger-entity (0.2.3)
|
grape-swagger-entity (0.3.0)
|
||||||
grape-entity (>= 0.5.0)
|
grape-entity (>= 0.5.0)
|
||||||
grape-swagger (>= 0.20.4)
|
grape-swagger (>= 0.31.0)
|
||||||
grape_logging (1.8.0)
|
grape_logging (1.8.0)
|
||||||
grape
|
grape
|
||||||
rack
|
rack
|
||||||
|
@ -224,44 +250,55 @@ GEM
|
||||||
grape (>= 0.12.0)
|
grape (>= 0.12.0)
|
||||||
hamster (3.0.0)
|
hamster (3.0.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
hashie (3.4.1)
|
hashdiff (0.3.7)
|
||||||
heroku-deflater (0.5.3)
|
hashie (3.6.0)
|
||||||
|
heroku-deflater (0.6.3)
|
||||||
rack (>= 1.4.5)
|
rack (>= 1.4.5)
|
||||||
hike (1.2.3)
|
htmlentities (4.3.4)
|
||||||
http-cookie (1.0.2)
|
http-cookie (1.0.3)
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
httparty (0.13.3)
|
httparty (0.16.2)
|
||||||
json (~> 1.8)
|
|
||||||
multi_xml (>= 0.5.2)
|
multi_xml (>= 0.5.2)
|
||||||
i18n (0.9.5)
|
i18n (1.6.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
i18n-js (3.0.2)
|
i18n-js (3.1.0)
|
||||||
i18n (~> 0.6, >= 0.6.6)
|
i18n (>= 0.6.6, < 2)
|
||||||
i18n_data (0.8.0)
|
i18n_data (0.8.0)
|
||||||
ice_nine (0.11.2)
|
ice_nine (0.11.2)
|
||||||
inflecto (0.0.2)
|
jaro_winkler (1.5.2)
|
||||||
journey (1.0.4)
|
jmespath (1.4.0)
|
||||||
json (1.8.6)
|
json (1.8.6)
|
||||||
kdtree (0.3)
|
kdtree (0.4)
|
||||||
lograge (0.3.6)
|
kramdown (1.17.0)
|
||||||
actionpack (>= 3)
|
lograge (0.10.0)
|
||||||
activesupport (>= 3)
|
actionpack (>= 4)
|
||||||
railties (>= 3)
|
activesupport (>= 4)
|
||||||
mail (2.5.5)
|
railties (>= 4)
|
||||||
mime-types (~> 1.16)
|
request_store (~> 1.0)
|
||||||
treetop (~> 1.4.8)
|
loofah (2.2.3)
|
||||||
|
crass (~> 1.0.2)
|
||||||
|
nokogiri (>= 1.5.9)
|
||||||
|
mail (2.7.1)
|
||||||
|
mini_mime (>= 0.1.1)
|
||||||
mail_view (2.0.4)
|
mail_view (2.0.4)
|
||||||
tilt
|
tilt
|
||||||
|
marcel (0.3.3)
|
||||||
|
mimemagic (~> 0.3.2)
|
||||||
memcachier (0.0.2)
|
memcachier (0.0.2)
|
||||||
method_source (0.9.0)
|
method_source (0.9.2)
|
||||||
mime-types (1.25.1)
|
mime-types (3.2.2)
|
||||||
mini_magick (4.9.5)
|
mime-types-data (~> 3.2015)
|
||||||
mini_portile2 (2.1.0)
|
mime-types-data (3.2018.0812)
|
||||||
money (6.10.0)
|
mimemagic (0.3.3)
|
||||||
i18n (>= 0.6.4, < 1.0)
|
mini_magick (4.9.2)
|
||||||
msgpack (1.2.0)
|
mini_mime (1.0.2)
|
||||||
|
mini_portile2 (2.4.0)
|
||||||
|
minitest (5.11.3)
|
||||||
|
money (6.13.1)
|
||||||
|
i18n (>= 0.6.4, <= 2)
|
||||||
|
msgpack (1.2.6)
|
||||||
multi_json (1.13.1)
|
multi_json (1.13.1)
|
||||||
multi_xml (0.5.5)
|
multi_xml (0.6.0)
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
mustermann (1.0.3)
|
mustermann (1.0.3)
|
||||||
mustermann-grape (1.0.0)
|
mustermann-grape (1.0.0)
|
||||||
|
@ -271,164 +308,194 @@ GEM
|
||||||
kdtree
|
kdtree
|
||||||
require_all
|
require_all
|
||||||
netrc (0.11.0)
|
netrc (0.11.0)
|
||||||
nokogiri (1.6.8.1)
|
nio4r (2.4.0)
|
||||||
mini_portile2 (~> 2.1.0)
|
nokogiri (1.10.3)
|
||||||
|
mini_portile2 (~> 2.4.0)
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
parallel (1.6.1)
|
parallel (1.13.0)
|
||||||
pg (0.18.3)
|
parser (2.6.0.0)
|
||||||
plissken (0.2.0)
|
ast (~> 2.4.0)
|
||||||
symbolize (~> 4.2)
|
pg (0.21.0)
|
||||||
polyglot (0.3.5)
|
power_assert (1.1.3)
|
||||||
power_assert (1.1.1)
|
powerpack (0.1.2)
|
||||||
pry (0.11.3)
|
pry (0.12.0)
|
||||||
coderay (~> 1.1.0)
|
coderay (~> 1.1.0)
|
||||||
method_source (~> 0.9.0)
|
method_source (~> 0.9.0)
|
||||||
puma (3.11.2)
|
public_suffix (3.0.3)
|
||||||
|
puma (3.12.0)
|
||||||
puma_worker_killer (0.1.0)
|
puma_worker_killer (0.1.0)
|
||||||
get_process_mem (~> 0.2)
|
get_process_mem (~> 0.2)
|
||||||
puma (>= 2.7, < 4)
|
puma (>= 2.7, < 4)
|
||||||
rabl (0.11.6)
|
rabl (0.14.0)
|
||||||
activesupport (>= 2.3.14)
|
activesupport (>= 2.3.14)
|
||||||
rack (1.4.7)
|
rack (2.0.7)
|
||||||
rack-accept (0.4.5)
|
rack-accept (0.4.5)
|
||||||
rack (>= 0.4)
|
rack (>= 0.4)
|
||||||
rack-attack (4.2.0)
|
rack-attack (5.4.2)
|
||||||
|
rack (>= 1.0, < 3)
|
||||||
|
rack-ssl (1.4.1)
|
||||||
rack
|
rack
|
||||||
rack-cache (1.7.2)
|
rack-test (1.1.0)
|
||||||
rack (>= 0.4)
|
rack (>= 1.0, < 3)
|
||||||
rack-ssl (1.3.4)
|
rack-timeout (0.5.1)
|
||||||
rack
|
rails (5.2.3)
|
||||||
rack-test (0.6.3)
|
actioncable (= 5.2.3)
|
||||||
rack (>= 1.0)
|
actionmailer (= 5.2.3)
|
||||||
rack-timeout (0.4.2)
|
actionpack (= 5.2.3)
|
||||||
rails (3.2.22.5)
|
actionview (= 5.2.3)
|
||||||
actionmailer (= 3.2.22.5)
|
activejob (= 5.2.3)
|
||||||
actionpack (= 3.2.22.5)
|
activemodel (= 5.2.3)
|
||||||
activerecord (= 3.2.22.5)
|
activerecord (= 5.2.3)
|
||||||
activeresource (= 3.2.22.5)
|
activestorage (= 5.2.3)
|
||||||
activesupport (= 3.2.22.5)
|
activesupport (= 5.2.3)
|
||||||
bundler (~> 1.0)
|
bundler (>= 1.3.0)
|
||||||
railties (= 3.2.22.5)
|
railties (= 5.2.3)
|
||||||
rails-i18n (3.0.1)
|
sprockets-rails (>= 2.0.0)
|
||||||
i18n (~> 0.5)
|
rails-dom-testing (2.0.3)
|
||||||
rails (>= 3.0.0, < 4.0.0)
|
activesupport (>= 4.2.0)
|
||||||
rails_12factor (0.0.3)
|
nokogiri (>= 1.6)
|
||||||
rails_serve_static_assets
|
rails-html-sanitizer (1.0.4)
|
||||||
rails_stdout_logging
|
loofah (~> 2.2, >= 2.2.2)
|
||||||
rails_serve_static_assets (0.0.4)
|
rails-i18n (5.1.3)
|
||||||
rails_stdout_logging (0.0.3)
|
i18n (>= 0.7, < 2)
|
||||||
railties (3.2.22.5)
|
railties (>= 5.0, < 6)
|
||||||
actionpack (= 3.2.22.5)
|
railties (5.2.3)
|
||||||
activesupport (= 3.2.22.5)
|
actionpack (= 5.2.3)
|
||||||
rack-ssl (~> 1.3.2)
|
activesupport (= 5.2.3)
|
||||||
|
method_source
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
rdoc (~> 3.4)
|
thor (>= 0.19.0, < 2.0)
|
||||||
thor (>= 0.14.6, < 2.0)
|
rainbow (3.0.0)
|
||||||
rake (12.3.1)
|
rake (12.3.2)
|
||||||
rdoc (3.12.2)
|
request_store (1.4.1)
|
||||||
json (~> 1.4)
|
rack (>= 1.4)
|
||||||
require_all (1.3.2)
|
require_all (2.0.0)
|
||||||
responders (1.1.2)
|
responders (2.4.1)
|
||||||
railties (>= 3.2, < 4.2)
|
actionpack (>= 4.2.0, < 6.0)
|
||||||
rest-client (1.8.0)
|
railties (>= 4.2.0, < 6.0)
|
||||||
|
rest-client (2.0.2)
|
||||||
http-cookie (>= 1.0.2, < 2.0)
|
http-cookie (>= 1.0.2, < 2.0)
|
||||||
mime-types (>= 1.16, < 3.0)
|
mime-types (>= 1.16, < 4.0)
|
||||||
netrc (~> 0.7)
|
netrc (~> 0.8)
|
||||||
roadie (3.0.4)
|
reverse_markdown (1.1.0)
|
||||||
css_parser (~> 1.3.4)
|
nokogiri
|
||||||
nokogiri (~> 1.6.0)
|
roadie (3.4.0)
|
||||||
roadie-rails (1.0.5)
|
css_parser (~> 1.4)
|
||||||
railties (>= 3.0, < 4.3)
|
nokogiri (~> 1.5)
|
||||||
roadie (~> 3.0)
|
roadie-rails (1.3.0)
|
||||||
rspec (3.5.0)
|
railties (>= 3.0, < 5.3)
|
||||||
rspec-core (~> 3.5.0)
|
roadie (~> 3.1)
|
||||||
rspec-expectations (~> 3.5.0)
|
rspec (3.8.0)
|
||||||
rspec-mocks (~> 3.5.0)
|
rspec-core (~> 3.8.0)
|
||||||
rspec-core (3.5.1)
|
rspec-expectations (~> 3.8.0)
|
||||||
rspec-support (~> 3.5.0)
|
rspec-mocks (~> 3.8.0)
|
||||||
rspec-expectations (3.5.0)
|
rspec-core (3.8.0)
|
||||||
|
rspec-support (~> 3.8.0)
|
||||||
|
rspec-expectations (3.8.2)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.5.0)
|
rspec-support (~> 3.8.0)
|
||||||
rspec-mocks (3.5.0)
|
rspec-mocks (3.8.0)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.5.0)
|
rspec-support (~> 3.8.0)
|
||||||
rspec-rails (3.5.0)
|
rspec-rails (3.8.1)
|
||||||
actionpack (>= 3.0)
|
actionpack (>= 3.0)
|
||||||
activesupport (>= 3.0)
|
activesupport (>= 3.0)
|
||||||
railties (>= 3.0)
|
railties (>= 3.0)
|
||||||
rspec-core (~> 3.5.0)
|
rspec-core (~> 3.8.0)
|
||||||
rspec-expectations (~> 3.5.0)
|
rspec-expectations (~> 3.8.0)
|
||||||
rspec-mocks (~> 3.5.0)
|
rspec-mocks (~> 3.8.0)
|
||||||
rspec-support (~> 3.5.0)
|
rspec-support (~> 3.8.0)
|
||||||
rspec-support (3.5.0)
|
rspec-support (3.8.0)
|
||||||
|
rubocop (0.63.1)
|
||||||
|
jaro_winkler (~> 1.5.1)
|
||||||
|
parallel (~> 1.10)
|
||||||
|
parser (>= 2.5, != 2.5.1.1)
|
||||||
|
powerpack (~> 0.1)
|
||||||
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
|
ruby-progressbar (~> 1.7)
|
||||||
|
unicode-display_width (~> 1.4.0)
|
||||||
ruby-debug-ide (0.6.1)
|
ruby-debug-ide (0.6.1)
|
||||||
rake (>= 0.8.1)
|
rake (>= 0.8.1)
|
||||||
ruby-prof (0.15.9)
|
ruby-prof (0.15.9)
|
||||||
|
ruby-progressbar (1.10.0)
|
||||||
safe_yaml (1.0.4)
|
safe_yaml (1.0.4)
|
||||||
sass (3.2.19)
|
sass (3.2.19)
|
||||||
sass-rails (3.2.6)
|
sass-rails (5.0.7)
|
||||||
railties (~> 3.2.0)
|
railties (>= 4.0.0, < 6)
|
||||||
sass (>= 3.1.10)
|
sass (~> 3.1)
|
||||||
tilt (~> 1.3)
|
sprockets (>= 2.8, < 4.0)
|
||||||
|
sprockets-rails (>= 2.0, < 4.0)
|
||||||
|
tilt (>= 1.1, < 3)
|
||||||
simplecov (0.16.1)
|
simplecov (0.16.1)
|
||||||
docile (~> 1.1)
|
docile (~> 1.1)
|
||||||
json (>= 1.8, < 3)
|
json (>= 1.8, < 3)
|
||||||
simplecov-html (~> 0.10.0)
|
simplecov-html (~> 0.10.0)
|
||||||
simplecov-html (0.10.2)
|
simplecov-html (0.10.2)
|
||||||
sixarm_ruby_unaccent (1.2.0)
|
sixarm_ruby_unaccent (1.2.0)
|
||||||
sprockets (2.2.3)
|
solargraph (0.31.2)
|
||||||
hike (~> 1.2)
|
backport (~> 0.3)
|
||||||
multi_json (~> 1.0)
|
htmlentities (~> 4.3, >= 4.3.4)
|
||||||
rack (~> 1.0)
|
jaro_winkler (~> 1.5)
|
||||||
tilt (~> 1.1, != 1.3.0)
|
kramdown (~> 1.16)
|
||||||
stripe (1.49.0)
|
parser (~> 2.3)
|
||||||
rest-client (>= 1.4, < 3.0)
|
reverse_markdown (~> 1.0, >= 1.0.5)
|
||||||
symbolize (4.5.2)
|
rubocop (~> 0.52)
|
||||||
activemodel (>= 3.2, < 5)
|
thor (~> 0.19, >= 0.19.4)
|
||||||
activesupport (>= 3.2, < 5)
|
tilt (~> 2.0)
|
||||||
i18n
|
yard (~> 0.9)
|
||||||
table_print (1.5.4)
|
sprockets (3.7.2)
|
||||||
test-unit (3.2.7)
|
concurrent-ruby (~> 1.0)
|
||||||
|
rack (> 1, < 3)
|
||||||
|
sprockets-rails (3.2.1)
|
||||||
|
actionpack (>= 4.0)
|
||||||
|
activesupport (>= 4.0)
|
||||||
|
sprockets (>= 3.0.0)
|
||||||
|
stripe (1.58.0)
|
||||||
|
rest-client (>= 1.4, < 4.0)
|
||||||
|
table_print (1.5.6)
|
||||||
|
test-unit (3.2.8)
|
||||||
power_assert
|
power_assert
|
||||||
thor (0.19.4)
|
thor (0.19.4)
|
||||||
thread_safe (0.3.6)
|
thread_safe (0.3.6)
|
||||||
tilt (1.4.1)
|
tilt (2.0.9)
|
||||||
timecop (0.7.3)
|
timecop (0.9.1)
|
||||||
traceroute (0.5.0)
|
traceroute (0.8.0)
|
||||||
rails (>= 3.0.0)
|
rails (>= 3.0.0)
|
||||||
treetop (1.4.15)
|
tzinfo (1.2.5)
|
||||||
polyglot
|
thread_safe (~> 0.1)
|
||||||
polyglot (>= 0.3.1)
|
uglifier (4.1.19)
|
||||||
tzinfo (0.3.54)
|
execjs (>= 0.3.0, < 3)
|
||||||
uglifier (2.7.1)
|
|
||||||
execjs (>= 0.3.0)
|
|
||||||
json (>= 1.8.0)
|
|
||||||
unf (0.1.4)
|
unf (0.1.4)
|
||||||
unf_ext
|
unf_ext
|
||||||
unf_ext (0.0.7.2)
|
unf_ext (0.0.7.5)
|
||||||
|
unicode-display_width (1.4.1)
|
||||||
unicode_utils (1.4.0)
|
unicode_utils (1.4.0)
|
||||||
virtus (1.0.5)
|
virtus (1.0.5)
|
||||||
axiom-types (~> 0.1)
|
axiom-types (~> 0.1)
|
||||||
coercible (~> 1.0)
|
coercible (~> 1.0)
|
||||||
descendants_tracker (~> 0.0, >= 0.0.3)
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
||||||
equalizer (~> 0.0, >= 0.0.9)
|
equalizer (~> 0.0, >= 0.0.9)
|
||||||
warden (1.2.7)
|
warden (1.2.8)
|
||||||
rack (>= 1.0)
|
rack (>= 2.0.6)
|
||||||
webmock (1.21.0)
|
webmock (3.4.2)
|
||||||
addressable (>= 2.3.6)
|
addressable (>= 2.3.6)
|
||||||
crack (>= 0.3.2)
|
crack (>= 0.3.2)
|
||||||
|
hashdiff
|
||||||
|
websocket-driver (0.7.1)
|
||||||
|
websocket-extensions (>= 0.1.0)
|
||||||
|
websocket-extensions (0.1.4)
|
||||||
xml-simple (1.1.5)
|
xml-simple (1.1.5)
|
||||||
|
yard (0.9.18)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
action_mailer_matchers
|
action_mailer_matchers
|
||||||
aws-sdk
|
aws-sdk (~> 1)
|
||||||
aws-ses
|
aws-ses
|
||||||
binding_of_caller
|
binding_of_caller
|
||||||
bootsnap
|
bootsnap
|
||||||
browserify-rails
|
|
||||||
bunny (>= 2.6.3)
|
bunny (>= 2.6.3)
|
||||||
carrierwave
|
carrierwave
|
||||||
carrierwave-aws
|
carrierwave-aws
|
||||||
|
@ -440,7 +507,7 @@ DEPENDENCIES
|
||||||
database_cleaner
|
database_cleaner
|
||||||
debase
|
debase
|
||||||
delayed_job_active_record
|
delayed_job_active_record
|
||||||
devise
|
devise (~> 4.4)
|
||||||
devise-async
|
devise-async
|
||||||
dotenv-rails
|
dotenv-rails
|
||||||
dry-validation
|
dry-validation
|
||||||
|
@ -450,8 +517,8 @@ DEPENDENCIES
|
||||||
foreman
|
foreman
|
||||||
fullcontact
|
fullcontact
|
||||||
geocoder
|
geocoder
|
||||||
grape (~> 1.1.0)
|
grape
|
||||||
grape-entity!
|
grape-entity
|
||||||
grape-swagger
|
grape-swagger
|
||||||
grape-swagger-entity
|
grape-swagger-entity
|
||||||
grape_devise!
|
grape_devise!
|
||||||
|
@ -468,17 +535,17 @@ DEPENDENCIES
|
||||||
nearest_time_zone
|
nearest_time_zone
|
||||||
parallel
|
parallel
|
||||||
param_validation!
|
param_validation!
|
||||||
pg
|
pg (~> 0.11)
|
||||||
pry
|
pry
|
||||||
puma
|
puma
|
||||||
puma_worker_killer
|
puma_worker_killer
|
||||||
qx!
|
qx!
|
||||||
rabl
|
rabl
|
||||||
rack-attack
|
rack-attack
|
||||||
|
rack-ssl
|
||||||
rack-timeout
|
rack-timeout
|
||||||
rails (= 3.2.22.5)
|
rails (= 5.2.3)
|
||||||
rails-i18n (~> 3.0.0)
|
rails-i18n
|
||||||
rails_12factor
|
|
||||||
rake
|
rake
|
||||||
roadie-rails
|
roadie-rails
|
||||||
rspec
|
rspec
|
||||||
|
@ -486,8 +553,9 @@ DEPENDENCIES
|
||||||
ruby-debug-ide
|
ruby-debug-ide
|
||||||
ruby-prof (= 0.15.9)
|
ruby-prof (= 0.15.9)
|
||||||
sass (= 3.2.19)
|
sass (= 3.2.19)
|
||||||
sass-rails (= 3.2.6)
|
sass-rails
|
||||||
simplecov (~> 0.16.1)
|
simplecov (~> 0.16.1)
|
||||||
|
solargraph
|
||||||
sprockets
|
sprockets
|
||||||
stripe
|
stripe
|
||||||
stripe-ruby-mock (~> 2.4.1)!
|
stripe-ruby-mock (~> 2.4.1)!
|
||||||
|
@ -499,7 +567,7 @@ DEPENDENCIES
|
||||||
webmock
|
webmock
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 2.3.7p456
|
ruby 2.5.1p57
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.17.3
|
1.17.3
|
||||||
|
|
4
Rakefile
4
Rakefile
|
@ -1,7 +1,9 @@
|
||||||
#!/usr/bin/env rake
|
#!/usr/bin/env rake
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||||
|
|
||||||
require File.expand_path('../config/application', __FILE__)
|
require File.expand_path('config/application', __dir__)
|
||||||
|
|
||||||
Commitchange::Application.load_tasks
|
Commitchange::Application.load_tasks
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class Houdini::API < Grape::API
|
class Houdini::API < Grape::API
|
||||||
format :json
|
format :json
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
require 'houdini/v1/validations'
|
require 'houdini/v1/validations'
|
||||||
class Houdini::V1::API < Grape::API
|
class Houdini::V1::API < Grape::API
|
||||||
logger.formatter = GrapeLogging::Formatters::Rails.new
|
logger.formatter = GrapeLogging::Formatters::Rails.new
|
||||||
use GrapeLogging::Middleware::RequestLogger, { logger: logger }
|
use GrapeLogging::Middleware::RequestLogger, logger: logger
|
||||||
content_type :json, 'application/json'
|
content_type :json, 'application/json'
|
||||||
default_format :json
|
default_format :json
|
||||||
rescue_from Grape::Exceptions::ValidationErrors do |e|
|
rescue_from Grape::Exceptions::ValidationErrors do |e|
|
||||||
output = {errors: e}
|
output = { errors: e }
|
||||||
error! output, 400
|
error! output, 400
|
||||||
end
|
end
|
||||||
|
|
||||||
#include Houdini::V1::Helpers::ApplicationHelper
|
# include Houdini::V1::Helpers::ApplicationHelper
|
||||||
mount Houdini::V1::Nonprofit => '/nonprofit'
|
mount Houdini::V1::Nonprofit => '/nonprofit'
|
||||||
# Additional mounts are added via generators above this line
|
# Additional mounts are added via generators above this line
|
||||||
# DON'T REMOVE THIS OR THE PREVIOUS LINES!!!
|
# DON'T REMOVE THIS OR THE PREVIOUS LINES!!!
|
||||||
uri_for_host = URI.parse(Settings.api_domain&.url || Settings.cdn.url)
|
uri_for_host = URI.parse(Settings.api_domain&.url || Settings.cdn.url)
|
||||||
add_swagger_documentation \
|
add_swagger_documentation \
|
||||||
host: "#{uri_for_host.host}#{uri_for_host.port ? ":#{uri_for_host.port}" : ""}",
|
host: "#{uri_for_host.host}#{uri_for_host.port ? ":#{uri_for_host.port}" : ''}",
|
||||||
schemes: [uri_for_host.scheme],
|
schemes: [uri_for_host.scheme],
|
||||||
base_path: '/api/v1'
|
base_path: '/api/v1'
|
||||||
end
|
end
|
|
@ -1,6 +1,8 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class Houdini::V1::BaseAPI < Grape::API
|
class Houdini::V1::BaseAPI < Grape::API
|
||||||
#helpers ApplicationHelper
|
# helpers ApplicationHelper
|
||||||
# helpers do
|
# helpers do
|
||||||
# def session
|
# def session
|
||||||
# env['rack.session']
|
# env['rack.session']
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class Houdini::V1::Entities::Nonprofit < Grape::Entity
|
class Houdini::V1::Entities::Nonprofit < Grape::Entity
|
||||||
expose :id
|
expose :id
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class Houdini::V1::Entities::ValidationError < Grape::Entity
|
class Houdini::V1::Entities::ValidationError < Grape::Entity
|
||||||
expose :params, documentation: {type: 'String', desc: 'Params where the following had an error.', is_array: true}
|
expose :params, documentation: { type: 'String', desc: 'Params where the following had an error.', is_array: true }
|
||||||
expose :messages, documentation: {type:'String', desc: 'The validation messages for the params', is_array: true}
|
expose :messages, documentation: { type: 'String', desc: 'The validation messages for the params', is_array: true }
|
||||||
end
|
end
|
|
@ -1,4 +1,6 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class Houdini::V1::Entities::ValidationErrors < Grape::Entity
|
class Houdini::V1::Entities::ValidationErrors < Grape::Entity
|
||||||
expose :errors, documentation: {type: ValidationError, desc: 'errors', is_array:true}
|
expose :errors, documentation: { type: ValidationError, desc: 'errors', is_array: true }
|
||||||
end
|
end
|
|
@ -1,22 +1,21 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Houdini::V1::Helpers::ApplicationHelper
|
module Houdini::V1::Helpers::ApplicationHelper
|
||||||
extend Grape::API::Helpers
|
extend Grape::API::Helpers
|
||||||
|
|
||||||
|
|
||||||
def session
|
def session
|
||||||
env['rack.session']
|
env['rack.session']
|
||||||
end
|
end
|
||||||
|
|
||||||
def protect_against_forgery
|
def protect_against_forgery
|
||||||
unless verified_request?
|
error!('Unauthorized', 401) unless verified_request?
|
||||||
error!('Unauthorized', 401)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def verified_request?
|
def verified_request?
|
||||||
!protect_against_forgery? || request.get? || request.head? ||
|
!protect_against_forgery? || request.get? || request.head? ||
|
||||||
form_authenticity_token == request.headers['X-CSRF-Token'] ||
|
form_authenticity_token == request.headers['X-CSRF-Token'] ||
|
||||||
form_authenticity_token == request.headers['X-Csrf-Token']
|
form_authenticity_token == request.headers['X-Csrf-Token']
|
||||||
end
|
end
|
||||||
|
|
||||||
def form_authenticity_token
|
def form_authenticity_token
|
||||||
|
@ -24,11 +23,10 @@ module Houdini::V1::Helpers::ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def protect_against_forgery?
|
def protect_against_forgery?
|
||||||
allow_forgery_protection = Rails.configuration.action_controller.allow_forgery_protection
|
allow_forgery_protection = Rails.configuration.action_controller.allow_forgery_protection
|
||||||
allow_forgery_protection.nil? || allow_forgery_protection
|
allow_forgery_protection.nil? || allow_forgery_protection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# def rescue_ar_invalid( *class_to_hash)
|
# def rescue_ar_invalid( *class_to_hash)
|
||||||
# rescue_with ActiveRecord::RecordInvalid do |error|
|
# rescue_with ActiveRecord::RecordInvalid do |error|
|
||||||
# output = []
|
# output = []
|
||||||
|
@ -40,6 +38,4 @@ module Houdini::V1::Helpers::ApplicationHelper
|
||||||
#
|
#
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Houdini::V1::Helpers::RescueHelper
|
module Houdini::V1::Helpers::RescueHelper
|
||||||
require 'active_support/concern'
|
require 'active_support/concern'
|
||||||
|
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
include Grape::DSL::Configuration
|
include Grape::DSL::Configuration
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
def rescue_ar_invalid( *class_to_hash)
|
def rescue_ar_invalid(*class_to_hash)
|
||||||
rescue_with ActiveRecord::RecordInvalid do |error|
|
rescue_with ActiveRecord::RecordInvalid do |error|
|
||||||
output = []
|
output = []
|
||||||
error.record.errors do |attr,message|
|
error.record.errors do |attr, message|
|
||||||
output.push({params: "#{class_to_hash[error.record.class]}['#{attr}']",
|
output.push(params: "#{class_to_hash[error.record.class]}['#{attr}']",
|
||||||
message: message})
|
message: message)
|
||||||
|
end
|
||||||
|
raise Grape::Exceptions::ValidationErrors, output
|
||||||
end
|
end
|
||||||
raise Grape::Exceptions::ValidationErrors.new(output)
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,10 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class Houdini::V1::Nonprofit < Houdini::V1::BaseAPI
|
class Houdini::V1::Nonprofit < Houdini::V1::BaseAPI
|
||||||
helpers Houdini::V1::Helpers::ApplicationHelper, Houdini::V1::Helpers::RescueHelper
|
helpers Houdini::V1::Helpers::ApplicationHelper, Houdini::V1::Helpers::RescueHelper
|
||||||
|
|
||||||
before do
|
before do
|
||||||
protect_against_forgery
|
protect_against_forgery
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Return a nonprofit.' do
|
desc 'Return a nonprofit.' do
|
||||||
success Houdini::V1::Entities::Nonprofit
|
success Houdini::V1::Entities::Nonprofit
|
||||||
|
@ -22,99 +24,88 @@ class Houdini::V1::Nonprofit < Houdini::V1::BaseAPI
|
||||||
desc 'Register a nonprofit' do
|
desc 'Register a nonprofit' do
|
||||||
success Houdini::V1::Entities::Nonprofit
|
success Houdini::V1::Entities::Nonprofit
|
||||||
|
|
||||||
#this needs to be a validation an array
|
# this needs to be a validation an array
|
||||||
failure [{code:400, message:'Validation Errors', model: Houdini::V1::Entities::ValidationErrors}]
|
failure [{ code: 400, message: 'Validation Errors', model: Houdini::V1::Entities::ValidationErrors }]
|
||||||
end
|
end
|
||||||
|
|
||||||
params do
|
params do
|
||||||
|
requires :nonprofit, type: Hash do
|
||||||
requires :nonprofit, type: Hash do
|
requires :name, type: String, desc: 'Organization Name', allow_blank: false, documentation: { param_type: 'body' }
|
||||||
requires :name, type:String, desc: 'Organization Name', allow_blank: false, documentation: { param_type: 'body' }
|
optional :website, type: String, desc: 'Organization website URL', allow_blank: true, regexp: URI::DEFAULT_PARSER.make_regexp, documentation: { param_type: 'body' }, coerce_with: lambda { |url|
|
||||||
optional :website, type:String, desc: 'Organization website URL', allow_blank:true, regexp: URI::regexp, documentation: { param_type: 'body' }, coerce_with: ->(url) {
|
|
||||||
coerced_url = url
|
coerced_url = url
|
||||||
unless (url =~ /\Ahttp:\/\/.*/i || url =~ /\Ahttps:\/\/.*/i)
|
unless url =~ %r{\Ahttp://.*}i || url =~ %r{\Ahttps://.*}i
|
||||||
coerced_url = 'http://'+ coerced_url
|
coerced_url = 'http://' + coerced_url
|
||||||
end
|
end
|
||||||
coerced_url
|
coerced_url
|
||||||
}
|
}
|
||||||
requires :zip_code, type:String, allow_blank: false, desc: "Organization Address ZIP Code", documentation: { param_type: 'body' }
|
requires :zip_code, type: String, allow_blank: false, desc: 'Organization Address ZIP Code', documentation: { param_type: 'body' }
|
||||||
requires :state_code, type:String, allow_blank: false, desc: "Organization Address State Code", documentation: { param_type: 'body' }
|
requires :state_code, type: String, allow_blank: false, desc: 'Organization Address State Code', documentation: { param_type: 'body' }
|
||||||
requires :city, type:String, allow_blank: false, desc: "Organization Address City", documentation: { param_type: 'body' }
|
requires :city, type: String, allow_blank: false, desc: 'Organization Address City', documentation: { param_type: 'body' }
|
||||||
optional :email, type:String, desc: 'Organization email (public)', regexp: Email::Regex, documentation: { param_type: 'body' }
|
optional :email, type: String, desc: 'Organization email (public)', regexp: Email::Regex, documentation: { param_type: 'body' }
|
||||||
optional :phone, type:String, desc: 'Organization phone (public)', documentation: { param_type: 'body' }
|
optional :phone, type: String, desc: 'Organization phone (public)', documentation: { param_type: 'body' }
|
||||||
end
|
end
|
||||||
|
|
||||||
requires :user, type: Hash do
|
requires :user, type: Hash do
|
||||||
requires :name, type:String, desc: 'Full name', allow_blank:false, documentation: { param_type: 'body' }
|
requires :name, type: String, desc: 'Full name', allow_blank: false, documentation: { param_type: 'body' }
|
||||||
requires :email, type:String, desc: 'Username', allow_blank: false, documentation: { param_type: 'body' }
|
requires :email, type: String, desc: 'Username', allow_blank: false, documentation: { param_type: 'body' }
|
||||||
requires :password, type:String, desc: 'Password', allow_blank: false, is_equal_to: :password_confirmation, documentation: { param_type: 'body' }
|
requires :password, type: String, desc: 'Password', allow_blank: false, is_equal_to: :password_confirmation, documentation: { param_type: 'body' }
|
||||||
requires :password_confirmation, type:String, desc: 'Password confirmation', allow_blank: false, documentation: { param_type: 'body' }
|
requires :password_confirmation, type: String, desc: 'Password confirmation', allow_blank: false, documentation: { param_type: 'body' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
post do
|
post do
|
||||||
declared_params = declared(params)
|
declared_params = declared(params)
|
||||||
np = nil
|
np = nil
|
||||||
u = nil
|
u = nil
|
||||||
Qx.transaction do
|
Qx.transaction do
|
||||||
|
np = Nonprofit.new(OnboardAccounts.set_nonprofit_defaults(declared_params[:nonprofit]))
|
||||||
|
|
||||||
begin
|
begin
|
||||||
np = Nonprofit.new(OnboardAccounts.set_nonprofit_defaults(declared_params[:nonprofit]))
|
np.save!
|
||||||
|
|
||||||
begin
|
|
||||||
np.save!
|
|
||||||
rescue ActiveRecord::RecordInvalid => e
|
|
||||||
if (e.record.errors[:slug])
|
|
||||||
begin
|
|
||||||
slug = SlugNonprofitNamingAlgorithm.new(np.state_code_slug, np.city_slug).create_copy_name(np.slug)
|
|
||||||
np.slug = slug
|
|
||||||
np.save!
|
|
||||||
rescue UnableToCreateNameCopyError
|
|
||||||
raise Grape::Exceptions::ValidationErrors.new(errors:[Grape::Exceptions::Validation.new(
|
|
||||||
|
|
||||||
params: ["nonprofit[name]"],
|
|
||||||
message: "has an invalid slug. Contact support for help."
|
|
||||||
)])
|
|
||||||
end
|
|
||||||
else
|
|
||||||
raise e
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
u = User.new(declared_params[:user])
|
|
||||||
u.save!
|
|
||||||
|
|
||||||
role = u.roles.build(host: np, name: 'nonprofit_admin')
|
|
||||||
role.save!
|
|
||||||
|
|
||||||
billing_plan = BillingPlan.find(Settings.default_bp.id)
|
|
||||||
b_sub = np.build_billing_subscription(billing_plan: billing_plan, status: 'active')
|
|
||||||
b_sub.save!
|
|
||||||
rescue ActiveRecord::RecordInvalid => e
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
class_to_name = {Nonprofit => 'nonprofit', User => 'user'}
|
if e.record.errors[:slug]
|
||||||
if class_to_name[e.record.class]
|
begin
|
||||||
errors = e.record.errors.keys.map {|k|
|
slug = SlugNonprofitNamingAlgorithm.new(np.state_code_slug, np.city_slug).create_copy_name(np.slug)
|
||||||
|
np.slug = slug
|
||||||
errors = e.record.errors[k].uniq
|
np.save!
|
||||||
errors.map{|error| Grape::Exceptions::Validation.new(
|
rescue UnableToCreateNameCopyError
|
||||||
|
raise Grape::Exceptions::ValidationErrors.new(errors: [Grape::Exceptions::Validation.new(
|
||||||
params: ["#{class_to_name[e.record.class]}[#{k.to_s}]"],
|
params: ['nonprofit[name]'],
|
||||||
message: error
|
message: 'has an invalid slug. Contact support for help.'
|
||||||
|
)])
|
||||||
)}
|
end
|
||||||
}
|
|
||||||
|
|
||||||
raise Grape::Exceptions::ValidationErrors.new(errors:errors.flatten)
|
|
||||||
else
|
else
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
u = User.new(declared_params[:user])
|
||||||
|
u.save!
|
||||||
|
|
||||||
|
role = u.roles.build(host: np, name: 'nonprofit_admin')
|
||||||
|
role.save!
|
||||||
|
|
||||||
|
billing_plan = BillingPlan.find(Settings.default_bp.id)
|
||||||
|
b_sub = np.build_billing_subscription(billing_plan: billing_plan, status: 'active')
|
||||||
|
b_sub.save!
|
||||||
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
|
class_to_name = { Nonprofit => 'nonprofit', User => 'user' }
|
||||||
|
if class_to_name[e.record.class]
|
||||||
|
errors = e.record.errors.keys.map do |k|
|
||||||
|
errors = e.record.errors[k].uniq
|
||||||
|
errors.map do |error|
|
||||||
|
Grape::Exceptions::Validation.new(
|
||||||
|
params: ["#{class_to_name[e.record.class]}[#{k}]"],
|
||||||
|
message: error
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
raise Grape::Exceptions::ValidationErrors.new(errors: errors.flatten)
|
||||||
|
else
|
||||||
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#onboard callback
|
# onboard callback
|
||||||
present np, with: Houdini::V1::Entities::Nonprofit
|
present np, with: Houdini::V1::Entities::Nonprofit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
require 'houdini/v1/validators/is_equal_to'
|
require 'houdini/v1/validators/is_equal_to'
|
|
@ -1,8 +1,10 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class Houdini::V1::Validators::IsEqualTo < Grape::Validations::Base
|
class Houdini::V1::Validators::IsEqualTo < Grape::Validations::Base
|
||||||
def validate_param!(attr_name, params)
|
def validate_param!(attr_name, params)
|
||||||
if params[attr_name] != params[@option]
|
if params[attr_name] != params[@option]
|
||||||
fail Grape::Exceptions::Validation, params: [@scope.full_name(attr_name), @scope.full_name(@option)], message: message(:is_equal_to)
|
raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name), @scope.full_name(@option)], message: message(:is_equal_to)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,10 +1,10 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class ActivitiesController < ApplicationController
|
class ActivitiesController < ApplicationController
|
||||||
|
before_action :authenticate_user!, only: [:create]
|
||||||
|
|
||||||
before_filter :authenticate_user!, only: [:create]
|
def create
|
||||||
|
json_saved Activity.create(params[:activity])
|
||||||
def create
|
end
|
||||||
json_saved Activity.create(params[:activity])
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,174 +1,178 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
before_filter :set_locale, :redirect_to_maintenance
|
before_action :set_locale, :redirect_to_maintenance
|
||||||
|
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
|
|
||||||
helper_method \
|
helper_method \
|
||||||
:current_role?,
|
:current_role?,
|
||||||
:current_nonprofit_user?,
|
:current_nonprofit_user?,
|
||||||
:administered_nonprofit,
|
:administered_nonprofit,
|
||||||
:nonprofit_in_trial?,
|
:nonprofit_in_trial?,
|
||||||
:current_plan_tier #int
|
:current_plan_tier # int
|
||||||
|
|
||||||
def set_locale
|
def set_locale
|
||||||
if params[:locale] && Settings.available_locales.include?(params[:locale])
|
if params[:locale] && Settings.available_locales.include?(params[:locale])
|
||||||
I18n.locale = params[:locale]
|
I18n.locale = params[:locale]
|
||||||
else
|
else
|
||||||
I18n.locale = Settings.language
|
I18n.locale = Settings.language
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect_to_maintenance
|
def redirect_to_maintenance
|
||||||
if (Settings&.maintenance&.maintenance_mode && !current_user)
|
if Settings&.maintenance&.maintenance_mode && !current_user
|
||||||
unless (self.class == Users::SessionsController &&
|
unless self.class == Users::SessionsController &&
|
||||||
((Settings.maintenance.maintenance_token && params[:maintenance_token] == Settings.maintenance.maintenance_token) || params[:format] == 'json'))
|
((Settings.maintenance.maintenance_token && params[:maintenance_token] == Settings.maintenance.maintenance_token) || params[:format] == 'json')
|
||||||
redirect_to Settings.maintenance.maintenance_page
|
redirect_to Settings.maintenance.maintenance_page
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def json_saved(model, msg=nil)
|
def json_saved(model, msg = nil)
|
||||||
if model.valid?
|
if model.valid?
|
||||||
flash[:notice] = msg if msg
|
flash[:notice] = msg if msg
|
||||||
render json: model, status: 200
|
render json: model, status: 200
|
||||||
else
|
else
|
||||||
render json: model.errors.full_messages, status: :unprocessable_entity
|
render json: model.errors.full_messages, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# A response helper for use with the param_validation gem
|
# A response helper for use with the param_validation gem
|
||||||
# use like: render_json{ UpdateUsers.update(params[:user]) }
|
# use like: render_json{ UpdateUsers.update(params[:user]) }
|
||||||
# will catch and pretty print exceptions using the rails loggers
|
# will catch and pretty print exceptions using the rails loggers
|
||||||
def render_json(&block)
|
def render_json(&block)
|
||||||
begin
|
begin
|
||||||
result = {status: 200, json: yield(block)}
|
result = { status: 200, json: yield(block) }
|
||||||
rescue ParamValidation::ValidationError => e
|
rescue ParamValidation::ValidationError => e
|
||||||
logger.info "422: #{e}".red.bold
|
logger.info "422: #{e}".red.bold
|
||||||
#logger.info ">>".bold.red + " #{{'Failed key name' => e.data[:key], 'Value' => e.data[:val], 'Failed validator' => e.data[:name]}}".red
|
# logger.info ">>".bold.red + " #{{'Failed key name' => e.data[:key], 'Value' => e.data[:val], 'Failed validator' => e.data[:name]}}".red
|
||||||
result = {status: 422, json: {error: e.message}}
|
result = { status: 422, json: { error: e.message } }
|
||||||
rescue CCOrgError => e
|
rescue CCOrgError => e
|
||||||
logger.info "422: #{e}".red.bold
|
logger.info "422: #{e}".red.bold
|
||||||
result = {status: 422, json: {error: e.message}}
|
result = { status: 422, json: { error: e.message } }
|
||||||
rescue ActiveRecord::RecordNotFound => e
|
rescue ActiveRecord::RecordNotFound => e
|
||||||
logger.info "404: #{e}".red.bold
|
logger.info "404: #{e}".red.bold
|
||||||
result = {status: 404, json: {error: e.message}}
|
result = { status: 404, json: { error: e.message } }
|
||||||
rescue AuthenticationError => e
|
rescue AuthenticationError => e
|
||||||
logger.info "401: #{e}".red.bold
|
logger.info "401: #{e}".red.bold
|
||||||
result = {status: 401, json: {error: e.message}}
|
result = { status: 401, json: { error: e.message } }
|
||||||
rescue ExpiredTokenError => e
|
rescue ExpiredTokenError => e
|
||||||
logger.info "422: #{e}".red.bold
|
logger.info "422: #{e}".red.bold
|
||||||
result = {status: 422, json: {error: e.message}}
|
result = { status: 422, json: { error: e.message } }
|
||||||
rescue Exception => e # a non-validation related exception
|
rescue Exception => e # a non-validation related exception
|
||||||
logger.error "500: #{e}".red.bold
|
logger.error "500: #{e}".red.bold
|
||||||
logger.error e.backtrace.take(5).map{|l| ">>".red.bold + " #{l}"}.join("\n").red
|
logger.error e.backtrace.take(5).map { |l| '>>'.red.bold + " #{l}" }.join("\n").red
|
||||||
result = {status: 500, json: {error: e.message, backtrace: e.backtrace}}
|
result = { status: 500, json: { error: e.message, backtrace: e.backtrace } }
|
||||||
end
|
end
|
||||||
render result
|
render result
|
||||||
end
|
end
|
||||||
|
|
||||||
# Test that within the last 5 minutes, the user has confirmed their password
|
# Test that within the last 5 minutes, the user has confirmed their password
|
||||||
def password_was_confirmed(token)
|
def password_was_confirmed(token)
|
||||||
session[:pw_token] == token && Chronic.parse(session[:pw_timestamp]) >= 5.minutes.ago.utc
|
session[:pw_token] == token && Chronic.parse(session[:pw_timestamp]) >= 5.minutes.ago.utc
|
||||||
end
|
end
|
||||||
|
|
||||||
def store_location
|
def store_location
|
||||||
referrer = request.fullpath
|
referrer = request.fullpath
|
||||||
no_redirects = ['/users', '/signup', '/signin', '/users/sign_in', '/users/sign_up', '/users/password', '/users/sign_out', /.*\.json.*/, /.*auth\/facebook.*/]
|
no_redirects = ['/users', '/signup', '/signin', '/users/sign_in', '/users/sign_up', '/users/password', '/users/sign_out', /.*\.json.*/, %r{.*auth/facebook.*}]
|
||||||
unless request.format.symbol == :json || no_redirects.map{|p| referrer.match(p)}.any?
|
unless request.format.symbol == :json || no_redirects.map { |p| referrer.match(p) }.any?
|
||||||
session[:previous_url] = referrer
|
session[:previous_url] = referrer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def block_with_sign_in(msg=nil)
|
def block_with_sign_in(msg = nil)
|
||||||
store_location
|
store_location
|
||||||
if current_user
|
if current_user
|
||||||
flash[:notice] = "It looks like you're not allowed to access that page. If this seems like a mistake, please contact #{Settings.mailer.email}"
|
flash[:notice] = "It looks like you're not allowed to access that page. If this seems like a mistake, please contact #{Settings.mailer.email}"
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
else
|
else
|
||||||
msg ||= 'We need to sign you in before you can do that.'
|
msg ||= 'We need to sign you in before you can do that.'
|
||||||
redirect_to new_user_session_path, :flash => {:error => msg}
|
redirect_to new_user_session_path, flash: { error: msg }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_user!(options={})
|
def authenticate_user!(_options = {})
|
||||||
block_with_sign_in unless current_user
|
block_with_sign_in unless current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_confirmed_user!
|
def authenticate_confirmed_user!
|
||||||
if !current_user
|
if !current_user
|
||||||
block_with_sign_in
|
block_with_sign_in
|
||||||
elsif !current_user.confirmed? && !current_role?([:super_associate, :super_admin])
|
elsif !current_user.confirmed? && !current_role?(%i[super_associate super_admin])
|
||||||
redirect_to new_user_confirmation_path, flash: {error: 'You need to confirm your account to do that.'}
|
redirect_to new_user_confirmation_path, flash: { error: 'You need to confirm your account to do that.' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_super_associate!
|
def authenticate_super_associate!
|
||||||
unless current_role?(:super_admin) || current_role?(:super_associate)
|
unless current_role?(:super_admin) || current_role?(:super_associate)
|
||||||
block_with_sign_in 'Please login.'
|
block_with_sign_in 'Please login.'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_super_admin!
|
def authenticate_super_admin!
|
||||||
unless current_role?(:super_admin)
|
block_with_sign_in 'Please login.' unless current_role?(:super_admin)
|
||||||
block_with_sign_in 'Please login.'
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def current_role?(role_names, host_id = nil)
|
def current_role?(role_names, host_id = nil)
|
||||||
return false unless current_user
|
return false unless current_user
|
||||||
role_names = Array(role_names)
|
|
||||||
key = "current_role_user_#{current_user_id}_names_#{role_names.join("_")}_host_#{host_id}"
|
|
||||||
QueryRoles.user_has_role?(current_user.id, role_names, host_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
def nonprofit_in_trial?(npo_id=nil)
|
role_names = Array(role_names)
|
||||||
|
key = "current_role_user_#{current_user_id}_names_#{role_names.join('_')}_host_#{host_id}"
|
||||||
|
QueryRoles.user_has_role?(current_user.id, role_names, host_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def nonprofit_in_trial?(npo_id = nil)
|
||||||
return false if !npo_id && !administered_nonprofit
|
return false if !npo_id && !administered_nonprofit
|
||||||
|
|
||||||
npo_id ||= administered_nonprofit.id
|
npo_id ||= administered_nonprofit.id
|
||||||
key = "in_trial_user_#{current_user_id}_nonprofit_#{npo_id}"
|
key = "in_trial_user_#{current_user_id}_nonprofit_#{npo_id}"
|
||||||
QueryBillingSubscriptions.currently_in_trial?(npo_id)
|
QueryBillingSubscriptions.currently_in_trial?(npo_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_plan_tier(npo_id=nil)
|
def current_plan_tier(npo_id = nil)
|
||||||
return 0 if !npo_id && !administered_nonprofit
|
return 0 if !npo_id && !administered_nonprofit
|
||||||
|
|
||||||
npo_id ||= administered_nonprofit.id
|
npo_id ||= administered_nonprofit.id
|
||||||
return 2 if current_role?(:super_admin)
|
return 2 if current_role?(:super_admin)
|
||||||
key = "plan_tier_user_#{current_user_id}_nonprofit_#{npo_id}"
|
|
||||||
|
key = "plan_tier_user_#{current_user_id}_nonprofit_#{npo_id}"
|
||||||
administered_nonprofit ? QueryBillingSubscriptions.plan_tier(npo_id) : 0
|
administered_nonprofit ? QueryBillingSubscriptions.plan_tier(npo_id) : 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def administered_nonprofit
|
def administered_nonprofit
|
||||||
return nil unless current_user
|
return nil unless current_user
|
||||||
key = "administered_nonprofit_user_#{current_user_id}_nonprofit"
|
|
||||||
Nonprofit.where(id: QueryRoles.host_ids(current_user_id, [:nonprofit_admin, :nonprofit_associate])).last
|
|
||||||
end
|
|
||||||
|
|
||||||
# devise config
|
key = "administered_nonprofit_user_#{current_user_id}_nonprofit"
|
||||||
|
Nonprofit.where(id: QueryRoles.host_ids(current_user_id, %i[nonprofit_admin nonprofit_associate])).last
|
||||||
|
end
|
||||||
|
|
||||||
def after_sign_in_path_for(resource)
|
# devise config
|
||||||
request.env['omniauth.origin'] || session[:previous_url] || root_path
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_sign_up_path_for(resource)
|
def after_sign_in_path_for(_resource)
|
||||||
request.env['omniauth.origin'] || session[:previous_url] || root_path
|
request.env['omniauth.origin'] || session[:previous_url] || root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_update_path_for(resource)
|
def after_sign_up_path_for(_resource)
|
||||||
profile_path(current_user.profile)
|
request.env['omniauth.origin'] || session[:previous_url] || root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_inactive_sign_up_path_for(resource)
|
def after_update_path_for(_resource)
|
||||||
profile_path(current_user.profile)
|
profile_path(current_user.profile)
|
||||||
end
|
end
|
||||||
|
|
||||||
# /devise config
|
def after_inactive_sign_up_path_for(_resource)
|
||||||
|
profile_path(current_user.profile)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
# /devise config
|
||||||
|
|
||||||
def current_user_id
|
private
|
||||||
current_user && current_user.id
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def current_user_id
|
||||||
|
current_user&.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class AwsPresignedPostsController < ApplicationController
|
class AwsPresignedPostsController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
|
||||||
# post /presigned_posts
|
# post /presigned_posts
|
||||||
# Create some keys using the AWS gem so the user can do direct-to-S3 uploads
|
# Create some keys using the AWS gem so the user can do direct-to-S3 uploads
|
||||||
# http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/PresignedPost.html
|
# http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/PresignedPost.html
|
||||||
def create
|
def create
|
||||||
uuid = SecureRandom.uuid
|
uuid = SecureRandom.uuid
|
||||||
p = S3Bucket.presigned_post({
|
p = S3Bucket.presigned_post(
|
||||||
key: "tmp/#{uuid}/${filename}",
|
key: "tmp/#{uuid}/${filename}",
|
||||||
success_action_status: 201,
|
success_action_status: 201,
|
||||||
acl: 'public-read',
|
acl: 'public-read',
|
||||||
expiration: 30.days.from_now
|
expiration: 30.days.from_now
|
||||||
})
|
)
|
||||||
|
|
||||||
render json: {
|
render json: {
|
||||||
s3_presigned_post: p.fields.to_json,
|
s3_presigned_post: p.fields.to_json,
|
||||||
|
@ -20,5 +22,4 @@ class AwsPresignedPostsController < ApplicationController
|
||||||
s3_uuid: uuid
|
s3_uuid: uuid
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,30 +1,32 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class BillingSubscriptionsController < ApplicationController
|
class BillingSubscriptionsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_admin!
|
before_action :authenticate_nonprofit_admin!
|
||||||
|
|
||||||
def create_trial
|
def create_trial
|
||||||
render JsonResp.new(params){|params|
|
render JsonResp.new(params) do |_params|
|
||||||
requires(:nonprofit_id).as_int
|
requires(:nonprofit_id).as_int
|
||||||
requires(:stripe_plan_id).as_string
|
requires(:stripe_plan_id).as_string
|
||||||
}.when_valid{|params|
|
end.when_valid do |params|
|
||||||
InsertBillingSubscriptions.trial(params[:nonprofit_id], params[:stripe_plan_id])
|
InsertBillingSubscriptions.trial(params[:nonprofit_id], params[:stripe_plan_id])
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@nonprofit ||= Nonprofit.find(params[:nonprofit_id])
|
@nonprofit ||= Nonprofit.find(params[:nonprofit_id])
|
||||||
@subscription = BillingSubscription.create_with_stripe(@nonprofit, params[:billing_subscription])
|
@subscription = BillingSubscription.create_with_stripe(@nonprofit, params[:billing_subscription])
|
||||||
json_saved(@subscription, "Success! You are subscribed to #{Settings.general.name}.")
|
json_saved(@subscription, "Success! You are subscribed to #{Settings.general.name}.")
|
||||||
end
|
end
|
||||||
|
|
||||||
# post /nonprofits/:nonprofit_id/billing_subscription/cancel
|
# post /nonprofits/:nonprofit_id/billing_subscription/cancel
|
||||||
def cancel
|
def cancel
|
||||||
@result = CancelBillingSubscription.with_stripe(@nonprofit)
|
@result = CancelBillingSubscription.with_stripe(@nonprofit)
|
||||||
flash[:notice] = "Your subscription has been cancelled. We'll email you soon with exports."
|
flash[:notice] = "Your subscription has been cancelled. We'll email you soon with exports."
|
||||||
redirect_to root_url
|
redirect_to root_url
|
||||||
end
|
end
|
||||||
|
|
||||||
# get nonprofits/:nonprofit_id/billing_subscription/cancellation
|
# get nonprofits/:nonprofit_id/billing_subscription/cancellation
|
||||||
def cancellation
|
def cancellation
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class ButtonDebugController < ApplicationController
|
class ButtonDebugController < ApplicationController
|
||||||
def embedded
|
def embedded
|
||||||
@np = params[:id] || 1
|
@np = params[:id] || 1
|
||||||
respond_to { |format| format.html{render layout: 'layouts/empty'} }
|
respond_to { |format| format.html { render layout: 'layouts/empty' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
def button
|
def button
|
||||||
@np = params[:id] || 1
|
@np = params[:id] || 1
|
||||||
respond_to { |format| format.html{render layout: 'layouts/empty'} }
|
respond_to { |format| format.html { render layout: 'layouts/empty' } }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,29 +1,31 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class CampaignGiftOptionsController < ApplicationController
|
class CampaignGiftOptionsController < ApplicationController
|
||||||
include Controllers::CampaignHelper
|
include Controllers::CampaignHelper
|
||||||
|
|
||||||
before_filter :authenticate_campaign_editor!, only: [:create, :destroy, :update, :update_order]
|
before_action :authenticate_campaign_editor!, only: %i[create destroy update update_order]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@gift_options = current_campaign.campaign_gift_options.order('"order", amount_recurring, amount_one_time')
|
@gift_options = current_campaign.campaign_gift_options.order('"order", amount_recurring, amount_one_time')
|
||||||
render json: {data: @gift_options}
|
render json: { data: @gift_options }
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
render json: {data: current_campaign.campaign_gift_options.find(params[:id])}
|
render json: { data: current_campaign.campaign_gift_options.find(params[:id]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
campaign = current_campaign
|
campaign = current_campaign
|
||||||
json_saved CreateCampaignGiftOption.create(campaign, params[:campaign_gift_option]),
|
json_saved CreateCampaignGiftOption.create(campaign, params[:campaign_gift_option]),
|
||||||
'Gift option successfully created!'
|
'Gift option successfully created!'
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@campaign = current_campaign
|
@campaign = current_campaign
|
||||||
gift_option = @campaign.campaign_gift_options.find params[:id]
|
gift_option = @campaign.campaign_gift_options.find params[:id]
|
||||||
json_saved UpdateCampaignGiftOption.update(gift_option, params[:campaign_gift_option]), 'Successfully updated'
|
json_saved UpdateCampaignGiftOption.update(gift_option, params[:campaign_gift_option]), 'Successfully updated'
|
||||||
end
|
end
|
||||||
|
|
||||||
# put /nonprofits/:nonprofit_id/campaigns/:campaign_id/campaign_gift_options/update_order
|
# put /nonprofits/:nonprofit_id/campaigns/:campaign_id/campaign_gift_options/update_order
|
||||||
# Pass in {data: [{id: 1, order: 1}]}
|
# Pass in {data: [{id: 1, order: 1}]}
|
||||||
|
@ -32,9 +34,9 @@ class CampaignGiftOptionsController < ApplicationController
|
||||||
render json: updated_gift_options
|
render json: updated_gift_options
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@campaign = current_campaign
|
@campaign = current_campaign
|
||||||
|
|
||||||
render_json { DeleteCampaignGiftOption.delete(@campaign, params[:id])}
|
render_json { DeleteCampaignGiftOption.delete(@campaign, params[:id]) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class CampaignGiftsController < ApplicationController
|
class CampaignGiftsController < ApplicationController
|
||||||
|
|
||||||
# post /campaign_gifts
|
# post /campaign_gifts
|
||||||
def create
|
def create
|
||||||
json_saved CreateCampaignGift.create params[:campaign_gift]
|
json_saved CreateCampaignGift.create params[:campaign_gift]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +1,51 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Campaigns; class CampaignGiftOptionsController < ApplicationController
|
module Campaigns
|
||||||
include Controllers::CampaignHelper
|
class CampaignGiftOptionsController < ApplicationController
|
||||||
|
include Controllers::CampaignHelper
|
||||||
|
|
||||||
before_filter :authenticate_campaign_editor!, only: [:index]
|
before_action :authenticate_campaign_editor!, only: %i[create destroy update update_order report]
|
||||||
|
|
||||||
def index
|
def report
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
render json: QueryCampaignGifts.report_metrics(current_campaign.id)
|
render json: QueryCampaignGifts.report_metrics(current_campaign.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def index
|
||||||
|
@gift_options = current_campaign.campaign_gift_options.order('"order", amount_recurring, amount_one_time')
|
||||||
|
render json: { data: @gift_options }
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
render json: { data: current_campaign.campaign_gift_options.find(params[:id]) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
campaign = current_campaign
|
||||||
|
json_saved CreateCampaignGiftOption.create(campaign, params[:campaign_gift_option]),
|
||||||
|
'Gift option successfully created!'
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@campaign = current_campaign
|
||||||
|
gift_option = @campaign.campaign_gift_options.find params[:id]
|
||||||
|
json_saved UpdateCampaignGiftOption.update(gift_option, params[:campaign_gift_option]), 'Successfully updated'
|
||||||
|
end
|
||||||
|
|
||||||
|
# put /nonprofits/:nonprofit_id/campaigns/:campaign_id/campaign_gift_options/update_order
|
||||||
|
# Pass in {data: [{id: 1, order: 1}]}
|
||||||
|
def update_order
|
||||||
|
updated_gift_options = UpdateOrder.with_data('campaign_gift_options', params[:data])
|
||||||
|
render json: updated_gift_options
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@campaign = current_campaign
|
||||||
|
|
||||||
|
render_json { DeleteCampaignGiftOption.delete(@campaign, params[:id]) }
|
||||||
|
end
|
||||||
end; end
|
end; end
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Campaigns
|
module Campaigns
|
||||||
class DonationsController < ApplicationController
|
class DonationsController < ApplicationController
|
||||||
include Controllers::CampaignHelper
|
include Controllers::CampaignHelper
|
||||||
|
|
||||||
before_filter :authenticate_campaign_editor!, only: [:index]
|
before_action :authenticate_campaign_editor!, only: [:index]
|
||||||
|
|
||||||
def index
|
|
||||||
respond_to do |format|
|
|
||||||
format.csv do
|
|
||||||
file_date = Date.today.strftime("%m-%d-%Y")
|
|
||||||
donations = QueryDonations.campaign_export(current_campaign.id)
|
|
||||||
send_data(Format::Csv.from_vectors(donations), filename: "campaign-donations-#{file_date}.csv")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
def index
|
||||||
|
respond_to do |format|
|
||||||
|
format.csv do
|
||||||
|
file_date = Date.today.strftime('%m-%d-%Y')
|
||||||
|
donations = QueryDonations.campaign_export(current_campaign.id)
|
||||||
|
send_data(Format::Csv.from_vectors(donations), filename: "campaign-donations-#{file_date}.csv")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,22 +1,23 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Campaigns
|
module Campaigns
|
||||||
class SupportersController < ApplicationController
|
class SupportersController < ApplicationController
|
||||||
include Controllers::CampaignHelper
|
include Controllers::CampaignHelper
|
||||||
|
|
||||||
before_filter :authenticate_campaign_editor!, only: [:index]
|
before_action :authenticate_campaign_editor!, only: [:index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@panels_layout = true
|
@panels_layout = true
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
@campaign = current_campaign
|
@campaign = current_campaign
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.json do
|
|
||||||
render json: QuerySupporters.campaign_list(@nonprofit.id, @campaign.id, params)
|
|
||||||
end
|
|
||||||
format.html
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
respond_to do |format|
|
||||||
|
format.json do
|
||||||
|
render json: QuerySupporters.campaign_list(@nonprofit.id, @campaign.id, params)
|
||||||
|
end
|
||||||
|
format.html
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class CampaignsController < ApplicationController
|
class CampaignsController < ApplicationController
|
||||||
include Controllers::CampaignHelper
|
include Controllers::CampaignHelper
|
||||||
|
|
||||||
helper_method :current_campaign_editor?
|
helper_method :current_campaign_editor?
|
||||||
before_filter :authenticate_confirmed_user!, only: [:create, :name_and_id, :duplicate]
|
before_action :authenticate_confirmed_user!, only: %i[create name_and_id duplicate]
|
||||||
before_filter :authenticate_campaign_editor!, only: [:update, :soft_delete]
|
before_action :authenticate_campaign_editor!, only: %i[update soft_delete]
|
||||||
before_filter :check_nonprofit_status, only: [:index, :show]
|
before_action :check_nonprofit_status, only: %i[index show]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
if (current_nonprofit_user?)
|
if current_nonprofit_user?
|
||||||
@campaigns = @nonprofit.campaigns.includes(:nonprofit).not_deleted.order('created_at desc')
|
@campaigns = @nonprofit.campaigns.includes(:nonprofit).not_deleted.order('created_at desc')
|
||||||
@deleted_campaigns = @nonprofit.campaigns.includes(:nonprofit).deleted.order('created_at desc')
|
@deleted_campaigns = @nonprofit.campaigns.includes(:nonprofit).deleted.order('created_at desc')
|
||||||
else
|
else
|
||||||
|
@ -57,18 +59,7 @@ class CampaignsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
Time.use_zone(current_nonprofit.timezone || 'UTC') do
|
render json: CreateCampaign.create(params, current_nonprofit)
|
||||||
params[:campaign][:end_datetime] = Chronic.parse(params[:campaign][:end_datetime]) if params[:campaign][:end_datetime].present?
|
|
||||||
end
|
|
||||||
|
|
||||||
if !params[:campaign][:parent_campaign_id]
|
|
||||||
campaign = current_nonprofit.campaigns.create params[:campaign]
|
|
||||||
json_saved campaign, 'Campaign created! Well done.'
|
|
||||||
else
|
|
||||||
profile_id = params[:campaign][:profile_id]
|
|
||||||
Profile.find(profile_id).update_attributes params[:profile]
|
|
||||||
render json: CreatePeerToPeerCampaign.create(params[:campaign], profile_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@ -81,14 +72,11 @@ class CampaignsController < ApplicationController
|
||||||
|
|
||||||
# post 'nonprofits/:np_id/campaigns/:campaign_id/duplicate'
|
# post 'nonprofits/:np_id/campaigns/:campaign_id/duplicate'
|
||||||
def duplicate
|
def duplicate
|
||||||
|
render_json do
|
||||||
render_json {
|
|
||||||
InsertDuplicate.campaign(current_campaign.id, current_user.profile.id)
|
InsertDuplicate.campaign(current_campaign.id, current_user.profile.id)
|
||||||
}
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def soft_delete
|
def soft_delete
|
||||||
current_campaign.update_attribute(:deleted, params[:delete])
|
current_campaign.update_attribute(:deleted, params[:delete])
|
||||||
render json: {}
|
render json: {}
|
||||||
|
@ -112,17 +100,17 @@ class CampaignsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def peer_to_peer
|
def peer_to_peer
|
||||||
session[:donor_signup_url] = request.env["REQUEST_URI"]
|
session[:donor_signup_url] = request.env['REQUEST_URI']
|
||||||
@nonprofit = Nonprofit.find_by_id(params[:npo_id])
|
@nonprofit = Nonprofit.find_by_id(params[:npo_id])
|
||||||
@parent_campaign = Campaign.find_by_id(params[:campaign_id])
|
@parent_campaign = Campaign.find_by_id(params[:campaign_id])
|
||||||
|
|
||||||
if params[:campaign_id].present? && !@parent_campaign
|
if params[:campaign_id].present? && !@parent_campaign
|
||||||
raise ActionController::RoutingError.new('Not Found')
|
raise ActionController::RoutingError, 'Not Found'
|
||||||
end
|
end
|
||||||
|
|
||||||
if current_user
|
if current_user
|
||||||
@profile = current_user.profile
|
@profile = current_user.profile
|
||||||
if (@parent_campaign)
|
if @parent_campaign
|
||||||
@child_campaign = Campaign.where(
|
@child_campaign = Campaign.where(
|
||||||
profile_id: @profile.id,
|
profile_id: @profile.id,
|
||||||
parent_campaign_id: @parent_campaign.id
|
parent_campaign_id: @parent_campaign.id
|
||||||
|
@ -135,7 +123,7 @@ class CampaignsController < ApplicationController
|
||||||
|
|
||||||
def check_nonprofit_status
|
def check_nonprofit_status
|
||||||
if !current_role?(:super_admin) && !current_nonprofit.published
|
if !current_role?(:super_admin) && !current_nonprofit.published
|
||||||
raise ActionController::RoutingError.new('Not Found')
|
raise ActionController::RoutingError, 'Not Found'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class CardsController < ApplicationController
|
class CardsController < ApplicationController
|
||||||
|
before_action :authenticate_user!, except: [:create]
|
||||||
|
|
||||||
before_filter :authenticate_user!, :except => [:create]
|
# post /cards
|
||||||
|
def create
|
||||||
# post /cards
|
|
||||||
def create
|
|
||||||
acct = Supporter.find(params[:card][:holder_id]).nonprofit.stripe_account_id
|
acct = Supporter.find(params[:card][:holder_id]).nonprofit.stripe_account_id
|
||||||
render(
|
render(
|
||||||
JsonResp.new(params) do |d|
|
JsonResp.new(params) do |_d|
|
||||||
requires(:card).nested do
|
requires(:card).nested do
|
||||||
requires(:name, :stripe_card_token).as_string
|
requires(:name, :stripe_card_token).as_string
|
||||||
requires(:holder_id).as_int
|
requires(:holder_id).as_int
|
||||||
requires(:holder_type).one_of('Supporter')
|
requires(:holder_type).one_of('Supporter')
|
||||||
end
|
end
|
||||||
end.when_valid do |d|
|
end.when_valid do |d|
|
||||||
InsertCard.with_stripe(d[:card], acct, params[:event_id], current_user)
|
InsertCard.with_stripe(d[:card], acct, params[:event_id], current_user)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class DirectDebitDetailsController < ApplicationController
|
class DirectDebitDetailsController < ApplicationController
|
||||||
|
|
||||||
|
|
||||||
# POST /sepa
|
# POST /sepa
|
||||||
# This endpoint is used for saving direct debit account details
|
# This endpoint is used for saving direct debit account details
|
||||||
# when SEPA payment is selected in the donation widget. Actual charge is
|
# when SEPA payment is selected in the donation widget. Actual charge is
|
||||||
# happening offline, after donations are exported to an external CRM.
|
# happening offline, after donations are exported to an external CRM.
|
||||||
def create
|
def create
|
||||||
render(
|
render(
|
||||||
JsonResp.new(params) do |data|
|
JsonResp.new(params) do |_data|
|
||||||
requires(:supporter_id).as_int
|
requires(:supporter_id).as_int
|
||||||
requires(:sepa_params).nested do
|
requires(:sepa_params).nested do
|
||||||
requires(:iban, :name, :bic).as_string
|
requires(:iban, :name, :bic).as_string
|
||||||
end
|
end
|
||||||
end.when_valid do |data|
|
end.when_valid do |_data|
|
||||||
InsertDirectDebitDetail.execute(params)
|
InsertDirectDebitDetail.execute(params)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class EmailSettingsController < ApplicationController
|
class EmailSettingsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
user = current_role?(:super_admin) ? User.find(params[:user_id]) : current_user
|
user = current_role?(:super_admin) ? User.find(params[:user_id]) : current_user
|
||||||
|
@ -15,6 +17,4 @@ class EmailSettingsController < ApplicationController
|
||||||
user = current_role?(:super_admin) ? User.find(params[:user_id]) : current_user
|
user = current_role?(:super_admin) ? User.find(params[:user_id]) : current_user
|
||||||
render json: UpdateEmailSettings.save(params[:nonprofit_id], user.id, params[:email_settings])
|
render json: UpdateEmailSettings.save(params[:nonprofit_id], user.id, params[:email_settings])
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class EmailsController < ApplicationController
|
class EmailsController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
|
||||||
def create
|
|
||||||
email = params[:email]
|
|
||||||
GenericMailer.delay.generic_mail(email[:from_email], email[:from_name], email[:message], email[:subject], email[:to_email], email[:to_name])
|
|
||||||
render :json => {:notification => 'Email successfully sent'}, :status => :created
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def create
|
||||||
|
email = params[:email]
|
||||||
|
GenericMailer.delay.generic_mail(email[:from_email], email[:from_name], email[:message], email[:subject], email[:to_email], email[:to_name])
|
||||||
|
render json: { notification: 'Email successfully sent' }, status: :created
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class EventDiscountsController < ApplicationController
|
class EventDiscountsController < ApplicationController
|
||||||
include Controllers::EventHelper
|
include Controllers::EventHelper
|
||||||
before_filter :authenticate_event_editor!, :except => [:index]
|
before_action :authenticate_event_editor!, except: [:index]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
params[:event_discount][:event_id] = current_event.id
|
params[:event_discount][:event_id] = current_event.id
|
||||||
|
|
||||||
render JsonResp.new(params[:event_discount]){|data|
|
render JsonResp.new(params[:event_discount]) do |_data|
|
||||||
requires(:code, :name).as_string
|
requires(:code, :name).as_string
|
||||||
requires(:event_id, :percent).as_int
|
requires(:event_id, :percent).as_int
|
||||||
}.when_valid{|data|
|
end.when_valid do |data|
|
||||||
{ status: 200, json: { event_discount: current_event.event_discounts.create(data) } }
|
{ status: 200, json: { event_discount: current_event.event_discounts.create(data) } }
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -26,15 +28,14 @@ class EventDiscountsController < ApplicationController
|
||||||
.returning('*')
|
.returning('*')
|
||||||
).first
|
).first
|
||||||
)
|
)
|
||||||
render json: {status: 200, data: discount }
|
render json: { status: 200, data: discount }
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
Psql.execute(
|
Psql.execute(
|
||||||
Qexpr.new.delete_from("event_discounts")
|
Qexpr.new.delete_from('event_discounts')
|
||||||
.where("event_discounts.event_id=$id", id: params["event_id"])
|
.where('event_discounts.event_id=$id', id: params['event_id'])
|
||||||
.where("event_discounts.id=$id", id: params["id"])
|
.where('event_discounts.id=$id', id: params['id'])
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class EventsController < ApplicationController
|
class EventsController < ApplicationController
|
||||||
include Controllers::EventHelper
|
include Controllers::EventHelper
|
||||||
|
|
||||||
helper_method :current_event_editor?
|
helper_method :current_event_editor?
|
||||||
before_filter :authenticate_nonprofit_user!, only: :name_and_id
|
before_action :authenticate_nonprofit_user!, only: :name_and_id
|
||||||
before_filter :authenticate_event_editor!, only: [:update, :soft_delete, :stats, :create, :duplicate]
|
before_action :authenticate_event_editor!, only: %i[update soft_delete stats create duplicate]
|
||||||
|
|
||||||
|
def index
|
||||||
def index
|
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
end
|
end
|
||||||
|
|
||||||
def listings
|
def listings
|
||||||
render json: QueryEventMetrics.for_listings('nonprofit', current_nonprofit.id, params)
|
render json: QueryEventMetrics.for_listings('nonprofit', current_nonprofit.id, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@event = params[:event_slug] ? Event.find_by_slug!(params[:event_slug]) : Event.find_by_id!(params[:id])
|
@event = params[:event_slug] ? Event.find_by_slug!(params[:event_slug]) : Event.find_by_id!(params[:id])
|
||||||
@event_background_image = FetchBackgroundImage.with_model(@event)
|
@event_background_image = FetchBackgroundImage.with_model(@event)
|
||||||
@nonprofit = @event.nonprofit
|
@nonprofit = @event.nonprofit
|
||||||
|
@ -24,10 +25,10 @@ class EventsController < ApplicationController
|
||||||
flash[:notice] = "Sorry, we couldn't find that event"
|
flash[:notice] = "Sorry, we couldn't find that event"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@organizer = QueryEventOrganizer.with_event(@event.id)
|
@organizer = QueryEventOrganizer.with_event(@event.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
render_json do
|
render_json do
|
||||||
Time.use_zone(current_nonprofit.timezone || 'UTC') do
|
Time.use_zone(current_nonprofit.timezone || 'UTC') do
|
||||||
params[:event][:start_datetime] = Chronic.parse(params[:event][:start_datetime]) if params[:event][:start_datetime].present?
|
params[:event][:start_datetime] = Chronic.parse(params[:event][:start_datetime]) if params[:event][:start_datetime].present?
|
||||||
|
@ -35,22 +36,22 @@ class EventsController < ApplicationController
|
||||||
end
|
end
|
||||||
flash[:notice] = 'Your draft event has been created! Well done.'
|
flash[:notice] = 'Your draft event has been created! Well done.'
|
||||||
ev = current_nonprofit.events.create(params[:event])
|
ev = current_nonprofit.events.create(params[:event])
|
||||||
{url: "/events/#{ev.slug}", event: ev}
|
{ url: "/events/#{ev.slug}", event: ev }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
Time.use_zone(current_nonprofit.timezone || 'UTC') do
|
Time.use_zone(current_nonprofit.timezone || 'UTC') do
|
||||||
params[:event][:start_datetime] = Chronic.parse(params[:event][:start_datetime]) if params[:event][:start_datetime].present?
|
params[:event][:start_datetime] = Chronic.parse(params[:event][:start_datetime]) if params[:event][:start_datetime].present?
|
||||||
params[:event][:end_datetime] = Chronic.parse(params[:event][:end_datetime]) if params[:event][:end_datetime].present?
|
params[:event][:end_datetime] = Chronic.parse(params[:event][:end_datetime]) if params[:event][:end_datetime].present?
|
||||||
end
|
end
|
||||||
current_event.update_attributes(params[:event])
|
current_event.update_attributes(params[:event])
|
||||||
json_saved current_event, 'Successfully updated'
|
json_saved current_event, 'Successfully updated'
|
||||||
end
|
end
|
||||||
|
|
||||||
# post 'nonprofits/:np_id/events/:event_id/duplicate'
|
# post 'nonprofits/:np_id/events/:event_id/duplicate'
|
||||||
def duplicate
|
def duplicate
|
||||||
render_json { InsertDuplicate.event(current_event.id, current_user.profile.id)}
|
render_json { InsertDuplicate.event(current_event.id, current_user.profile.id) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def activities
|
def activities
|
||||||
|
@ -58,24 +59,22 @@ class EventsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def soft_delete
|
def soft_delete
|
||||||
current_event.update_attribute(:deleted, params[:delete])
|
current_event.update_attribute(:deleted, params[:delete])
|
||||||
render json: {}
|
render json: {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def metrics
|
def metrics
|
||||||
render json: QueryEventMetrics.with_event_ids([current_event.id]).first
|
render json: QueryEventMetrics.with_event_ids([current_event.id]).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def stats
|
def stats
|
||||||
@event = current_event
|
@event = current_event
|
||||||
@url = Format::Url.concat(root_url, @event.url)
|
@url = Format::Url.concat(root_url, @event.url)
|
||||||
@event_background_image = FetchBackgroundImage.with_model(@event)
|
@event_background_image = FetchBackgroundImage.with_model(@event)
|
||||||
render layout: 'layouts/embed'
|
render layout: 'layouts/embed'
|
||||||
end
|
end
|
||||||
|
|
||||||
def name_and_id
|
def name_and_id
|
||||||
render json: QueryEvents.name_and_id(current_nonprofit.id)
|
render json: QueryEvents.name_and_id(current_nonprofit.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class FrontController < ApplicationController
|
class FrontController < ApplicationController
|
||||||
def index
|
def index
|
||||||
if !Nonprofit.any?
|
if Nonprofit.none?
|
||||||
redirect_to onboard_path
|
redirect_to onboard_path
|
||||||
elsif current_role?([:nonprofit_admin,:nonprofit_associate])
|
elsif current_role?(%i[nonprofit_admin nonprofit_associate])
|
||||||
redirect_to NonprofitPath.dashboard(administered_nonprofit)
|
redirect_to NonprofitPath.dashboard(administered_nonprofit)
|
||||||
elsif current_user
|
elsif current_user
|
||||||
redirect_to '/profiles/' + current_user.profile.id.to_s
|
redirect_to '/profiles/' + current_user.profile.id.to_s
|
||||||
else
|
else
|
||||||
redirect_to new_user_session_path
|
redirect_to new_user_session_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,24 +1,26 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class ImageAttachmentsController < ApplicationController
|
class ImageAttachmentsController < ApplicationController
|
||||||
before_filter :authenticate_confirmed_user!
|
before_action :authenticate_confirmed_user!
|
||||||
def create
|
def create
|
||||||
# must return json with a link attr
|
# must return json with a link attr
|
||||||
# http://editor.froala.com/server-integrations/php-image-upload
|
# http://editor.froala.com/server-integrations/php-image-upload
|
||||||
@image = ImageAttachment.new(:file => params[:file])
|
@image = ImageAttachment.new(file: params[:file])
|
||||||
if @image.save
|
if @image.save
|
||||||
render :json => {:link => @image.file_url}
|
render json: { link: @image.file_url }
|
||||||
else
|
else
|
||||||
render :json => @image.errors.full_messages, :status => :unprocessable_entity
|
render json: @image.errors.full_messages, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove
|
def remove
|
||||||
@image = ImageAttachment.select{|img| img.file_url == params[:src]}.first
|
@image = ImageAttachment.select { |img| img.file_url == params[:src] }.first
|
||||||
if @image
|
if @image
|
||||||
@image.destroy
|
@image.destroy
|
||||||
render :json => @image
|
render json: @image
|
||||||
else
|
else
|
||||||
render :json => {}, :status => :unprocessable_entity
|
render json: {}, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class MapsController < ApplicationController
|
class MapsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_super_associate!, only: :all_supporters
|
before_action :authenticate_super_associate!, only: :all_supporters
|
||||||
before_filter :authenticate_nonprofit_user!, only: [:all_npo_supporters, :specific_npo_supporters]
|
before_action :authenticate_nonprofit_user!, only: %i[all_npo_supporters specific_npo_supporters]
|
||||||
|
|
||||||
# used on admin/nonprofits_map and front page
|
# used on admin/nonprofits_map and front page
|
||||||
def all_npos
|
def all_npos
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to :root }
|
format.html { redirect_to :root }
|
||||||
format.json { @map_data = Nonprofit.where("latitude IS NOT NULL").last(1000) }
|
format.json { @map_data = Nonprofit.where('latitude IS NOT NULL').last(1000) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# used on admin/supporters_map
|
# used on admin/supporters_map
|
||||||
def all_supporters
|
def all_supporters
|
||||||
@map_data = Supporter.where("latitude IS NOT NULL").last(1000)
|
@map_data = Supporter.where('latitude IS NOT NULL').last(1000)
|
||||||
end
|
end
|
||||||
|
|
||||||
# used on npo dashboard
|
|
||||||
def all_npo_supporters
|
|
||||||
@map_data = Nonprofit.find(params['npo_id']).supporters.where("latitude IS NOT NULL").last(100)
|
|
||||||
end
|
|
||||||
|
|
||||||
# used on supporter dashboard
|
|
||||||
def specific_npo_supporters
|
|
||||||
supporter_ids = params['supporter_ids'].split(",").map { |s| s.to_i }
|
|
||||||
supporters = Nonprofit.find(params['npo_id']).supporters.find(supporter_ids).last(500)
|
|
||||||
@map_data = supporters.map{|s| s if s.latitude != ''}
|
|
||||||
end
|
|
||||||
|
|
||||||
|
# used on npo dashboard
|
||||||
|
def all_npo_supporters
|
||||||
|
@map_data = Nonprofit.find(params['npo_id']).supporters.where('latitude IS NOT NULL').last(100)
|
||||||
|
end
|
||||||
|
|
||||||
|
# used on supporter dashboard
|
||||||
|
def specific_npo_supporters
|
||||||
|
supporter_ids = params['supporter_ids'].split(',').map(&:to_i)
|
||||||
|
supporters = Nonprofit.find(params['npo_id']).supporters.find(supporter_ids).last(500)
|
||||||
|
@map_data = supporters.map { |s| s if s.latitude != '' }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class ActivitiesController < ApplicationController
|
class ActivitiesController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
# get /nonprofits/:nonprofit_id/supporters/:supporter_id/activities
|
# get /nonprofits/:nonprofit_id/supporters/:supporter_id/activities
|
||||||
def index
|
def index
|
||||||
render json: QueryActivities.for_timeline(params[:nonprofit_id], params[:supporter_id])
|
render json: QueryActivities.for_timeline(params[:nonprofit_id], params[:supporter_id])
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,64 +1,65 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class BankAccountsController < ApplicationController
|
class BankAccountsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_admin!
|
before_action :authenticate_nonprofit_admin!
|
||||||
|
|
||||||
# post /nonprofits/:nonprofit_id/bank_account
|
# post /nonprofits/:nonprofit_id/bank_account
|
||||||
# must pass in the user's password as params[:password]
|
# must pass in the user's password as params[:password]
|
||||||
def create
|
def create
|
||||||
if password_was_confirmed(params[:pw_token])
|
if password_was_confirmed(params[:pw_token])
|
||||||
render_json { InsertBankAccount.with_stripe(current_nonprofit, current_user, params[:bank_account]) }
|
render_json { InsertBankAccount.with_stripe(current_nonprofit, current_user, params[:bank_account]) }
|
||||||
else
|
else
|
||||||
render json: ["Please confirm your password"], status: :unprocessable_entity
|
render json: ['Please confirm your password'], status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# get /nonprofits/:nonprofit_id/bank_account/confirmation
|
# get /nonprofits/:nonprofit_id/bank_account/confirmation
|
||||||
def confirmation
|
def confirmation
|
||||||
@nonprofit = Nonprofit.find(params[:nonprofit_id])
|
@nonprofit = Nonprofit.find(params[:nonprofit_id])
|
||||||
@bank_account = @nonprofit.bank_account
|
@bank_account = @nonprofit.bank_account
|
||||||
end
|
end
|
||||||
|
|
||||||
# post /nonprofits/:nonprofit_id/bank_account/confirmation
|
# post /nonprofits/:nonprofit_id/bank_account/confirmation
|
||||||
def confirm
|
def confirm
|
||||||
npo = current_nonprofit
|
npo = current_nonprofit
|
||||||
ba = npo.bank_account
|
ba = npo.bank_account
|
||||||
if params[:token] == ba.confirmation_token
|
if params[:token] == ba.confirmation_token
|
||||||
ba.update_attribute(:pending_verification, false)
|
ba.update_attribute(:pending_verification, false)
|
||||||
flash[:notice] = "Your bank account is now confirmed!"
|
flash[:notice] = 'Your bank account is now confirmed!'
|
||||||
redirect_to nonprofits_payouts_path(npo)
|
redirect_to nonprofits_payouts_path(npo)
|
||||||
else
|
else
|
||||||
redirect_to(nonprofits_donations_path(npo), {:flash => {:error => "We could not confirm this bank account. Please follow the exact link provided in the confirmation email."}})
|
redirect_to(nonprofits_donations_path(npo), flash: { error: 'We could not confirm this bank account. Please follow the exact link provided in the confirmation email.' })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# get /nonprofits/:nonprofit_id/bank_account/cancellation
|
# get /nonprofits/:nonprofit_id/bank_account/cancellation
|
||||||
def cancellation
|
def cancellation
|
||||||
@nonprofit = Nonprofit.find(params[:nonprofit_id])
|
@nonprofit = Nonprofit.find(params[:nonprofit_id])
|
||||||
@bank_account = @nonprofit.bank_account
|
@bank_account = @nonprofit.bank_account
|
||||||
end
|
end
|
||||||
|
|
||||||
# post /nonprofits/:nonprofit_id/bank_account/cancel
|
# post /nonprofits/:nonprofit_id/bank_account/cancel
|
||||||
def cancel
|
def cancel
|
||||||
npo = current_nonprofit
|
npo = current_nonprofit
|
||||||
ba = npo.bank_account
|
ba = npo.bank_account
|
||||||
if params[:token] == ba.confirmation_token
|
if params[:token] == ba.confirmation_token
|
||||||
ba.destroy
|
ba.destroy
|
||||||
flash[:notice] = "Your bank account has been removed."
|
flash[:notice] = 'Your bank account has been removed.'
|
||||||
redirect_to nonprofits_donations_path(npo)
|
redirect_to nonprofits_donations_path(npo)
|
||||||
else
|
else
|
||||||
redirect_to(nonprofits_donations_path(npo), {:flash => {:error => "We could not remove this bank account. Please follow the exact link provided in the email."}})
|
redirect_to(nonprofits_donations_path(npo), flash: { error: 'We could not remove this bank account. Please follow the exact link provided in the email.' })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def resend_confirmation
|
|
||||||
npo = current_nonprofit
|
|
||||||
ba = npo.bank_account
|
|
||||||
NonprofitMailer.delay.new_bank_account_notification(ba) if ba.valid?
|
|
||||||
respond_to{|format| format.json{render json: {}}}
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
def resend_confirmation
|
||||||
|
npo = current_nonprofit
|
||||||
|
ba = npo.bank_account
|
||||||
|
NonprofitMailer.delay.new_bank_account_notification(ba) if ba.valid?
|
||||||
|
respond_to { |format| format.json { render json: {} } }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,28 +1,27 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class ButtonController < ApplicationController
|
class ButtonController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
|
before_action :authenticate_user!
|
||||||
|
|
||||||
before_filter :authenticate_user!
|
def send_code
|
||||||
|
NonprofitMailer.button_code(current_nonprofit, params[:to_email], params[:to_name], params[:from_email], params[:message], params[:code]).deliver
|
||||||
|
render json: {}, status: 200
|
||||||
|
end
|
||||||
|
|
||||||
|
def basic
|
||||||
|
@nonprofit = current_nonprofit
|
||||||
|
end
|
||||||
|
|
||||||
def send_code
|
def guided
|
||||||
NonprofitMailer.button_code(current_nonprofit, params[:to_email], params[:to_name], params[:from_email], params[:message], params[:code]).deliver
|
@nonprofit = current_nonprofit
|
||||||
render json: {}, status: 200
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def basic
|
|
||||||
@nonprofit = current_nonprofit
|
|
||||||
end
|
|
||||||
|
|
||||||
def guided
|
|
||||||
@nonprofit = current_nonprofit
|
|
||||||
end
|
|
||||||
|
|
||||||
def advanced
|
|
||||||
@nonprofit = current_nonprofit
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
def advanced
|
||||||
|
@nonprofit = current_nonprofit
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class CardsController < ApplicationController
|
class CardsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
|
@ -12,7 +14,7 @@ module Nonprofits
|
||||||
# POST /nonprofits/:nonprofit_id/card
|
# POST /nonprofits/:nonprofit_id/card
|
||||||
def create
|
def create
|
||||||
render(
|
render(
|
||||||
JsonResp.new(params) do |d|
|
JsonResp.new(params) do |_d|
|
||||||
requires(:nonprofit_id).as_int
|
requires(:nonprofit_id).as_int
|
||||||
requires(:card).nested do
|
requires(:card).nested do
|
||||||
requires(:name, :stripe_card_token, :stripe_card_id).as_string
|
requires(:name, :stripe_card_token, :stripe_card_id).as_string
|
||||||
|
@ -25,6 +27,5 @@ module Nonprofits
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class ChargesController < ApplicationController
|
class ChargesController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_user!, only: :index
|
before_action :authenticate_nonprofit_user!, only: :index
|
||||||
|
|
||||||
# get /nonprofit/:nonprofit_id/charges
|
# get /nonprofit/:nonprofit_id/charges
|
||||||
def index
|
def index
|
||||||
redirect_to controller: :payments, action: :index
|
redirect_to controller: :payments, action: :index
|
||||||
end # def index
|
end # def index
|
||||||
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,41 +1,39 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class CustomFieldJoinsController < ApplicationController
|
class CustomFieldJoinsController < ApplicationController
|
||||||
|
include Controllers::NonprofitHelper
|
||||||
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
include Controllers::NonprofitHelper
|
def index
|
||||||
before_filter :authenticate_nonprofit_user!
|
@custom_field_joins = current_nonprofit
|
||||||
|
.supporters.find(params[:supporter_id])
|
||||||
|
.custom_field_joins
|
||||||
|
.order('created_at DESC')
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
# used for modify a single supporter's custom fields or a group of
|
||||||
@custom_field_joins = current_nonprofit
|
# selected supporters' CFs or all supporters' CFs
|
||||||
.supporters.find(params[:supporter_id])
|
def modify
|
||||||
.custom_field_joins
|
if params[:custom_fields].blank? || params[:custom_fields].empty?
|
||||||
.order('created_at DESC')
|
render json: {}
|
||||||
end
|
return
|
||||||
|
end
|
||||||
|
|
||||||
# used for modify a single supporter's custom fields or a group of
|
if params[:selecting_all]
|
||||||
# selected supporters' CFs or all supporters' CFs
|
supporter_ids = QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select('supporters.id').execute.map { |h| h['id'] }
|
||||||
def modify
|
else
|
||||||
if params[:custom_fields].blank? || params[:custom_fields].empty?
|
supporter_ids = params[:supporter_ids]. map(&:to_i)
|
||||||
render json: {}
|
end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if params[:selecting_all]
|
render InsertCustomFieldJoins.in_bulk(current_nonprofit.id, supporter_ids, params[:custom_fields])
|
||||||
supporter_ids = QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select("supporters.id").execute.map{|h| h['id']}
|
end
|
||||||
else
|
|
||||||
supporter_ids = params[:supporter_ids]. map(&:to_i)
|
|
||||||
end
|
|
||||||
|
|
||||||
render InsertCustomFieldJoins.in_bulk(current_nonprofit.id, supporter_ids, params[:custom_fields])
|
def destroy
|
||||||
end
|
supporter = current_nonprofit.supporters.find(params[:supporter_id])
|
||||||
|
supporter.custom_field_joins.find(params[:id]).destroy
|
||||||
|
render json: {}, status: :ok
|
||||||
def destroy
|
end
|
||||||
supporter = current_nonprofit.supporters.find(params[:supporter_id])
|
end
|
||||||
supporter.custom_field_joins.find(params[:id]).destroy
|
|
||||||
render json: {}, status: :ok
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class CustomFieldMastersController < ApplicationController
|
class CustomFieldMastersController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@custom_field_masters = current_nonprofit
|
@custom_field_masters = current_nonprofit
|
||||||
.custom_field_masters
|
.custom_field_masters
|
||||||
.order('id DESC')
|
.order('id DESC')
|
||||||
.not_deleted
|
.not_deleted
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
json_saved CreateCustomFieldMaster.create(current_nonprofit, params[:custom_field_master])
|
json_saved CreateCustomFieldMaster.create(current_nonprofit, params[:custom_field_master])
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
custom_field_master = current_nonprofit.custom_field_masters.find(params[:id])
|
custom_field_master = current_nonprofit.custom_field_masters.find(params[:id])
|
||||||
custom_field_master.update_attribute(:deleted, true)
|
custom_field_master.update_attribute(:deleted, true)
|
||||||
custom_field_master.custom_field_joins.destroy_all
|
custom_field_master.custom_field_joins.destroy_all
|
||||||
render json: {}, status: :ok
|
render json: {}, status: :ok
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,84 +1,83 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class DonationsController < ApplicationController
|
class DonationsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_user!, only: [:index, :update]
|
before_action :authenticate_nonprofit_user!, only: %i[index update]
|
||||||
before_filter :authenticate_campaign_editor!, only: [:create_offsite]
|
before_action :authenticate_campaign_editor!, only: [:create_offsite]
|
||||||
|
|
||||||
# get /nonprofit/:nonprofit_id/donations
|
# get /nonprofit/:nonprofit_id/donations
|
||||||
def index
|
def index
|
||||||
redirect_to controller: :payments, action: :index
|
redirect_to controller: :payments, action: :index
|
||||||
end # def index
|
end # def index
|
||||||
|
|
||||||
# post /nonprofits/:nonprofit_id/donations
|
# post /nonprofits/:nonprofit_id/donations
|
||||||
def create
|
def create
|
||||||
|
if params[:token]
|
||||||
|
params[:donation][:token] = params[:token]
|
||||||
|
render_json { InsertDonation.with_stripe(params[:donation], current_user) }
|
||||||
|
elsif params[:direct_debit_detail_id]
|
||||||
|
render JsonResp.new(params[:donation]) do |_data|
|
||||||
|
requires(:amount).as_int
|
||||||
|
requires(:supporter_id, :nonprofit_id)
|
||||||
|
# TODO
|
||||||
|
# requires_either(:card_id, :direct_debit_detail_id).as_int
|
||||||
|
optional(:dedication, :designation).as_string
|
||||||
|
optional(:campaign_id, :event_id).as_int
|
||||||
|
end.when_valid do |data|
|
||||||
|
|
||||||
if params[:token]
|
InsertDonation.with_sepa(data)
|
||||||
params[:donation][:token] = params[:token]
|
end
|
||||||
return render_json{ InsertDonation.with_stripe(params[:donation], current_user) }
|
end
|
||||||
elsif params[:direct_debit_detail_id]
|
end
|
||||||
render JsonResp.new(params[:donation]){|data|
|
|
||||||
requires(:amount).as_int
|
|
||||||
requires(:supporter_id, :nonprofit_id)
|
|
||||||
# TODO
|
|
||||||
# requires_either(:card_id, :direct_debit_detail_id).as_int
|
|
||||||
optional(:dedication, :designation).as_string
|
|
||||||
optional(:campaign_id, :event_id).as_int
|
|
||||||
}.when_valid{|data|
|
|
||||||
|
|
||||||
|
# post /nonprofits/:nonprofit_id/donations/create_offsite
|
||||||
InsertDonation.with_sepa(data)
|
def create_offsite
|
||||||
|
render JsonResp.new(params[:donation]) do |_data|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# post /nonprofits/:nonprofit_id/donations/create_offsite
|
|
||||||
def create_offsite
|
|
||||||
render JsonResp.new(params[:donation]){|data|
|
|
||||||
requires(:amount).as_int.min(1)
|
requires(:amount).as_int.min(1)
|
||||||
requires(:supporter_id, :nonprofit_id).as_int
|
requires(:supporter_id, :nonprofit_id).as_int
|
||||||
optional(:dedication, :designation).as_string
|
optional(:dedication, :designation).as_string
|
||||||
optional(:campaign_id, :event_id).as_int
|
optional(:campaign_id, :event_id).as_int
|
||||||
optional(:date).as_date
|
optional(:date).as_date
|
||||||
optional(:offsite_payment).nested{
|
optional(:offsite_payment).nested do
|
||||||
optional(:kind).one_of('cash', 'check')
|
optional(:kind).one_of('cash', 'check')
|
||||||
optional(:check_number)
|
optional(:check_number)
|
||||||
}
|
end
|
||||||
}.when_valid{|data| InsertDonation.offsite(data)}
|
end.when_valid { |data| InsertDonation.offsite(data) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
render_json{ UpdateDonation.update_payment(params[:id], params[:donation]) }
|
render_json { UpdateDonation.update_payment(params[:id], params[:donation]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# put /nonprofits/:nonprofit_id/donations/:id
|
# put /nonprofits/:nonprofit_id/donations/:id
|
||||||
# update designation, dedication, or comment on a donation in the followup
|
# update designation, dedication, or comment on a donation in the followup
|
||||||
def followup
|
def followup
|
||||||
nonprofit = Nonprofit.find(params[:nonprofit_id])
|
nonprofit = Nonprofit.find(params[:nonprofit_id])
|
||||||
donation = nonprofit.donations.find(params[:id])
|
donation = nonprofit.donations.find(params[:id])
|
||||||
json_saved UpdateDonation.from_followup(donation, params[:donation])
|
json_saved UpdateDonation.from_followup(donation, params[:donation])
|
||||||
end
|
end
|
||||||
|
|
||||||
# this is a special, weird case
|
# this is a special, weird case
|
||||||
private
|
private
|
||||||
|
|
||||||
def current_campaign
|
def current_campaign
|
||||||
if !@campaign && params[:donation] && params[:donation][:campaign_id]
|
if !@campaign && params[:donation] && params[:donation][:campaign_id]
|
||||||
@campaign = Campaign.where('id = ? ', params[:donation][:campaign_id]).first
|
@campaign = Campaign.where('id = ? ', params[:donation][:campaign_id]).first
|
||||||
end
|
end
|
||||||
return @campaign
|
@campaign
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_campaign_editor?
|
def current_campaign_editor?
|
||||||
!params[:preview] && (current_nonprofit_user? || (current_campaign && current_role?(:campaign_editor, current_campaign.id)) || current_role?(:super_admin))
|
!params[:preview] && (current_nonprofit_user? || (current_campaign && current_role?(:campaign_editor, current_campaign.id)) || current_role?(:super_admin))
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_campaign_editor!
|
def authenticate_campaign_editor!
|
||||||
unless current_campaign_editor?
|
unless current_campaign_editor?
|
||||||
block_with_sign_in 'You need to be a campaign editor to do that.'
|
block_with_sign_in 'You need to be a campaign editor to do that.'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class EmailListsController < ApplicationController
|
class EmailListsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
render_json{ Qx.fetch(:email_lists, nonprofit_id: params[:nonprofit_id]) }
|
render_json { Qx.fetch(:email_lists, nonprofit_id: params[:nonprofit_id]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
tag_master_ids = params['tag_masters'].values.map(&:to_i)
|
tag_master_ids = params['tag_masters'].values.map(&:to_i)
|
||||||
render_json{ InsertEmailLists.for_mailchimp(params[:nonprofit_id], tag_master_ids) }
|
render_json { InsertEmailLists.for_mailchimp(params[:nonprofit_id], tag_master_ids) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class ImportsController < ApplicationController
|
class ImportsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
# post /nonprofits/:nonprofit_id/imports
|
# post /nonprofits/:nonprofit_id/imports
|
||||||
def create
|
def create
|
||||||
render_json{
|
render_json do
|
||||||
InsertImport.delay.from_csv_safe({
|
InsertImport.delay.from_csv_safe(
|
||||||
nonprofit_id: params[:nonprofit_id],
|
nonprofit_id: params[:nonprofit_id],
|
||||||
user_id: current_user.id,
|
user_id: current_user.id,
|
||||||
user_email: current_user.email,
|
user_email: current_user.email,
|
||||||
file_uri: params[:file_uri],
|
file_uri: params[:file_uri],
|
||||||
header_matches: params[:header_matches]
|
header_matches: params[:header_matches]
|
||||||
})
|
)
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class MiscellaneousNpInfosController < ApplicationController
|
class MiscellaneousNpInfosController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
helper_method :current_nonprofit_user?
|
helper_method :current_nonprofit_user?
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
def show
|
def show
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -12,18 +14,17 @@ module Nonprofits
|
||||||
render_json { FetchMiscellaneousNpInfo.fetch(params[:nonprofit_id]) }
|
render_json { FetchMiscellaneousNpInfo.fetch(params[:nonprofit_id]) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json {
|
format.json do
|
||||||
render_json {
|
render_json do
|
||||||
update = UpdateMiscellaneousNpInfo.update(params[:nonprofit_id], params[:miscellaneous_np_info])
|
update = UpdateMiscellaneousNpInfo.update(params[:nonprofit_id], params[:miscellaneous_np_info])
|
||||||
#flash[:notice] = "Your Miscellaneous Settings have been saved"
|
# flash[:notice] = "Your Miscellaneous Settings have been saved"
|
||||||
update
|
update
|
||||||
}
|
end
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,38 +1,39 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
|
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class NonprofitKeysController < ApplicationController
|
class NonprofitKeysController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
# get /nonprofits/:nonprofit_id/nonprofit_keys
|
# get /nonprofits/:nonprofit_id/nonprofit_keys
|
||||||
# pass in the :select query param, which is the name of the column of the specific token you want
|
# pass in the :select query param, which is the name of the column of the specific token you want
|
||||||
def index
|
def index
|
||||||
render_json{QueryNonprofitKeys.get_key(current_nonprofit.id, params[:select])}
|
render_json { QueryNonprofitKeys.get_key(current_nonprofit.id, params[:select]) }
|
||||||
end
|
|
||||||
|
|
||||||
# Redirects to the mailchimp OAuth2 landing page, first setting the nonprofit id in the session
|
|
||||||
# GET /nonprofits/:nonprofit_id/nonprofit_keys/mailchimp_login
|
|
||||||
def mailchimp_login
|
|
||||||
session[:current_mailchimp_nonprofit_id] = current_nonprofit.id
|
|
||||||
redirect_to "https://login.mailchimp.com/oauth2/authorize?response_type=code&client_id=#{ENV['MAILCHIMP_OAUTH_CLIENT_ID']}"
|
|
||||||
end
|
|
||||||
|
|
||||||
# After the user OAuths mailchimp, they are redirected to /mailchimp-landing
|
|
||||||
# This action then redirects them back to /settings
|
|
||||||
# GET /mailchimp-landing
|
|
||||||
def mailchimp_landing
|
|
||||||
@nonprofit = Nonprofit.find(session[:current_mailchimp_nonprofit_id])
|
|
||||||
session.delete(:current_mailchimp_nonprofit_id)
|
|
||||||
begin
|
|
||||||
session[:mailchimp_access_token] = InsertNonprofitKeys.insert_mailchimp_access_token(@nonprofit.id, params[:code])
|
|
||||||
rescue Exception => e
|
|
||||||
flash[:notice] = "Unable to connect to your Mailchimp account, please try again. (Error: #{e})"
|
|
||||||
redirect_to '/settings'
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
redirect_to nonprofits_supporters_path @nonprofit, 'show-modal' => 'mailchimpSettingsModal'
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
# Redirects to the mailchimp OAuth2 landing page, first setting the nonprofit id in the session
|
||||||
|
# GET /nonprofits/:nonprofit_id/nonprofit_keys/mailchimp_login
|
||||||
|
def mailchimp_login
|
||||||
|
session[:current_mailchimp_nonprofit_id] = current_nonprofit.id
|
||||||
|
redirect_to "https://login.mailchimp.com/oauth2/authorize?response_type=code&client_id=#{ENV['MAILCHIMP_OAUTH_CLIENT_ID']}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# After the user OAuths mailchimp, they are redirected to /mailchimp-landing
|
||||||
|
# This action then redirects them back to /settings
|
||||||
|
# GET /mailchimp-landing
|
||||||
|
def mailchimp_landing
|
||||||
|
@nonprofit = Nonprofit.find(session[:current_mailchimp_nonprofit_id])
|
||||||
|
session.delete(:current_mailchimp_nonprofit_id)
|
||||||
|
begin
|
||||||
|
session[:mailchimp_access_token] = InsertNonprofitKeys.insert_mailchimp_access_token(@nonprofit.id, params[:code])
|
||||||
|
rescue Exception => e
|
||||||
|
flash[:notice] = "Unable to connect to your Mailchimp account, please try again. (Error: #{e})"
|
||||||
|
redirect_to '/settings'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
redirect_to nonprofits_supporters_path @nonprofit, 'show-modal' => 'mailchimpSettingsModal'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,32 +1,33 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class PaymentsController < ApplicationController
|
class PaymentsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
|
# get /nonprofit/:nonprofit_id/payments
|
||||||
# get /nonprofit/:nonprofit_id/payments
|
def index
|
||||||
def index
|
@nonprofit = current_nonprofit
|
||||||
@nonprofit = current_nonprofit
|
respond_to do |format|
|
||||||
respond_to do |format|
|
format.html do
|
||||||
format.html do
|
|
||||||
@panels_layout = true
|
@panels_layout = true
|
||||||
end
|
end
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
@response = QueryPayments.full_search(params[:nonprofit_id], params)
|
@response = QueryPayments.full_search(params[:nonprofit_id], params)
|
||||||
render json: @response, status: :ok
|
render json: @response, status: :ok
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # def index
|
end # def index
|
||||||
|
|
||||||
def export
|
def export
|
||||||
begin
|
begin
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
@user = current_user_id
|
@user = current_user_id
|
||||||
ExportPayments::initiate_export(@nonprofit.id, params, @user)
|
ExportPayments.initiate_export(@nonprofit.id, params, @user)
|
||||||
rescue => e
|
rescue StandardError => e
|
||||||
e
|
e
|
||||||
end
|
end
|
||||||
if e.nil?
|
if e.nil?
|
||||||
|
@ -37,10 +38,10 @@ module Nonprofits
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
@payment = @nonprofit.payments.find(params[:id])
|
@payment = @nonprofit.payments.find(params[:id])
|
||||||
end # def show
|
end # def show
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@payment = current_nonprofit.payments.find(params[:id])
|
@payment = current_nonprofit.payments.find(params[:id])
|
||||||
|
@ -68,11 +69,12 @@ module Nonprofits
|
||||||
PaymentMailer.resend_donor_receipt(params[:id])
|
PaymentMailer.resend_donor_receipt(params[:id])
|
||||||
render json: {}
|
render json: {}
|
||||||
end
|
end
|
||||||
|
|
||||||
# post /nonprofits/:nonprofit_id/payments/:id/resend_admin_receipt
|
# post /nonprofits/:nonprofit_id/payments/:id/resend_admin_receipt
|
||||||
# pass user_id of the admin to send to
|
# pass user_id of the admin to send to
|
||||||
def resend_admin_receipt
|
def resend_admin_receipt
|
||||||
PaymentMailer.resend_admin_receipt(params[:id], current_user.id)
|
PaymentMailer.resend_admin_receipt(params[:id], current_user.id)
|
||||||
render json: {}
|
render json: {}
|
||||||
end
|
end
|
||||||
end # class PaymentsController
|
end # class PaymentsController
|
||||||
end # module Nonprofits
|
end # module Nonprofits
|
||||||
|
|
|
@ -1,49 +1,50 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class PayoutsController < ApplicationController
|
class PayoutsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_admin!, only: :create
|
before_action :authenticate_nonprofit_admin!, only: :create
|
||||||
before_filter :authenticate_nonprofit_user!, only: [:index, :show]
|
before_action :authenticate_nonprofit_user!, only: %i[index show]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
payout = InsertPayout.with_stripe(current_nonprofit.id, {
|
payout = InsertPayout.with_stripe(current_nonprofit.id, {
|
||||||
stripe_account_id: current_nonprofit.stripe_account_id,
|
stripe_account_id: current_nonprofit.stripe_account_id,
|
||||||
email: current_user.email,
|
email: current_user.email,
|
||||||
user_ip: current_user.current_sign_in_ip,
|
user_ip: current_user.current_sign_in_ip,
|
||||||
bank_name: current_nonprofit.bank_account.name
|
bank_name: current_nonprofit.bank_account.name
|
||||||
}, {before_date: params[:before_date]})
|
}, before_date: params[:before_date])
|
||||||
|
|
||||||
if payout['failure_message'].present?
|
if payout['failure_message'].present?
|
||||||
flash[:notice] = "The payout failed: #{payout['failure_message']}"
|
flash[:notice] = "The payout failed: #{payout['failure_message']}"
|
||||||
render json: payout, status: :unprocessable_entity
|
render json: payout, status: :unprocessable_entity
|
||||||
else
|
else
|
||||||
flash[:notice] = 'We successfully submitted your payout! View status and receipts below.'
|
flash[:notice] = 'We successfully submitted your payout! View status and receipts below.'
|
||||||
render json: payout, status: :ok
|
render json: payout, status: :ok
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def index
|
|
||||||
@nonprofit = Nonprofit.find(params[:nonprofit_id])
|
|
||||||
@payouts = @nonprofit.payouts.order('created_at DESC')
|
|
||||||
balances = QueryPayments.nonprofit_balances(params[:nonprofit_id])
|
|
||||||
@available_total = balances['available_gross']
|
|
||||||
@pending_total = balances['pending_gross']
|
|
||||||
@can_make_payouts = @nonprofit.can_make_payouts
|
|
||||||
end
|
|
||||||
|
|
||||||
# get /nonprofits/:nonprofit_id/payouts/:id
|
|
||||||
def show
|
|
||||||
payout = current_nonprofit.payouts.find(params[:id])
|
|
||||||
respond_to do |format|
|
|
||||||
format.json{render json: payout}
|
|
||||||
format.csv do
|
|
||||||
payments = QueryPayments.for_payout(params[:nonprofit_id], params[:id])
|
|
||||||
filename = "payout-#{payout.created_at.strftime("%m-%d-%Y")}"
|
|
||||||
send_data(Format::Csv.from_vectors(payments), filename: "#{filename}.csv")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
def index
|
||||||
|
@nonprofit = Nonprofit.find(params[:nonprofit_id])
|
||||||
|
@payouts = @nonprofit.payouts.order('created_at DESC')
|
||||||
|
balances = QueryPayments.nonprofit_balances(params[:nonprofit_id])
|
||||||
|
@available_total = balances['available_gross']
|
||||||
|
@pending_total = balances['pending_gross']
|
||||||
|
@can_make_payouts = @nonprofit.can_make_payouts
|
||||||
|
end
|
||||||
|
|
||||||
|
# get /nonprofits/:nonprofit_id/payouts/:id
|
||||||
|
def show
|
||||||
|
payout = current_nonprofit.payouts.find(params[:id])
|
||||||
|
respond_to do |format|
|
||||||
|
format.json { render json: payout }
|
||||||
|
format.csv do
|
||||||
|
payments = QueryPayments.for_payout(params[:nonprofit_id], params[:id])
|
||||||
|
filename = "payout-#{payout.created_at.strftime('%m-%d-%Y')}"
|
||||||
|
send_data(Format::Csv.from_vectors(payments), filename: "#{filename}.csv")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,94 +1,95 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class RecurringDonationsController < ApplicationController
|
class RecurringDonationsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_user!, except: [:create]
|
before_action :authenticate_nonprofit_user!, except: [:create]
|
||||||
|
|
||||||
# get /nonprofits/:nonprofit_id/recurring_donations
|
# get /nonprofits/:nonprofit_id/recurring_donations
|
||||||
def index
|
def index
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
@panels_layout = true
|
@panels_layout = true
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.json do
|
format.json do
|
||||||
# set dashboard params include externally active and failed
|
# set dashboard params include externally active and failed
|
||||||
#TODO move into javascript
|
# TODO move into javascript
|
||||||
params[:active] = true
|
params[:active] = true
|
||||||
|
|
||||||
render json: QueryRecurringDonations.full_list(params[:nonprofit_id], params)
|
render json: QueryRecurringDonations.full_list(params[:nonprofit_id], params)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def export
|
|
||||||
begin
|
|
||||||
@nonprofit = current_nonprofit
|
|
||||||
@user = current_user_id
|
|
||||||
#TODO move into javascript
|
|
||||||
if params.key?(:active_and_not_failed)
|
|
||||||
params.delete(:active) if params.key?(:active)
|
|
||||||
params.delete(:failed) if params.key?(:failed)
|
|
||||||
end
|
|
||||||
|
|
||||||
[:active_and_not_failed, :active, :failed].each do |k|
|
|
||||||
if (params.key?(k))
|
|
||||||
params[k] = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(params[k])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
params[:root_url] = root_url
|
|
||||||
|
|
||||||
ExportRecurringDonations::initiate_export(@nonprofit.id, params, current_user.id)
|
|
||||||
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
|
|
||||||
@recurring_donation = current_recurring_donation
|
|
||||||
respond_to {|format| format.json}
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
UpdateRecurringDonations.cancel(params[:id], current_user.email)
|
|
||||||
json_saved current_recurring_donation
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
|
||||||
json_saved UpdateRecurringDonations
|
|
||||||
.update(current_recurring_donation, params[:recurring_donation])
|
|
||||||
end
|
|
||||||
|
|
||||||
# post /nonprofits/:nonprofit_id/recurring_donations
|
|
||||||
def create
|
|
||||||
if params[:recurring_donation][:token]
|
|
||||||
render_json{ InsertRecurringDonation.with_stripe(params[:recurring_donation]) }
|
|
||||||
elsif params[:recurring_donation][:direct_debit_detail_id]
|
|
||||||
render JsonResp.new(params[:recurring_donation]){|data|
|
|
||||||
requires(:amount).as_int
|
|
||||||
requires(:supporter_id, :nonprofit_id, :direct_debit_detail_id).as_int
|
|
||||||
optional(:dedication, :designation).as_string
|
|
||||||
optional(:campaign_id, :event_id).as_int
|
|
||||||
}.when_valid{|data|
|
|
||||||
InsertRecurringDonation.with_sepa(data)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
render json: {}, status: 422
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
private
|
def export
|
||||||
|
begin
|
||||||
|
@nonprofit = current_nonprofit
|
||||||
|
@user = current_user_id
|
||||||
|
# TODO: move into javascript
|
||||||
|
if params.key?(:active_and_not_failed)
|
||||||
|
params.delete(:active) if params.key?(:active)
|
||||||
|
params.delete(:failed) if params.key?(:failed)
|
||||||
|
end
|
||||||
|
|
||||||
def current_recurring_donation
|
%i[active_and_not_failed active failed].each do |k|
|
||||||
@recurring_donation ||= current_nonprofit.recurring_donations.find params[:id]
|
if params.key?(k)
|
||||||
end
|
params[k] = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(params[k])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
params[:root_url] = root_url
|
||||||
|
|
||||||
|
ExportRecurringDonations.initiate_export(@nonprofit.id, params, current_user.id)
|
||||||
|
rescue StandardError => 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
|
||||||
|
@recurring_donation = current_recurring_donation
|
||||||
|
respond_to { |format| format.json }
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
UpdateRecurringDonations.cancel(params[:id], current_user.email)
|
||||||
|
json_saved current_recurring_donation
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
json_saved UpdateRecurringDonations
|
||||||
|
.update(current_recurring_donation, params[:recurring_donation])
|
||||||
|
end
|
||||||
|
|
||||||
|
# post /nonprofits/:nonprofit_id/recurring_donations
|
||||||
|
def create
|
||||||
|
if params[:recurring_donation][:token]
|
||||||
|
render_json { InsertRecurringDonation.with_stripe(params[:recurring_donation]) }
|
||||||
|
elsif params[:recurring_donation][:direct_debit_detail_id]
|
||||||
|
render JsonResp.new(params[:recurring_donation]) do |_data|
|
||||||
|
requires(:amount).as_int
|
||||||
|
requires(:supporter_id, :nonprofit_id, :direct_debit_detail_id).as_int
|
||||||
|
optional(:dedication, :designation).as_string
|
||||||
|
optional(:campaign_id, :event_id).as_int
|
||||||
|
end.when_valid do |data|
|
||||||
|
InsertRecurringDonation.with_sepa(data)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render json: {}, status: 422
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def current_recurring_donation
|
||||||
|
@recurring_donation ||= current_nonprofit.recurring_donations.find params[:id]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class RefundsController < ApplicationController
|
class RefundsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
# post /charges/:charge_id/refunds
|
# post /charges/:charge_id/refunds
|
||||||
def create
|
def create
|
||||||
charge = Qx.select("*").from("charges").where(id: params[:charge_id]).execute.first
|
charge = Qx.select('*').from('charges').where(id: params[:charge_id]).execute.first
|
||||||
params[:refund][:user_id] = current_user.id
|
params[:refund][:user_id] = current_user.id
|
||||||
render_json{ InsertRefunds.with_stripe(charge, params['refund']) }
|
render_json { InsertRefunds.with_stripe(charge, params['refund']) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
charge = current_nonprofit.charges.find(params[:charge_id])
|
charge = current_nonprofit.charges.find(params[:charge_id])
|
||||||
@refunds = charge.refunds
|
@refunds = charge.refunds
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class ReportsController < ApplicationController
|
class ReportsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
def end_of_year
|
def end_of_year
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.csv do
|
format.csv do
|
||||||
filename = "end-of-year-report-#{params[:year]}.csv"
|
filename = "end-of-year-report-#{params[:year]}.csv"
|
||||||
data = QuerySupporters.year_aggregate_report(params[:nonprofit_id], {:year => params[:year]})
|
data = QuerySupporters.year_aggregate_report(params[:nonprofit_id], year: params[:year])
|
||||||
send_data(Format::Csv.from_array(data), filename: filename)
|
send_data(Format::Csv.from_array(data), filename: filename)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,17 +20,15 @@ module Nonprofits
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.csv do
|
format.csv do
|
||||||
name_description = nil
|
name_description = nil
|
||||||
if (params[:year])
|
if params[:year]
|
||||||
name_description = params[:year]
|
name_description = params[:year]
|
||||||
elsif (params[:start])
|
elsif params[:start]
|
||||||
name_description = "from-#{params[:start]}"
|
name_description = "from-#{params[:start]}"
|
||||||
if (params[:end])
|
name_description += "-to-#{params[:end]}" if params[:end]
|
||||||
name_description += "-to-#{params[:end]}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
filename = "aggregate-report-#{name_description}.csv"
|
filename = "aggregate-report-#{name_description}.csv"
|
||||||
data = QuerySupporters.year_aggregate_report(params[:nonprofit_id], {:year => params[:year], :start => params[:start], :end => params[:end]})
|
data = QuerySupporters.year_aggregate_report(params[:nonprofit_id], year: params[:year], start: params[:start], end: params[:end])
|
||||||
send_data(Format::Csv.from_array(data), filename: filename)
|
send_data(Format::Csv.from_array(data), filename: filename)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,25 +1,27 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class SupporterEmailsController < ApplicationController
|
class SupporterEmailsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if params[:selecting_all]
|
if params[:selecting_all]
|
||||||
ids = QuerySupporters.full_filter_expr(params[:nonprofit_id], params[:query])
|
ids = QuerySupporters.full_filter_expr(params[:nonprofit_id], params[:query])
|
||||||
.select("supporters.id")
|
.select('supporters.id')
|
||||||
.execute(format: 'csv')[1..-1].flatten
|
.execute(format: 'csv')[1..-1].flatten
|
||||||
elsif params[:supporter_ids]
|
elsif params[:supporter_ids]
|
||||||
ids = params[:supporter_ids]
|
ids = params[:supporter_ids]
|
||||||
end
|
end
|
||||||
|
|
||||||
if ids.nil? || ids.empty?
|
if ids.nil? || ids.empty?
|
||||||
render json: {errors: 'Supporters not found'}, status: :unprocessable_entity
|
render json: { errors: 'Supporters not found' }, status: :unprocessable_entity
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
DelayedJobHelper.enqueue_job(EmailSupporters, :deliver, [ids, params[:supporter_email]])
|
DelayedJobHelper.enqueue_job(EmailSupporters, :deliver, [ids, params[:supporter_email]])
|
||||||
render json: {count: ids.count}, status: :ok
|
render json: { count: ids.count }, status: :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
def gmail
|
def gmail
|
||||||
|
@ -29,4 +31,3 @@ module Nonprofits
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,28 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class SupporterNotesController < ApplicationController
|
class SupporterNotesController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_user!, except: [:create]
|
before_action :authenticate_nonprofit_user!, except: [:create]
|
||||||
|
|
||||||
# post /nonprofits/:nonprofit_id/supporters/:supporter_id/supporter_notes
|
# post /nonprofits/:nonprofit_id/supporters/:supporter_id/supporter_notes
|
||||||
def create
|
def create
|
||||||
params[:supporter_note][:user_id] ||= current_user && current_user.id
|
params[:supporter_note][:user_id] ||= current_user&.id
|
||||||
render_json{ InsertSupporterNotes.create([params[:supporter_note]]) }
|
render_json { InsertSupporterNotes.create([params[:supporter_note]]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# put /nonprofits/:nonprofit_id/supporters/:supporter_id/supporter_notes/:id
|
# put /nonprofits/:nonprofit_id/supporters/:supporter_id/supporter_notes/:id
|
||||||
def update
|
def update
|
||||||
params[:supporter_note][:user_id] ||= current_user && current_user.id
|
params[:supporter_note][:user_id] ||= current_user&.id
|
||||||
params[:supporter_note][:id] = params[:id]
|
params[:supporter_note][:id] = params[:id]
|
||||||
render_json{ UpdateSupporterNotes.update(params[:supporter_note]) }
|
render_json { UpdateSupporterNotes.update(params[:supporter_note]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# delete /nonprofits/:nonprofit_id/supporters/:supporter_id/supporter_notes/:id
|
|
||||||
def destroy
|
|
||||||
render_json{ UpdateSupporterNotes.delete(params[:id]) }
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
# delete /nonprofits/:nonprofit_id/supporters/:supporter_id/supporter_notes/:id
|
||||||
|
def destroy
|
||||||
|
render_json { UpdateSupporterNotes.delete(params[:id]) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,114 +1,114 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class SupportersController < ApplicationController
|
class SupportersController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_user!, except: [:new, :create]
|
before_action :authenticate_nonprofit_user!, except: %i[new create]
|
||||||
#before_filter(except: [:create, :mailchimp_landing]){authenticate_min_nonprofit_plan(2)}
|
# before_action(except: [:create, :mailchimp_landing]){authenticate_min_nonprofit_plan(2)}
|
||||||
|
|
||||||
# get /nonprofit/:nonprofit_id/supporters
|
# get /nonprofit/:nonprofit_id/supporters
|
||||||
def index
|
def index
|
||||||
@panels_layout = true
|
@panels_layout = true
|
||||||
@nonprofit = current_nonprofit
|
|
||||||
respond_to do |format|
|
|
||||||
format.html
|
|
||||||
format.json do
|
|
||||||
render json: QuerySupporters.full_search(params[:nonprofit_id], params)
|
|
||||||
end
|
|
||||||
|
|
||||||
format.csv do
|
|
||||||
file_date = Date.today.strftime("%m-%d-%Y")
|
|
||||||
supporters = QuerySupporters.for_export(params[:nonprofit_id], params)
|
|
||||||
send_data(Format::Csv.from_vectors(supporters), filename: "supporters-#{file_date}.csv")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def export
|
|
||||||
begin
|
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
@user = current_user_id
|
respond_to do |format|
|
||||||
ExportSupporters::initiate_export(@nonprofit.id, params, @user)
|
format.html
|
||||||
rescue => e
|
format.json do
|
||||||
e
|
render json: QuerySupporters.full_search(params[:nonprofit_id], params)
|
||||||
|
end
|
||||||
|
|
||||||
|
format.csv do
|
||||||
|
file_date = Date.today.strftime('%m-%d-%Y')
|
||||||
|
supporters = QuerySupporters.for_export(params[:nonprofit_id], params)
|
||||||
|
send_data(Format::Csv.from_vectors(supporters), filename: "supporters-#{file_date}.csv")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
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."
|
def export
|
||||||
render json: {}, status: :ok
|
begin
|
||||||
else
|
@nonprofit = current_nonprofit
|
||||||
render json: e, status: :ok
|
@user = current_user_id
|
||||||
|
ExportSupporters.initiate_export(@nonprofit.id, params, @user)
|
||||||
|
rescue StandardError => 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
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def index_metrics
|
def index_metrics
|
||||||
render_json do
|
render_json do
|
||||||
QuerySupporters.full_search_metrics(params[:nonprofit_id], params)
|
QuerySupporters.full_search_metrics(params[:nonprofit_id], params)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
render json: {data: QuerySupporters.for_crm_profile(params[:nonprofit_id], [params[:id]]).first}
|
render json: { data: QuerySupporters.for_crm_profile(params[:nonprofit_id], [params[:id]]).first }
|
||||||
end
|
|
||||||
|
|
||||||
def email_address
|
|
||||||
render json: Supporter.find(params[:supporter_id]).email
|
|
||||||
end
|
|
||||||
|
|
||||||
def full_contact
|
|
||||||
fc = FullContactInfo.where("supporter_id=#{params[:supporter_id]}").first
|
|
||||||
if fc
|
|
||||||
render json: {full_contact: QueryFullContactInfos.fetch_associated_tables(fc.id )}
|
|
||||||
else
|
|
||||||
render json: {full_contact: nil}
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def info_card
|
def email_address
|
||||||
render json: QuerySupporters.for_info_card(params[:supporter_id])
|
render json: Supporter.find(params[:supporter_id]).email
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
# post /nonprofits/:nonprofit_id/supporters
|
|
||||||
def create
|
|
||||||
render_json{ InsertSupporter.create_or_update(params[:nonprofit_id], params[:supporter]) }
|
|
||||||
end
|
|
||||||
|
|
||||||
# put /nonprofits/:nonprofit_id/supporters/:id
|
|
||||||
def update
|
|
||||||
@supporter = current_nonprofit.supporters.find(params[:id])
|
|
||||||
json_saved UpdateSupporter.from_info(@supporter, params[:supporter])
|
|
||||||
end
|
|
||||||
|
|
||||||
def bulk_delete
|
|
||||||
if params[:selecting_all]
|
|
||||||
supporter_ids = QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select("supporters.id").execute.map{|h| h['id']}
|
|
||||||
else
|
|
||||||
supporter_ids = params[:supporter_ids]. map(&:to_i)
|
|
||||||
end
|
end
|
||||||
render_json {UpdateSupporter.bulk_delete(current_nonprofit.id, supporter_ids ) }
|
|
||||||
end
|
|
||||||
|
|
||||||
# get /nonprofits/:nonprofit_id/supporters/merge_data
|
def full_contact
|
||||||
# returns the info required to merge two supporters
|
fc = FullContactInfo.where("supporter_id=#{params[:supporter_id]}").first
|
||||||
def merge_data
|
if fc
|
||||||
render json: QuerySupporters.merge_data(params[:ids])
|
render json: { full_contact: QueryFullContactInfos.fetch_associated_tables(fc.id) }
|
||||||
end
|
else
|
||||||
|
render json: { full_contact: nil }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# post /nonprofits/:nonprofit_id/supporters/merge
|
def info_card
|
||||||
def merge
|
render json: QuerySupporters.for_info_card(params[:supporter_id])
|
||||||
render JsonResp.new(params){|params|
|
end
|
||||||
requires(:supporter)
|
|
||||||
requires(:nonprofit_id).as_int
|
|
||||||
requires(:supporter_ids).as_array
|
|
||||||
}.when_valid{|params|
|
|
||||||
params[:supporter][:nonprofit_id] = params[:nonprofit_id]
|
|
||||||
MergeSupporters.selected(params[:supporter], params[:supporter_ids], params[:nonprofit_id], current_user.id)
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# def new
|
# post /nonprofits/:nonprofit_id/supporters
|
||||||
# @nonprofit = current_nonprofit
|
def create
|
||||||
# end
|
render_json { InsertSupporter.create_or_update(params[:nonprofit_id], params[:supporter]) }
|
||||||
|
end
|
||||||
|
|
||||||
end
|
# put /nonprofits/:nonprofit_id/supporters/:id
|
||||||
|
def update
|
||||||
|
@supporter = current_nonprofit.supporters.find(params[:id])
|
||||||
|
json_saved UpdateSupporter.from_info(@supporter, params[:supporter])
|
||||||
|
end
|
||||||
|
|
||||||
|
def bulk_delete
|
||||||
|
if params[:selecting_all]
|
||||||
|
supporter_ids = QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select('supporters.id').execute.map { |h| h['id'] }
|
||||||
|
else
|
||||||
|
supporter_ids = params[:supporter_ids]. map(&:to_i)
|
||||||
|
end
|
||||||
|
render_json { UpdateSupporter.bulk_delete(current_nonprofit.id, supporter_ids) }
|
||||||
|
end
|
||||||
|
|
||||||
|
# get /nonprofits/:nonprofit_id/supporters/merge_data
|
||||||
|
# returns the info required to merge two supporters
|
||||||
|
def merge_data
|
||||||
|
render json: QuerySupporters.merge_data(params[:ids])
|
||||||
|
end
|
||||||
|
|
||||||
|
# post /nonprofits/:nonprofit_id/supporters/merge
|
||||||
|
def merge
|
||||||
|
render JsonResp.new(params) do |_params|
|
||||||
|
requires(:supporter)
|
||||||
|
requires(:nonprofit_id).as_int
|
||||||
|
requires(:supporter_ids).as_array
|
||||||
|
end.when_valid do |params|
|
||||||
|
params[:supporter][:nonprofit_id] = params[:nonprofit_id]
|
||||||
|
MergeSupporters.selected(params[:supporter], params[:supporter_ids], params[:nonprofit_id], current_user.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# def new
|
||||||
|
# @nonprofit = current_nonprofit
|
||||||
|
# end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,36 +1,32 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class TagJoinsController < ApplicationController
|
class TagJoinsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
render_json do
|
render_json do
|
||||||
{data: QuerySupporters.tag_joins(params['nonprofit_id'], params['supporter_id'])}
|
{ data: QuerySupporters.tag_joins(params['nonprofit_id'], params['supporter_id']) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# used for modify a single supporter's tags or a group of
|
# used for modify a single supporter's tags or a group of
|
||||||
# selected supporters' tags or all supporters' tags
|
# selected supporters' tags or all supporters' tags
|
||||||
def modify
|
def modify
|
||||||
|
|
||||||
if params[:selecting_all]
|
if params[:selecting_all]
|
||||||
supporter_ids = QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select("supporters.id").execute.map{|h| h['id']}
|
supporter_ids = QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select('supporters.id').execute.map { |h| h['id'] }
|
||||||
else
|
else
|
||||||
supporter_ids = params[:supporter_ids]. map(&:to_i)
|
supporter_ids = params[:supporter_ids]. map(&:to_i)
|
||||||
end
|
end
|
||||||
render InsertTagJoins.in_bulk(current_nonprofit.id, current_user.profile.id, supporter_ids, params[:tags])
|
render InsertTagJoins.in_bulk(current_nonprofit.id, current_user.profile.id, supporter_ids, params[:tags])
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
supporter = current_nonprofit.supporters.find(params[:supporter_id])
|
||||||
end
|
supporter.tag_joins.find(params[:id]).destroy
|
||||||
|
render json: {}, status: :ok
|
||||||
def destroy
|
end
|
||||||
supporter = current_nonprofit.supporters.find(params[:supporter_id])
|
end
|
||||||
supporter.tag_joins.find(params[:id]).destroy
|
|
||||||
render json: {}, status: :ok
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class TagMastersController < ApplicationController
|
class TagMastersController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
before_filter :authenticate_nonprofit_user!
|
before_action :authenticate_nonprofit_user!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
render json: {data:
|
render json: { data:
|
||||||
Qx.select('id', 'name', 'created_at')
|
Qx.select('id', 'name', 'created_at')
|
||||||
.from('tag_masters')
|
.from('tag_masters')
|
||||||
.where(
|
.where(
|
||||||
['tag_masters.nonprofit_id = $id', id: current_nonprofit.id],
|
['tag_masters.nonprofit_id = $id', id: current_nonprofit.id],
|
||||||
["coalesce(deleted, FALSE) = FALSE"])
|
['coalesce(deleted, FALSE) = FALSE']
|
||||||
.execute
|
)
|
||||||
}
|
.execute }
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -25,7 +27,5 @@ module Nonprofits
|
||||||
tag_master.tag_joins.destroy_all
|
tag_master.tag_joins.destroy_all
|
||||||
render json: {}, status: :ok
|
render json: {}, status: :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module Nonprofits
|
module Nonprofits
|
||||||
class TrackingsController < ApplicationController
|
class TrackingsController < ApplicationController
|
||||||
# POST /nonprofits/:nonprofit_id/tracking
|
# POST /nonprofits/:nonprofit_id/tracking
|
||||||
def create
|
def create
|
||||||
render JsonResp.new(params){|data|
|
render JsonResp.new(params) do |_data|
|
||||||
requires(:donation_id).as_int
|
requires(:donation_id).as_int
|
||||||
optional(:utm_campaign, :utm_content, :utm_medium, :utm_source).as_string
|
optional(:utm_campaign, :utm_content, :utm_medium, :utm_source).as_string
|
||||||
}.when_valid{|data|
|
end.when_valid do |_data|
|
||||||
InsertTracking.create(params)
|
InsertTracking.create(params)
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,67 +1,69 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class NonprofitsController < ApplicationController
|
class NonprofitsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
helper_method :current_nonprofit_user?
|
helper_method :current_nonprofit_user?
|
||||||
before_filter :authenticate_nonprofit_user!, only: [:dashboard, :dashboard_metrics, :dashboard_todos, :payment_history, :profile_todos, :recurring_donation_stats, :update, :verify_identity]
|
before_action :authenticate_nonprofit_user!, only: %i[dashboard dashboard_metrics dashboard_todos payment_history profile_todos recurring_donation_stats update verify_identity]
|
||||||
before_filter :authenticate_super_admin!, only: [:destroy]
|
before_action :authenticate_super_admin!, only: [:destroy]
|
||||||
|
|
||||||
# get /nonprofits/:id
|
# get /nonprofits/:id
|
||||||
# get /:state_code/:city/:name
|
# get /:state_code/:city/:name
|
||||||
def show
|
def show
|
||||||
if !current_nonprofit.published && !current_role?(:super_admin)
|
if !current_nonprofit.published && !current_role?(:super_admin)
|
||||||
block_with_sign_in
|
block_with_sign_in
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
@url = Format::Url.concat(root_url, @nonprofit.url)
|
@url = Format::Url.concat(root_url, @nonprofit.url)
|
||||||
@supporters = @nonprofit.supporters.not_deleted
|
@supporters = @nonprofit.supporters.not_deleted
|
||||||
@profiles = @nonprofit.profiles.order('total_raised DESC').limit(5).includes(:user).uniq
|
@profiles = @nonprofit.profiles.order('total_raised DESC').limit(5).includes(:user).uniq
|
||||||
|
|
||||||
events = @nonprofit.events.not_deleted.order('start_datetime desc')
|
events = @nonprofit.events.not_deleted.order('start_datetime desc')
|
||||||
campaigns = @nonprofit.campaigns.not_deleted.not_a_child.order('created_at desc')
|
campaigns = @nonprofit.campaigns.not_deleted.not_a_child.order('created_at desc')
|
||||||
|
|
||||||
@events = events.upcoming
|
@events = events.upcoming
|
||||||
@any_past_events = events.past.any?
|
@any_past_events = events.past.any?
|
||||||
@active_campaigns = campaigns.active
|
@active_campaigns = campaigns.active
|
||||||
@any_past_campaigns = campaigns.past.any?
|
@any_past_campaigns = campaigns.past.any?
|
||||||
|
|
||||||
@nonprofit_background_image = FetchBackgroundImage.with_model(@nonprofit)
|
@nonprofit_background_image = FetchBackgroundImage.with_model(@nonprofit)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.json {render json: @nonprofit}
|
format.json { @nonprofit }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def recurring_donation_stats
|
def recurring_donation_stats
|
||||||
render json: QueryRecurringDonations.overall_stats(params[:nonprofit_id])
|
render json: QueryRecurringDonations.overall_stats(params[:nonprofit_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def profile_todos
|
def profile_todos
|
||||||
render json: FetchTodoStatus.for_profile(current_nonprofit)
|
render json: FetchTodoStatus.for_profile(current_nonprofit)
|
||||||
end
|
end
|
||||||
|
|
||||||
def dashboard_todos
|
def dashboard_todos
|
||||||
render json: FetchTodoStatus.for_dashboard(current_nonprofit)
|
render json: FetchTodoStatus.for_dashboard(current_nonprofit)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
current_user ||= User.find(params[:user_id])
|
current_user ||= User.find(params[:user_id])
|
||||||
json_saved Nonprofit.register(current_user, params[:nonprofit])
|
json_saved Nonprofit.register(current_user, params[:nonprofit])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
flash[:notice] = 'Update successful!'
|
flash[:notice] = 'Update successful!'
|
||||||
current_nonprofit.update_attributes params[:nonprofit].except(:verification_status)
|
current_nonprofit.update_attributes params[:nonprofit].except(:verification_status)
|
||||||
json_saved current_nonprofit
|
json_saved current_nonprofit
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
current_nonprofit.destroy
|
current_nonprofit.destroy
|
||||||
flash[:notice] = 'Nonprofit removed'
|
flash[:notice] = 'Nonprofit removed'
|
||||||
render json: {}
|
render json: {}
|
||||||
end
|
end
|
||||||
|
|
||||||
# get /nonprofits/:id/donate
|
# get /nonprofits/:id/donate
|
||||||
def donate
|
def donate
|
||||||
|
@ -69,18 +71,18 @@
|
||||||
@referer = params[:origin] || request.env['HTTP_REFERER']
|
@referer = params[:origin] || request.env['HTTP_REFERER']
|
||||||
@campaign = current_nonprofit.campaigns.find_by_id(params[:campaign_id]) if params[:campaign_id]
|
@campaign = current_nonprofit.campaigns.find_by_id(params[:campaign_id]) if params[:campaign_id]
|
||||||
@countries_translations = countries_list(I18n.locale)
|
@countries_translations = countries_list(I18n.locale)
|
||||||
respond_to { |format| format.html{render layout: 'layouts/embed'} }
|
respond_to { |format| format.html { render layout: 'layouts/embed' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
def btn
|
def btn
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
respond_to { |format| format.html{render layout: 'layouts/embed'} }
|
respond_to { |format| format.html { render layout: 'layouts/embed' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
# get /nonprofits/:id/supporter_form
|
# get /nonprofits/:id/supporter_form
|
||||||
def supporter_form
|
def supporter_form
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
respond_to { |format| format.html{render layout: 'layouts/embed'} }
|
respond_to { |format| format.html { render layout: 'layouts/embed' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
# post /nonprofits/:id/supporter_with_tag
|
# post /nonprofits/:id/supporter_with_tag
|
||||||
|
@ -89,21 +91,21 @@
|
||||||
render json: InsertSupporter.with_tags_and_fields(@nonprofit.id, params[:supporter])
|
render json: InsertSupporter.with_tags_and_fields(@nonprofit.id, params[:supporter])
|
||||||
end
|
end
|
||||||
|
|
||||||
def dashboard
|
def dashboard
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
respond_to { |format| format.html }
|
respond_to { |format| format.html }
|
||||||
end
|
end
|
||||||
|
|
||||||
def dashboard_metrics
|
def dashboard_metrics
|
||||||
render json: Hamster::Hash[data: NonprofitMetrics.all_metrics(current_nonprofit.id)]
|
render json: Hamster::Hash[data: NonprofitMetrics.all_metrics(current_nonprofit.id)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def payment_history
|
def payment_history
|
||||||
render json: NonprofitMetrics.payment_history(params)
|
render json: NonprofitMetrics.payment_history(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
# put /nonprofits/:id/verify_identity
|
# put /nonprofits/:id/verify_identity
|
||||||
def verify_identity
|
def verify_identity
|
||||||
if params[:legal_entity][:address]
|
if params[:legal_entity][:address]
|
||||||
tos = {
|
tos = {
|
||||||
ip: current_user.current_sign_in_ip,
|
ip: current_user.current_sign_in_ip,
|
||||||
|
@ -111,8 +113,8 @@
|
||||||
user_agent: request.user_agent
|
user_agent: request.user_agent
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
render_json{ UpdateNonprofit.verify_identity(params[:nonprofit_id], params[:legal_entity], tos) }
|
render_json { UpdateNonprofit.verify_identity(params[:nonprofit_id], params[:legal_entity], tos) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def search
|
def search
|
||||||
render json: QueryNonprofits.by_search_string(params[:npo_name])
|
render json: QueryNonprofits.by_search_string(params[:npo_name])
|
||||||
|
@ -132,13 +134,12 @@
|
||||||
all_countries = ISO3166::Country.translations(locale)
|
all_countries = ISO3166::Country.translations(locale)
|
||||||
|
|
||||||
if Settings.intntl.all_countries
|
if Settings.intntl.all_countries
|
||||||
countries = all_countries.select{ |code, name| Settings.intntl.all_countries.include? code }
|
countries = all_countries.select { |code, _name| Settings.intntl.all_countries.include? code }
|
||||||
countries = countries.map{ |code, name| [code.upcase, name] }.sort{ |a, b| a[1] <=> b[1] }
|
countries = countries.map { |code, name| [code.upcase, name] }.sort_by { |a| a[1] }
|
||||||
countries.push([Settings.intntl.other_country.upcase, I18n.t('nonprofits.donate.info.supporter.other_country')]) if Settings.intntl.other_country
|
countries.push([Settings.intntl.other_country.upcase, I18n.t('nonprofits.donate.info.supporter.other_country')]) if Settings.intntl.other_country
|
||||||
countries
|
countries
|
||||||
else
|
else
|
||||||
all_countries.map{ |code, name| [code.upcase, name] }.sort{ |a, b| a[1] <=> b[1] }
|
all_countries.map { |code, name| [code.upcase, name] }.sort_by { |a| a[1] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class OnboardController < ApplicationController
|
class OnboardController < ApplicationController
|
||||||
layout 'layouts/apified'
|
layout 'layouts/apified'
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,63 +1,64 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class ProfilesController < ApplicationController
|
class ProfilesController < ApplicationController
|
||||||
|
|
||||||
helper_method :authenticate_profile_owner!
|
helper_method :authenticate_profile_owner!
|
||||||
|
|
||||||
before_filter :authenticate_profile_owner!, only: [:update, :fundraisers, :donations_history]
|
before_action :authenticate_profile_owner!, only: %i[update fundraisers donations_history]
|
||||||
|
|
||||||
# get /profiles/:id
|
# get /profiles/:id
|
||||||
# public profile
|
# public profile
|
||||||
def show
|
def show
|
||||||
@profile = Profile.find(params[:id])
|
@profile = Profile.find(params[:id])
|
||||||
@profile_nonprofits = Psql.execute(Qexpr.new.select("DISTINCT nonprofits.*").from(:nonprofits).join(:supporters, "supporters.nonprofit_id=nonprofits.id AND supporters.profile_id=#{@profile.id}"))
|
@profile_nonprofits = Psql.execute(Qexpr.new.select('DISTINCT nonprofits.*').from(:nonprofits).join(:supporters, "supporters.nonprofit_id=nonprofits.id AND supporters.profile_id=#{@profile.id}"))
|
||||||
@campaigns = @profile.campaigns.published.includes(:nonprofit)
|
@campaigns = @profile.campaigns.published.includes(:nonprofit)
|
||||||
if @profile.anonymous? && current_user_id != @profile.user_id && !:super_admin
|
if @profile.anonymous? && current_user_id != @profile.user_id && !:super_admin
|
||||||
flash[:notice] = 'That user does not have a public profile.'
|
flash[:notice] = 'That user does not have a public profile.'
|
||||||
redirect_to(request.env["HTTP_REFERER"] || root_url)
|
redirect_to(request.env['HTTP_REFERER'] || root_url)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# get /profiles/:id/donations_history
|
# get /profiles/:id/donations_history
|
||||||
def donations_history
|
def donations_history
|
||||||
validate
|
validate
|
||||||
@profile = Profile.find(params[:id])
|
@profile = Profile.find(params[:id])
|
||||||
@recurring_donations = @profile.recurring_donations.where(:active => true).includes(:nonprofit)
|
@recurring_donations = @profile.recurring_donations.where(active: true).includes(:nonprofit)
|
||||||
@donations = @profile.donations.includes(:nonprofit)
|
@donations = @profile.donations.includes(:nonprofit)
|
||||||
end
|
end
|
||||||
|
|
||||||
# get /profiles/:id/fundraisers
|
# get /profiles/:id/fundraisers
|
||||||
def fundraisers
|
def fundraisers
|
||||||
validate
|
validate
|
||||||
current_user = Profile.find(params[:id]).user
|
current_user = Profile.find(params[:id]).user
|
||||||
@profile = current_user.profile
|
@profile = current_user.profile
|
||||||
@edited_campaigns = Campaign.where("profile_id=#{@profile.id}").order("end_datetime DESC")
|
@edited_campaigns = Campaign.where("profile_id=#{@profile.id}").order('end_datetime DESC')
|
||||||
end
|
end
|
||||||
|
|
||||||
# get /profiles/:id/events
|
# get /profiles/:id/events
|
||||||
def events
|
def events
|
||||||
render json: QueryEventMetrics.for_listings('profile', params[:id], params)
|
render json: QueryEventMetrics.for_listings('profile', params[:id], params)
|
||||||
end
|
end
|
||||||
|
|
||||||
# put /profiles/:id
|
# put /profiles/:id
|
||||||
def update
|
def update
|
||||||
if current_role?(:super_admin) # can update other profiles
|
@profile = if current_role?(:super_admin) # can update other profiles
|
||||||
@profile = Profile.find(params[:id])
|
Profile.find(params[:id])
|
||||||
else
|
else
|
||||||
@profile = current_user.profile
|
current_user.profile
|
||||||
end
|
end
|
||||||
@profile.update_attributes(params[:profile])
|
@profile.update_attributes(params[:profile])
|
||||||
json_saved @profile, 'Profile updated'
|
json_saved @profile, 'Profile updated'
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def authenticate_profile_owner!()
|
def authenticate_profile_owner!
|
||||||
if (!current_role?(:super_associate) &&
|
if !current_role?(:super_associate) &&
|
||||||
!current_role?(:super_admin) &&
|
!current_role?(:super_admin) &&
|
||||||
(!current_user ||
|
(!current_user ||
|
||||||
!current_user.profile ||
|
!current_user.profile ||
|
||||||
current_user.profile.id != params[:id].to_i))
|
current_user.profile.id != params[:id].to_i)
|
||||||
block_with_sign_in
|
block_with_sign_in
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class RecurringDonationsController < ApplicationController
|
class RecurringDonationsController < ApplicationController
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@data = QueryRecurringDonations.fetch_for_edit params[:id]
|
@data = QueryRecurringDonations.fetch_for_edit params[:id]
|
||||||
if @data && params[:t] == @data['recurring_donation']['edit_token']
|
if @data && params[:t] == @data['recurring_donation']['edit_token']
|
||||||
@data['change_amount_suggestions'] = CalculateSuggestedAmounts.calculate(@data['recurring_donation']['amount'])
|
@data['change_amount_suggestions'] = CalculateSuggestedAmounts.calculate(@data['recurring_donation']['amount'])
|
||||||
@data['miscellaneous_np_info'] = FetchMiscellaneousNpInfo.fetch(@data['nonprofit']['id'])
|
@data['miscellaneous_np_info'] = FetchMiscellaneousNpInfo.fetch(@data['nonprofit']['id'])
|
||||||
if @data['miscellaneous_np_info']['donate_again_url'].blank?
|
if @data['miscellaneous_np_info']['donate_again_url'].blank?
|
||||||
@data['miscellaneous_np_info']['donate_again_url'] = url_for(:controller => :nonprofits, :action=> :show, :id => @data['nonprofit']['id'], :only_path => false)
|
@data['miscellaneous_np_info']['donate_again_url'] = url_for(controller: :nonprofits, action: :show, id: @data['nonprofit']['id'], only_path: false)
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
flash[:notice] = "Unable to find donation. Please follow the exact link provided in your email"
|
flash[:notice] = 'Unable to find donation. Please follow the exact link provided in your email'
|
||||||
redirect_to root_url
|
redirect_to root_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -21,7 +22,7 @@ class RecurringDonationsController < ApplicationController
|
||||||
def destroy
|
def destroy
|
||||||
@data = QueryRecurringDonations.fetch_for_edit params[:id]
|
@data = QueryRecurringDonations.fetch_for_edit params[:id]
|
||||||
if params[:edit_token] != @data['recurring_donation']['edit_token']
|
if params[:edit_token] != @data['recurring_donation']['edit_token']
|
||||||
render json: {error: 'Invalid token'}, status: :unprocessable_entity
|
render json: { error: 'Invalid token' }, status: :unprocessable_entity
|
||||||
else
|
else
|
||||||
updated = UpdateRecurringDonations.cancel(params[:id], current_user ? current_user.email : @data['supporter']['email'])
|
updated = UpdateRecurringDonations.cancel(params[:id], current_user ? current_user.email : @data['supporter']['email'])
|
||||||
render json: updated
|
render json: updated
|
||||||
|
@ -37,7 +38,7 @@ class RecurringDonationsController < ApplicationController
|
||||||
data['recurring_donation'] = UpdateRecurringDonations.update_paydate(data['recurring_donation'], params[:paydate]) if params[:paydate]
|
data['recurring_donation'] = UpdateRecurringDonations.update_paydate(data['recurring_donation'], params[:paydate]) if params[:paydate]
|
||||||
render json: data, status: data.is_a?(ValidationError) ? :unprocessable_entity : :ok
|
render json: data, status: data.is_a?(ValidationError) ? :unprocessable_entity : :ok
|
||||||
else
|
else
|
||||||
render json: {error: 'Invalid token'}, status: :unprocessable_entity
|
render json: { error: 'Invalid token' }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,15 +46,14 @@ class RecurringDonationsController < ApplicationController
|
||||||
rd = RecurringDonation.where('id = ?', params[:id]).first
|
rd = RecurringDonation.where('id = ?', params[:id]).first
|
||||||
if rd && params[:edit_token] == rd['edit_token']
|
if rd && params[:edit_token] == rd['edit_token']
|
||||||
begin
|
begin
|
||||||
amount_response = UpdateRecurringDonations.update_amount(rd, params[:token], params[:amount])
|
amount_response = UpdateRecurringDonations.update_amount(rd, params[:token], params[:amount])
|
||||||
flash[:notice] = "Your recurring donation amount has been successfully changed to $#{(amount_response.amount/100).to_i}"
|
flash[:notice] = "Your recurring donation amount has been successfully changed to $#{(amount_response.amount / 100).to_i}"
|
||||||
render_json { amount_response }
|
render_json { amount_response }
|
||||||
rescue => e
|
rescue StandardError => e
|
||||||
render_json { raise e }
|
render_json { raise e }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render json: {error: 'Invalid token'}, status: :unprocessable_entity
|
render json: { error: 'Invalid token' }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class RolesController < ApplicationController
|
class RolesController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
before_filter :authenticate_nonprofit_admin!
|
before_action :authenticate_nonprofit_admin!
|
||||||
|
|
||||||
def create
|
def create
|
||||||
role = Role.create_for_nonprofit(params[:role][:name].to_sym, params[:role][:email], FetchNonprofit.with_params(params))
|
role = Role.create_for_nonprofit(params[:role][:name].to_sym, params[:role][:email], FetchNonprofit.with_params(params))
|
||||||
json_saved role, "User successfully added!"
|
json_saved role, 'User successfully added!'
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
role = Role.find(params[:id])
|
role = Role.find(params[:id])
|
||||||
roles = role.user.roles.where(host_id: params[:nonprofit_id], name: role.name)
|
roles = role.user.roles.where(host_id: params[:nonprofit_id], name: role.name)
|
||||||
unless roles.empty?
|
if roles.empty?
|
||||||
roles.destroy_all
|
render json: { error: "We couldn't find that admin" }, status: :unprocessable_entity
|
||||||
flash[:notice] = 'User successfully removed'
|
else
|
||||||
render json: {}
|
roles.destroy_all
|
||||||
else
|
flash[:notice] = 'User successfully removed'
|
||||||
render json: {:error => "We couldn't find that admin"}, :status => :unprocessable_entity
|
render json: {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class SettingsController < ApplicationController
|
class SettingsController < ApplicationController
|
||||||
include Controllers::NonprofitHelper
|
include Controllers::NonprofitHelper
|
||||||
|
|
||||||
helper_method :current_nonprofit_user?
|
helper_method :current_nonprofit_user?
|
||||||
before_filter :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if current_role?(:super_admin) && params[:nonprofit_id]
|
if current_role?(:super_admin) && params[:nonprofit_id]
|
||||||
@nonprofit = Nonprofit.find(params[:nonprofit_id])
|
@nonprofit = Nonprofit.find(params[:nonprofit_id])
|
||||||
elsif current_role?([:nonprofit_admin, :nonprofit_associate])
|
elsif current_role?(%i[nonprofit_admin nonprofit_associate])
|
||||||
@nonprofit = administered_nonprofit
|
@nonprofit = administered_nonprofit
|
||||||
end
|
|
||||||
|
|
||||||
if current_role?(:super_admin) && params[:user_id]
|
|
||||||
@user = User.find_by_id(params[:user_id])
|
|
||||||
elsif current_role?(:super_admin) && params[:user_email]
|
|
||||||
@user = User.find_by_email(params[:user_email])
|
|
||||||
else
|
|
||||||
@user = current_user
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@profile = @user.profile
|
@user = if current_role?(:super_admin) && params[:user_id]
|
||||||
|
User.find_by_id(params[:user_id])
|
||||||
|
elsif current_role?(:super_admin) && params[:user_email]
|
||||||
|
User.find_by_email(params[:user_email])
|
||||||
|
else
|
||||||
|
current_user
|
||||||
|
end
|
||||||
|
|
||||||
if @nonprofit
|
@profile = @user.profile
|
||||||
@miscellaneous_np_info = FetchMiscellaneousNpInfo.fetch(@nonprofit.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
if @nonprofit
|
||||||
|
@miscellaneous_np_info = FetchMiscellaneousNpInfo.fetch(@nonprofit.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class StaticController < ApplicationController
|
class StaticController < ApplicationController
|
||||||
layout 'layouts/static'
|
layout 'layouts/static'
|
||||||
|
@ -8,18 +10,17 @@ class StaticController < ApplicationController
|
||||||
|
|
||||||
def ccs
|
def ccs
|
||||||
ccs_method = !Settings.ccs ? 'local_tar_gz' : Settings.ccs.ccs_method
|
ccs_method = !Settings.ccs ? 'local_tar_gz' : Settings.ccs.ccs_method
|
||||||
if (ccs_method == 'local_tar_gz')
|
if ccs_method == 'local_tar_gz'
|
||||||
temp_file = "#{Rails.root}/tmp/#{Time.current.to_i}.tar.gz"
|
temp_file = "#{Rails.root}/tmp/#{Time.current.to_i}.tar.gz"
|
||||||
result = Kernel.system("git archive --format=tar.gz -o #{temp_file} HEAD")
|
result = Kernel.system("git archive --format=tar.gz -o #{temp_file} HEAD")
|
||||||
if result
|
if result
|
||||||
send_file(temp_file, :type => "application/gzip")
|
send_file(temp_file, type: 'application/gzip')
|
||||||
else
|
else
|
||||||
render :nothing => true, :status => 500
|
render body: nil, status: 500
|
||||||
end
|
end
|
||||||
elsif (ccs_method == 'github')
|
elsif ccs_method == 'github'
|
||||||
git_hash = File.read("#{Rails.root}/CCS_HASH")
|
git_hash = File.read("#{Rails.root}/CCS_HASH")
|
||||||
redirect_to "https://github.com/#{Settings.ccs.options.account}/#{Settings.ccs.options.repo}/tree/#{git_hash}"
|
redirect_to "https://github.com/#{Settings.ccs.options.account}/#{Settings.ccs.options.repo}/tree/#{git_hash}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class SuperAdminsController < ApplicationController
|
class SuperAdminsController < ApplicationController
|
||||||
layout "layouts/page"
|
layout 'layouts/page'
|
||||||
|
|
||||||
before_filter :authenticate_super_associate!
|
before_action :authenticate_super_associate!
|
||||||
|
|
||||||
def index
|
def index; end
|
||||||
end
|
|
||||||
|
|
||||||
def search_nonprofits
|
def search_nonprofits
|
||||||
render json: QueryNonprofits.for_admin(params)
|
render json: QueryNonprofits.for_admin(params)
|
||||||
|
@ -25,39 +26,37 @@ class SuperAdminsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def resend_user_confirmation
|
def resend_user_confirmation
|
||||||
ParamValidation.new(params || {}, {
|
ParamValidation.new(params || {},
|
||||||
profile_id: {:required => true, is_integer: true}
|
profile_id: { required: true, is_integer: true })
|
||||||
})
|
|
||||||
|
|
||||||
profile = Profile.includes(:user).where('id = ?', params[:profile_id]).first
|
profile = Profile.includes(:user).where('id = ?', params[:profile_id]).first
|
||||||
unless (profile.user)
|
unless profile.user
|
||||||
raise ArgumentError.new("#{params[:profile_id]} is a profile without a valid user")
|
raise ArgumentError, "#{params[:profile_id]} is a profile without a valid user"
|
||||||
end
|
end
|
||||||
|
|
||||||
profile.user.send_confirmation_instructions
|
profile.user.send_confirmation_instructions
|
||||||
|
|
||||||
render json: {status: :ok}
|
render json: { status: :ok }
|
||||||
end
|
end
|
||||||
|
|
||||||
def recurring_donations_without_cards
|
def recurring_donations_without_cards
|
||||||
odd_donations = QueryRecurringDonations::recurring_donations_without_cards
|
odd_donations = QueryRecurringDonations.recurring_donations_without_cards
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.csv do
|
format.csv do
|
||||||
csv_out = CSV.generate { |csv|
|
csv_out = CSV.generate do |csv|
|
||||||
csv << ['supporter id', 'recurring donation id', 'rd created date', 'rd modified', 'donation id', 'donation card id',
|
csv << ['supporter id', 'recurring donation id', 'rd created date', 'rd modified', 'donation id', 'donation card id',
|
||||||
'edit_token', 'nonprofit id',
|
'edit_token', 'nonprofit id',
|
||||||
'last charge succeeded id', 'last charge succeeded created at', 'last charge attempted id', 'last charge attempted created at', 'amount']
|
'last charge succeeded id', 'last charge succeeded created at', 'last charge attempted id', 'last charge attempted created at', 'amount']
|
||||||
|
|
||||||
odd_donations.each { |rd|
|
odd_donations.each do |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,
|
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.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]
|
rd.amount]
|
||||||
}
|
end
|
||||||
}
|
end
|
||||||
|
|
||||||
|
send_data(csv_out, filename: "recurring_donations_without_cards-#{Time.now.to_date}.csv")
|
||||||
send_data(csv_out, filename: "recurring_donations_without_cards-#{Time.now.to_date()}.csv")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,17 +64,13 @@ class SuperAdminsController < ApplicationController
|
||||||
def export_supporters_with_rds
|
def export_supporters_with_rds
|
||||||
np = params[:np]
|
np = params[:np]
|
||||||
ids = params[:ids]
|
ids = params[:ids]
|
||||||
results = QuerySupporters.for_export(np, {ids: ids})
|
results = QuerySupporters.for_export(np, ids: ids)
|
||||||
results[0].push("Management URLS")
|
results[0].push('Management URLS')
|
||||||
results.drop(1).each {|row|
|
results.drop(1).each do |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")
|
rds = Supporter.includes(:recurring_donations).find(row.last).recurring_donations.select(&:active).map { |rd| "* #{root_url}recurring_donations/#{rd.id}/edit?t=#{rd.edit_token}" }.join("\n")
|
||||||
row.push(rds)
|
row.push(rds)
|
||||||
}
|
end
|
||||||
|
|
||||||
|
send_data(Format::Csv.from_vectors(results), filename: 'supporters_with_multiple_donations.csv')
|
||||||
send_data(Format::Csv.from_vectors(results), filename: "supporters_with_multiple_donations.csv")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,29 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class TicketLevelsController < ApplicationController
|
class TicketLevelsController < ApplicationController
|
||||||
include Controllers::EventHelper
|
include Controllers::EventHelper
|
||||||
|
|
||||||
before_filter :authenticate_event_editor!, :except => [:index, :show]
|
before_action :authenticate_event_editor!, except: %i[index show]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
ev_id = current_event.id
|
ev_id = current_event.id
|
||||||
render json: {data: QueryTicketLevels.with_event_id(ev_id, current_role?(:event_editor, ev_id) || current_role?(:super_admin) || current_role?(:nonprofit_admin, current_event.nonprofit_id))}
|
render json: { data: QueryTicketLevels.with_event_id(ev_id, current_role?(:event_editor, ev_id) || current_role?(:super_admin) || current_role?(:nonprofit_admin, current_event.nonprofit_id)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
render json: current_ticket_level
|
render json: current_ticket_level
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
ticket_level = current_event.ticket_levels.create params[:ticket_level]
|
ticket_level = current_event.ticket_levels.create params[:ticket_level]
|
||||||
json_saved ticket_level, 'Ticket level created!'
|
json_saved ticket_level, 'Ticket level created!'
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
current_ticket_level.update_attributes params[:ticket_level]
|
current_ticket_level.update_attributes params[:ticket_level]
|
||||||
json_saved current_ticket_level, 'Ticket level updated'
|
json_saved current_ticket_level, 'Ticket level updated'
|
||||||
end
|
end
|
||||||
|
|
||||||
# put /nonprofits/:nonprofit_id/events/:event_id/ticket_levels/update_order
|
# put /nonprofits/:nonprofit_id/events/:event_id/ticket_levels/update_order
|
||||||
# Pass in {data: [{id: 1, order: 1}]}
|
# Pass in {data: [{id: 1, order: 1}]}
|
||||||
|
@ -31,14 +33,13 @@ class TicketLevelsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
current_ticket_level.destroy
|
current_ticket_level.destroy
|
||||||
render json: {}
|
render json: {}
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def current_ticket_level
|
|
||||||
@ticket_level ||= current_event.ticket_levels.find params[:id]
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def current_ticket_level
|
||||||
|
@ticket_level ||= current_event.ticket_levels.find params[:id]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class TicketsController < ApplicationController
|
class TicketsController < ApplicationController
|
||||||
include Controllers::EventHelper
|
include Controllers::EventHelper
|
||||||
|
|
||||||
helper_method :current_event_admin?, :current_event_editor?
|
helper_method :current_event_admin?, :current_event_editor?
|
||||||
before_filter :authenticate_event_editor!, :except => [:create, :add_note]
|
before_action :authenticate_event_editor!, except: %i[create add_note]
|
||||||
before_filter :authenticate_nonprofit_user!, only: [:delete_card_for_ticket]
|
before_action :authenticate_nonprofit_user!, only: [:delete_card_for_ticket]
|
||||||
|
|
||||||
# post /nonprofits/:nonprofit_id/events/:event_id/tickets
|
# post /nonprofits/:nonprofit_id/events/:event_id/tickets
|
||||||
def create
|
def create
|
||||||
authenticate_event_editor! if params[:kind] == 'offsite'
|
authenticate_event_editor! if params[:kind] == 'offsite'
|
||||||
render_json do
|
render_json do
|
||||||
params[:current_user] = current_user
|
params[:current_user] = current_user
|
||||||
|
@ -18,29 +20,30 @@ class TicketsController < ApplicationController
|
||||||
def update
|
def update
|
||||||
params[:ticket][:ticket_id] = params[:id]
|
params[:ticket][:ticket_id] = params[:id]
|
||||||
params[:ticket][:event_id] = params[:event_id]
|
params[:ticket][:event_id] = params[:event_id]
|
||||||
render_json{ UpdateTickets.update(params[:ticket], current_user) }
|
render_json { UpdateTickets.update(params[:ticket], current_user) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Attendees dashboard
|
# Attendees dashboard
|
||||||
# get /nonprofits/:nonprofit_id/events/:event_id/tickets
|
# get /nonprofits/:nonprofit_id/events/:event_id/tickets
|
||||||
def index
|
def index
|
||||||
@panels_layout = true
|
@panels_layout = true
|
||||||
@nonprofit = current_nonprofit
|
@nonprofit = current_nonprofit
|
||||||
@event = current_event
|
@event = current_event
|
||||||
respond_to do |format|
|
|
||||||
format.html
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
format.csv do
|
format.csv do
|
||||||
file_date = Date.today.strftime("%m-%d-%Y")
|
file_date = Date.today.strftime('%m-%d-%Y')
|
||||||
filename = "tickets-#{file_date}"
|
filename = "tickets-#{file_date}"
|
||||||
@tickets = QueryTickets.for_export(@event.id, params)
|
@tickets = QueryTickets.for_export(@event.id, params)
|
||||||
send_data(Format::Csv.from_vectors(@tickets), filename: "#{filename}.csv")
|
send_data(Format::Csv.from_vectors(@tickets), filename: "#{filename}.csv")
|
||||||
end
|
end
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
render json: QueryTickets.attendees_list(@event.id, params)
|
render json: QueryTickets.attendees_list(@event.id, params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT nonprofits/:nonprofit_id/events/:event_id/tickets/:id/add_note
|
# PUT nonprofits/:nonprofit_id/events/:event_id/tickets/:id/add_note
|
||||||
def add_note
|
def add_note
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class Users::ConfirmationsController < Devise::ConfirmationsController
|
class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||||
|
# get /confirm
|
||||||
|
def show
|
||||||
|
@user = User.confirm_by_token(params[:confirmation_token])
|
||||||
|
|
||||||
# get /confirm
|
if !@user.auto_generated || !@user.valid?
|
||||||
def show
|
flash[:notice] = 'We successfully confirmed your account'
|
||||||
@user = User.confirm_by_token(params[:confirmation_token])
|
redirect_to session[:donor_signup_url] || root_url
|
||||||
|
else
|
||||||
if !@user.auto_generated || !@user.valid?
|
|
||||||
flash[:notice] = "We successfully confirmed your account"
|
|
||||||
redirect_to session[:donor_signup_url] || root_url
|
|
||||||
else
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def exists
|
def exists
|
||||||
render json: User.find_by_email(params[:email])
|
render json: User.find_by_email(params[:email])
|
||||||
end
|
end
|
||||||
|
|
||||||
# post /confirm
|
# post /confirm
|
||||||
# set account password
|
# set account password
|
||||||
def confirm
|
def confirm
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
|
|
||||||
if @user.valid? && @user.update_attributes(params[:user].except(:confirmation_token))
|
if @user.valid? && @user.update_attributes(params[:user].except(:confirmation_token))
|
||||||
flash[:notice] = "Your account is all set!"
|
flash[:notice] = 'Your account is all set!'
|
||||||
sign_in @user
|
sign_in @user
|
||||||
redirect_to session[:donor_signup_url] || root_url
|
redirect_to session[:donor_signup_url] || root_url
|
||||||
else
|
else
|
||||||
session[:donor_signup_url] || root_url
|
session[:donor_signup_url] || root_url
|
||||||
#render :action => "show", :layout => 'layouts/embed'
|
# render :action => "show", :layout => 'layouts/embed'
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def is_confirmed
|
|
||||||
render json: {is_confirmed: User.find(params[:user_id]).confirmed?}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_confirmed
|
||||||
|
render json: { is_confirmed: User.find(params[:user_id]).confirmed? }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class Users::RegistrationsController < Devise::RegistrationsController
|
class Users::RegistrationsController < Devise::RegistrationsController
|
||||||
respond_to :html, :json
|
respond_to :html, :json
|
||||||
|
@ -12,9 +14,9 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
||||||
user = User.register_donor!(params[:user])
|
user = User.register_donor!(params[:user])
|
||||||
if user.save
|
if user.save
|
||||||
sign_in user
|
sign_in user
|
||||||
render :json => user
|
render json: user
|
||||||
else
|
else
|
||||||
render :json => user.errors.full_messages, :status => :unprocessable_entity
|
render json: user.errors.full_messages, status: :unprocessable_entity
|
||||||
clean_up_passwords(user)
|
clean_up_passwords(user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -33,7 +35,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
||||||
errs = current_user.errors.full_messages
|
errs = current_user.errors.full_messages
|
||||||
else
|
else
|
||||||
success = false
|
success = false
|
||||||
errs = {:password => :incorrect}
|
errs = { password: :incorrect }
|
||||||
end
|
end
|
||||||
|
|
||||||
if success
|
if success
|
||||||
|
@ -43,10 +45,10 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
||||||
flash[:notice] = 'Account updated!'
|
flash[:notice] = 'Account updated!'
|
||||||
end
|
end
|
||||||
|
|
||||||
sign_in(current_user, :bypass => true)
|
sign_in(current_user, bypass: true)
|
||||||
render :json => current_user
|
render json: current_user
|
||||||
else
|
else
|
||||||
render :json => {:errors => errs}, :status => :unprocessable_entity
|
render json: { errors: errs }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,37 +1,36 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class Users::SessionsController < Devise::SessionsController
|
class Users::SessionsController < Devise::SessionsController
|
||||||
layout 'layouts/apified', only: :new
|
layout 'layouts/apified', only: :new
|
||||||
|
respond_to :json, only: :new
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@theme = 'minimal'
|
@theme = 'minimal'
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@theme = 'minimal'
|
@theme = 'minimal'
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json {
|
format.json do
|
||||||
warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
|
warden.authenticate!(scope: resource_name, recall: "#{controller_path}#new")
|
||||||
render :status => 200, :json => { :status => "Success" }
|
render status: 200, json: { status: 'Success' }
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
# post /users/confirm_auth
|
|
||||||
# A simple action to confirm an entered password for a user who is already signed in
|
|
||||||
def confirm_auth
|
|
||||||
if current_user.valid_password?(params[:password])
|
|
||||||
tok = SecureRandom.uuid
|
|
||||||
session[:pw_token] = tok
|
|
||||||
session[:pw_timestamp] = Time.current.to_s
|
|
||||||
render json: {token: tok}, status: :ok
|
|
||||||
else
|
|
||||||
render json: ["Incorrect password. Please enter your #{Settings.general.name} %> password."], status: :unprocessable_entity
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# post /users/confirm_auth
|
||||||
|
# A simple action to confirm an entered password for a user who is already signed in
|
||||||
|
def confirm_auth
|
||||||
|
if current_user.valid_password?(params[:password])
|
||||||
|
tok = SecureRandom.uuid
|
||||||
|
session[:pw_token] = tok
|
||||||
|
session[:pw_timestamp] = Time.current.to_s
|
||||||
|
render json: { token: tok }, status: :ok
|
||||||
|
else
|
||||||
|
render json: ["Incorrect password. Please enter your #{Settings.general.name} %> password."], status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,70 +1,71 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
|
def resource_name
|
||||||
|
:user
|
||||||
|
end
|
||||||
|
|
||||||
def resource_name
|
def resource
|
||||||
:user
|
@resource ||= User.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def resource
|
def devise_mapping
|
||||||
@resource ||= User.new
|
@devise_mapping ||= Devise.mappings[:user]
|
||||||
end
|
end
|
||||||
|
|
||||||
def devise_mapping
|
def print_currency(cents, unit = 'EUR', sign = true)
|
||||||
@devise_mapping ||= Devise.mappings[:user]
|
dollars = cents.to_f / 100.0
|
||||||
end
|
dollars = number_to_currency(dollars, unit: unit.to_s, precision: dollars.round == dollars ? 0 : 2)
|
||||||
|
dollars = dollars[1..-1] unless sign
|
||||||
|
dollars
|
||||||
|
end
|
||||||
|
|
||||||
def print_currency(cents, unit="EUR", sign=true)
|
def print_percent(rate)
|
||||||
|
(rate.to_f * 100).round(2)
|
||||||
|
end
|
||||||
|
|
||||||
dollars = cents.to_f / 100.0
|
## Dates
|
||||||
dollars = number_to_currency(dollars, :unit => "#{unit}", :precision => (dollars.round == dollars) ? 0 : 2)
|
|
||||||
dollars = dollars[1..-1] if !sign
|
|
||||||
dollars
|
|
||||||
end
|
|
||||||
|
|
||||||
def print_percent(rate)
|
def simple_date(date_object, timezone = nil)
|
||||||
(rate.to_f * 100).round(2)
|
return '' if date_object.nil?
|
||||||
end
|
|
||||||
|
|
||||||
## Dates
|
date_object = date_object.in_time_zone(timezone) if timezone
|
||||||
|
date_object.strftime('%m/%d/%Y')
|
||||||
|
end
|
||||||
|
|
||||||
def simple_date date_object, timezone=nil
|
def simple_time(time_object, timezone = nil)
|
||||||
return '' if date_object.nil?
|
return '' if time_object.nil?
|
||||||
date_object = date_object.in_time_zone(timezone) if timezone
|
|
||||||
date_object.strftime("%m/%d/%Y")
|
|
||||||
end
|
|
||||||
|
|
||||||
def simple_time time_object, timezone=nil
|
time_object = time_object.in_time_zone(timezone) if timezone
|
||||||
return '' if time_object.nil?
|
time_object.strftime('%l:%M%P')
|
||||||
time_object = time_object.in_time_zone(timezone) if timezone
|
end
|
||||||
time_object.strftime("%l:%M%P")
|
|
||||||
end
|
|
||||||
|
|
||||||
def readable_date date_object
|
def readable_date(date_object)
|
||||||
date_object.strftime("%B %d, %Y")
|
date_object.strftime('%B %d, %Y')
|
||||||
end
|
end
|
||||||
|
|
||||||
def date_and_time date_object, timezone=nil
|
def date_and_time(date_object, timezone = nil)
|
||||||
date_object = date_object.in_time_zone(timezone) if timezone
|
date_object = date_object.in_time_zone(timezone) if timezone
|
||||||
date_object.strftime("%m/%d/%Y %I:%M%P (%Z)")
|
date_object.strftime('%m/%d/%Y %I:%M%P (%Z)')
|
||||||
end
|
end
|
||||||
|
|
||||||
def us_states
|
def us_states
|
||||||
[ ['Alabama', 'AL'], ['Alaska', 'AK'], ['Arizona', 'AZ'], ['Arkansas', 'AR'], ['California', 'CA'], ['Colorado', 'CO'], ['Connecticut', 'CT'], ['Delaware', 'DE'], ['District of Columbia', 'DC'], ['Florida', 'FL'], ['Georgia', 'GA'], ['Hawaii', 'HI'], ['Idaho', 'ID'], ['Illinois', 'IL'], ['Indiana', 'IN'], ['Iowa', 'IA'], ['Kansas', 'KS'], ['Kentucky', 'KY'], ['Louisiana', 'LA'], ['Maine', 'ME'], ['Maryland', 'MD'], ['Massachusetts', 'MA'], ['Michigan', 'MI'], ['Minnesota', 'MN'], ['Mississippi', 'MS'], ['Missouri', 'MO'], ['Montana', 'MT'], ['Nebraska', 'NE'], ['Nevada', 'NV'], ['New Hampshire', 'NH'], ['New Jersey', 'NJ'], ['New Mexico', 'NM'], ['New York', 'NY'], ['North Carolina', 'NC'], ['North Dakota', 'ND'], ['Ohio', 'OH'], ['Oklahoma', 'OK'], ['Oregon', 'OR'], ['Pennsylvania', 'PA'], ['Puerto Rico', 'PR'], ['Rhode Island', 'RI'], ['South Carolina', 'SC'], ['South Dakota', 'SD'], ['Tennessee', 'TN'], ['Texas', 'TX'], ['Utah', 'UT'], ['Vermont', 'VT'], ['Virginia', 'VA'], ['Washington', 'WA'], ['West Virginia', 'WV'], ['Wisconsin', 'WI'], ['Wyoming', 'WY'] ]
|
[%w[Alabama AL], %w[Alaska AK], %w[Arizona AZ], %w[Arkansas AR], %w[California CA], %w[Colorado CO], %w[Connecticut CT], %w[Delaware DE], ['District of Columbia', 'DC'], %w[Florida FL], %w[Georgia GA], %w[Hawaii HI], %w[Idaho ID], %w[Illinois IL], %w[Indiana IN], %w[Iowa IA], %w[Kansas KS], %w[Kentucky KY], %w[Louisiana LA], %w[Maine ME], %w[Maryland MD], %w[Massachusetts MA], %w[Michigan MI], %w[Minnesota MN], %w[Mississippi MS], %w[Missouri MO], %w[Montana MT], %w[Nebraska NE], %w[Nevada NV], ['New Hampshire', 'NH'], ['New Jersey', 'NJ'], ['New Mexico', 'NM'], ['New York', 'NY'], ['North Carolina', 'NC'], ['North Dakota', 'ND'], %w[Ohio OH], %w[Oklahoma OK], %w[Oregon OR], %w[Pennsylvania PA], ['Puerto Rico', 'PR'], ['Rhode Island', 'RI'], ['South Carolina', 'SC'], ['South Dakota', 'SD'], %w[Tennessee TN], %w[Texas TX], %w[Utah UT], %w[Vermont VT], %w[Virginia VA], %w[Washington WA], ['West Virginia', 'WV'], %w[Wisconsin WI], %w[Wyoming WY]]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Append a parameter to a URL string
|
# Append a parameter to a URL string
|
||||||
def url_with_param(param, val, url)
|
def url_with_param(param, val, url)
|
||||||
url + (url.include?('?') ? '&' : '?') + param + '=' + val
|
url + (url.include?('?') ? '&' : '?') + param + '=' + val
|
||||||
end
|
end
|
||||||
|
|
||||||
# Prepend 'http://' if it is not present in a given url
|
|
||||||
# Used for linking to nonprofit-provided website
|
|
||||||
def add_http url
|
|
||||||
if url[/^http:\/\//] || url[/^https:\/\//]
|
|
||||||
url
|
|
||||||
else
|
|
||||||
'http://' + url
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
# Prepend 'http://' if it is not present in a given url
|
||||||
|
# Used for linking to nonprofit-provided website
|
||||||
|
def add_http(url)
|
||||||
|
if url[%r{^http://}] || url[%r{^https://}]
|
||||||
|
url
|
||||||
|
else
|
||||||
|
'http://' + url
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,23 +1,24 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module CardHelper
|
module CardHelper
|
||||||
|
def brand_file(brand)
|
||||||
|
if brand == 'Visa' || brand == 'visa' || brand == 'VISA'
|
||||||
|
'visa'
|
||||||
|
elsif brand == 'American Express' || brand == 'amex'
|
||||||
|
'amex'
|
||||||
|
elsif brand == 'Discover' || brand == 'Discover Card' || brand == 'discover'
|
||||||
|
'discover'
|
||||||
|
elsif brand == 'MasterCard' || brand == 'Mastercard' || brand == 'mastercard'
|
||||||
|
'mastercard'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def brand_file(brand)
|
def current_card
|
||||||
if brand == 'Visa' || brand == 'visa' || brand == 'VISA'
|
current_user&.profile&.card
|
||||||
'visa'
|
end
|
||||||
elsif brand == 'American Express' || brand == 'amex'
|
|
||||||
'amex'
|
|
||||||
elsif brand == 'Discover' || brand == 'Discover Card' || brand == 'discover'
|
|
||||||
'discover'
|
|
||||||
elsif brand == 'MasterCard' || brand == 'Mastercard' || brand == 'mastercard'
|
|
||||||
'mastercard'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def current_card
|
def expiration_years
|
||||||
current_user && current_user.profile.card
|
(0..15).map { |n| (Date.today + n.years).year }
|
||||||
end
|
end
|
||||||
|
|
||||||
def expiration_years
|
|
||||||
(0..15).map{|n| (Date.today + n.years).year}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module DeviseHelper
|
module DeviseHelper
|
||||||
def devise_error_messages!
|
def devise_error_messages!
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module NonprofitsHelper
|
module NonprofitsHelper
|
||||||
|
def managed_npo_card_json
|
||||||
def managed_npo_card_json
|
if current_user
|
||||||
if current_user
|
if params[:nonprofit_id] && current_role?(:super_admin)
|
||||||
if params[:nonprofit_id] && current_role?(:super_admin)
|
raw(Nonprofit.find(params[:nonprofit_id]).active_card.to_json)
|
||||||
raw(Nonprofit.find(params[:nonprofit_id]).active_card.to_json)
|
elsif administered_nonprofit&.active_card
|
||||||
elsif administered_nonprofit && administered_nonprofit.active_card
|
raw(administered_nonprofit.active_card.to_json)
|
||||||
raw(administered_nonprofit.active_card.to_json)
|
end
|
||||||
end
|
else
|
||||||
else
|
'undefined'
|
||||||
'undefined'
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module OnboardHelper
|
module OnboardHelper
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module PricingHelper
|
module PricingHelper
|
||||||
private
|
private
|
||||||
def nonprofit_email
|
|
||||||
return nil if @nonprofit.nil?
|
def nonprofit_email
|
||||||
@nonprofit.email || GetData.chain(@nonprofit.users.first, :email)
|
return nil if @nonprofit.nil?
|
||||||
end
|
|
||||||
|
@nonprofit.email || GetData.chain(@nonprofit.users.first, :email)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
module ProfilesHelper
|
module ProfilesHelper
|
||||||
|
def get_shortened_name(name)
|
||||||
def get_shortened_name name
|
|
||||||
if name
|
if name
|
||||||
name.length > 18 ? name[0..18] + '...' : name
|
name.length > 18 ? name[0..18] + '...' : name
|
||||||
else
|
else
|
||||||
'Your Account'
|
'Your Account'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
6
app/jobs/application_job.rb
Normal file
6
app/jobs/application_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
|
|
||||||
|
class ApplicationJob < ActiveJob::Base
|
||||||
|
end
|
|
@ -1,6 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class AdminMailer < BaseMailer
|
class AdminMailer < BaseMailer
|
||||||
|
|
||||||
# Subject can be set in your I18n file at config/locales/en.yml
|
# Subject can be set in your I18n file at config/locales/en.yml
|
||||||
# with the following lookup:
|
# with the following lookup:
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class BaseMailer < ActionMailer::Base
|
class BaseMailer < ActionMailer::Base
|
||||||
include Roadie::Rails::Automatic
|
include Roadie::Rails::Automatic
|
||||||
include Devise::Controllers::UrlHelpers
|
include Devise::Controllers::UrlHelpers
|
||||||
add_template_helper(ApplicationHelper)
|
add_template_helper(ApplicationHelper)
|
||||||
default :from => Settings.mailer.default_from
|
default from: Settings.mailer.default_from
|
||||||
layout 'email'
|
layout 'email'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class BillingSubscriptionMailer < BaseMailer
|
class BillingSubscriptionMailer < BaseMailer
|
||||||
|
|
||||||
def failed_notice(np_id)
|
def failed_notice(np_id)
|
||||||
@nonprofit = Nonprofit.find(np_id)
|
@nonprofit = Nonprofit.find(np_id)
|
||||||
@billing_subscription = @nonprofit.billing_subscription
|
@billing_subscription = @nonprofit.billing_subscription
|
||||||
@card = @nonprofit.active_card
|
@card = @nonprofit.active_card
|
||||||
@billing_plan = @billing_subscription.billing_plan
|
@billing_plan = @billing_subscription.billing_plan
|
||||||
@emails = QueryUsers.all_nonprofit_user_emails(@nonprofit.id)
|
@emails = QueryUsers.all_nonprofit_user_emails(@nonprofit.id)
|
||||||
mail(to: @emails, subject: "Action Needed, Please Update Your #{Settings.general.name} Account")
|
mail(to: @emails, subject: "Action Needed, Please Update Your #{Settings.general.name} Account")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class CampaignMailer < BaseMailer
|
class CampaignMailer < BaseMailer
|
||||||
|
def creation_followup(campaign)
|
||||||
|
@creator_profile = campaign.profile
|
||||||
|
@campaign = campaign
|
||||||
|
mail(to: @creator_profile.user.email, subject: "Get your new campaign rolling! (via #{Settings.general.name})")
|
||||||
|
end
|
||||||
|
|
||||||
def creation_followup(campaign)
|
def federated_creation_followup(campaign)
|
||||||
@creator_profile = campaign.profile
|
@creator_profile = campaign.profile
|
||||||
@campaign = campaign
|
@campaign = campaign
|
||||||
mail(:to => @creator_profile.user.email, :subject => "Get your new campaign rolling! (via #{Settings.general.name})")
|
mail(to: @creator_profile.user.email, subject: "Get your new campaign rolling! (via #{Settings.general.name})")
|
||||||
end
|
end
|
||||||
|
|
||||||
def federated_creation_followup(campaign)
|
|
||||||
@creator_profile = campaign.profile
|
|
||||||
@campaign = campaign
|
|
||||||
mail(:to => @creator_profile.user.email, :subject => "Get your new campaign rolling! (via #{Settings.general.name})")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,36 +1,38 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class DonationMailer < BaseMailer
|
class DonationMailer < BaseMailer
|
||||||
|
# Used for both one-time and recurring donations
|
||||||
# Used for both one-time and recurring donations
|
|
||||||
# can pass in array of admin user_ids to send to only some -- if falsey/empty, will send to all
|
# can pass in array of admin user_ids to send to only some -- if falsey/empty, will send to all
|
||||||
def donor_payment_notification(donation_id, locale=I18n.locale)
|
def donor_payment_notification(donation_id, locale = I18n.locale)
|
||||||
@donation = Donation.find(donation_id)
|
@donation = Donation.find(donation_id)
|
||||||
@nonprofit = @donation.nonprofit
|
@nonprofit = @donation.nonprofit
|
||||||
if @donation.campaign && ActionView::Base.full_sanitizer.sanitize(@donation.campaign.receipt_message).present?
|
if @donation.campaign && ActionView::Base.full_sanitizer.sanitize(@donation.campaign.receipt_message).present?
|
||||||
@thank_you_note = @donation.campaign.receipt_message
|
@thank_you_note = @donation.campaign.receipt_message
|
||||||
else
|
else
|
||||||
@thank_you_note = Format::Interpolate.with_hash(@nonprofit.thank_you_note, {'NAME' => @donation.supporter.name})
|
@thank_you_note = Format::Interpolate.with_hash(@nonprofit.thank_you_note, 'NAME' => @donation.supporter.name)
|
||||||
end
|
end
|
||||||
@charge = @donation.charges.last
|
@charge = @donation.charges.last
|
||||||
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
||||||
from = Format::Name.email_from_np(@nonprofit.name)
|
from = Format::Name.email_from_np(@nonprofit.name)
|
||||||
I18n.with_locale(locale) do
|
I18n.with_locale(locale) do
|
||||||
mail(
|
mail(
|
||||||
to: @donation.supporter.email,
|
to: @donation.supporter.email,
|
||||||
from: from,
|
from: from,
|
||||||
reply_to: reply_to,
|
reply_to: reply_to,
|
||||||
subject: I18n.t('mailer.donations.donor_direct_debit_notification.subject', nonprofit_name: @nonprofit.name))
|
subject: I18n.t('mailer.donations.donor_direct_debit_notification.subject', nonprofit_name: @nonprofit.name)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def donor_direct_debit_notification(donation_id, locale=I18n.locale)
|
def donor_direct_debit_notification(donation_id, locale = I18n.locale)
|
||||||
@donation = Donation.find(donation_id)
|
@donation = Donation.find(donation_id)
|
||||||
@nonprofit = @donation.nonprofit
|
@nonprofit = @donation.nonprofit
|
||||||
|
|
||||||
if @donation.campaign && ActionView::Base.full_sanitizer.sanitize(@donation.campaign.receipt_message).present?
|
if @donation.campaign && ActionView::Base.full_sanitizer.sanitize(@donation.campaign.receipt_message).present?
|
||||||
@thank_you_note = @donation.campaign.receipt_message
|
@thank_you_note = @donation.campaign.receipt_message
|
||||||
else
|
else
|
||||||
@thank_you_note = Format::Interpolate.with_hash(@nonprofit.thank_you_note, {'NAME' => @donation.supporter.name})
|
@thank_you_note = Format::Interpolate.with_hash(@nonprofit.thank_you_note, 'NAME' => @donation.supporter.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
||||||
|
@ -45,87 +47,86 @@ class DonationMailer < BaseMailer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Used for both one-time and recurring donations
|
# Used for both one-time and recurring donations
|
||||||
def nonprofit_payment_notification(donation_id, user_id=nil)
|
def nonprofit_payment_notification(donation_id, user_id = nil)
|
||||||
@donation = Donation.find(donation_id)
|
@donation = Donation.find(donation_id)
|
||||||
@charge = @donation.charges.last
|
@charge = @donation.charges.last
|
||||||
@nonprofit = @donation.nonprofit
|
@nonprofit = @donation.nonprofit
|
||||||
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, @donation.campaign ? 'notify_campaigns' : 'notify_payments')
|
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, @donation.campaign ? 'notify_campaigns' : 'notify_payments')
|
||||||
if user_id
|
if user_id
|
||||||
em = User.find(user_id).email
|
em = User.find(user_id).email
|
||||||
# return unless @emails.include?(em)
|
# return unless @emails.include?(em)
|
||||||
@emails = [em]
|
@emails = [em]
|
||||||
end
|
end
|
||||||
mail(to: @emails, subject: "Donation receipt for #{@donation.supporter.name}")
|
mail(to: @emails, subject: "Donation receipt for #{@donation.supporter.name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def nonprofit_failed_recurring_donation(donation_id)
|
def nonprofit_failed_recurring_donation(donation_id)
|
||||||
@donation = Donation.find(donation_id)
|
@donation = Donation.find(donation_id)
|
||||||
@nonprofit = @donation.nonprofit
|
@nonprofit = @donation.nonprofit
|
||||||
@charge = @donation.charges.last
|
@charge = @donation.charges.last
|
||||||
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, @donation.campaign ? 'notify_campaigns' : 'notify_payments')
|
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, @donation.campaign ? 'notify_campaigns' : 'notify_payments')
|
||||||
mail(to: @emails, subject: "Recurring donation payment failure for #{@donation.supporter.name || @donation.supporter.email}")
|
mail(to: @emails, subject: "Recurring donation payment failure for #{@donation.supporter.name || @donation.supporter.email}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def donor_failed_recurring_donation(donation_id)
|
def donor_failed_recurring_donation(donation_id)
|
||||||
@donation = Donation.find(donation_id)
|
@donation = Donation.find(donation_id)
|
||||||
@nonprofit = @donation.nonprofit
|
@nonprofit = @donation.nonprofit
|
||||||
@charge = @donation.charges.last
|
@charge = @donation.charges.last
|
||||||
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
||||||
from = Format::Name.email_from_np(@nonprofit.name)
|
from = Format::Name.email_from_np(@nonprofit.name)
|
||||||
mail(to: @donation.supporter.email, from: from, reply_to: reply_to, subject: "Donation payment failure for #{@nonprofit.name}")
|
mail(to: @donation.supporter.email, from: from, reply_to: reply_to, subject: "Donation payment failure for #{@nonprofit.name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def nonprofit_recurring_donation_cancellation(donation_id)
|
def nonprofit_recurring_donation_cancellation(donation_id)
|
||||||
@donation = Donation.find(donation_id)
|
@donation = Donation.find(donation_id)
|
||||||
@nonprofit = @donation.nonprofit
|
@nonprofit = @donation.nonprofit
|
||||||
@charge = @donation.charges.last
|
@charge = @donation.charges.last
|
||||||
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, @donation.campaign ? 'notify_campaigns' : 'notify_payments')
|
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, @donation.campaign ? 'notify_campaigns' : 'notify_payments')
|
||||||
mail(to: @emails, subject: "Recurring donation cancelled for #{@donation.supporter.name || @donation.supporter.email}")
|
mail(to: @emails, subject: "Recurring donation cancelled for #{@donation.supporter.name || @donation.supporter.email}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def nonprofit_recurring_donation_change_amount(donation_id, previous_amount=nil)
|
def nonprofit_recurring_donation_change_amount(donation_id, previous_amount = nil)
|
||||||
@donation = RecurringDonation.find(donation_id).donation
|
@donation = RecurringDonation.find(donation_id).donation
|
||||||
@nonprofit = @donation.nonprofit
|
@nonprofit = @donation.nonprofit
|
||||||
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_recurring_donations')
|
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_recurring_donations')
|
||||||
@previous_amount = previous_amount
|
@previous_amount = previous_amount
|
||||||
mail(to: @emails, subject:"Recurring donation amount changed for #{@donation.supporter.name || @donation.supporter.email}")
|
mail(to: @emails, subject: "Recurring donation amount changed for #{@donation.supporter.name || @donation.supporter.email}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def donor_recurring_donation_change_amount(donation_id, previous_amount=nil)
|
def donor_recurring_donation_change_amount(donation_id, previous_amount = nil)
|
||||||
@donation = RecurringDonation.find(donation_id).donation
|
@donation = RecurringDonation.find(donation_id).donation
|
||||||
@nonprofit = @donation.nonprofit
|
@nonprofit = @donation.nonprofit
|
||||||
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
||||||
if @nonprofit.miscellaneous_np_info && ActionView::Base.full_sanitizer.sanitize(@nonprofit.miscellaneous_np_info.change_amount_message).present?
|
if @nonprofit.miscellaneous_np_info && ActionView::Base.full_sanitizer.sanitize(@nonprofit.miscellaneous_np_info.change_amount_message).present?
|
||||||
@thank_you_note = @nonprofit.miscellaneous_np_info.change_amount_message
|
@thank_you_note = @nonprofit.miscellaneous_np_info.change_amount_message
|
||||||
else
|
else
|
||||||
@thank_you_note = nil
|
@thank_you_note = nil
|
||||||
end
|
end
|
||||||
from = Format::Name.email_from_np(@nonprofit.name)
|
from = Format::Name.email_from_np(@nonprofit.name)
|
||||||
@previous_amount = previous_amount
|
@previous_amount = previous_amount
|
||||||
mail(to: @donation.supporter.email, from: from, reply_to: reply_to, subject: "Recurring donation amount changed for #{@nonprofit.name}")
|
mail(to: @donation.supporter.email, from: from, reply_to: reply_to, subject: "Recurring donation amount changed for #{@nonprofit.name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def nonprofit_recurring_donation_change_amount(donation_id, previous_amount=nil)
|
def nonprofit_recurring_donation_change_amount(donation_id, previous_amount = nil)
|
||||||
@donation = RecurringDonation.find(donation_id).donation
|
@donation = RecurringDonation.find(donation_id).donation
|
||||||
@nonprofit = @donation.nonprofit
|
@nonprofit = @donation.nonprofit
|
||||||
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_recurring_donations')
|
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_recurring_donations')
|
||||||
@previous_amount = previous_amount
|
@previous_amount = previous_amount
|
||||||
mail(to: @emails, subject:"Recurring donation amount changed for #{@donation.supporter.name || @donation.supporter.email}")
|
mail(to: @emails, subject: "Recurring donation amount changed for #{@donation.supporter.name || @donation.supporter.email}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def donor_recurring_donation_change_amount(donation_id, previous_amount=nil)
|
|
||||||
@donation = RecurringDonation.find(donation_id).donation
|
|
||||||
@nonprofit = @donation.nonprofit
|
|
||||||
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
|
||||||
if @nonprofit.miscellaneous_np_info && ActionView::Base.full_sanitizer.sanitize(@nonprofit.miscellaneous_np_info.change_amount_message).present?
|
|
||||||
@thank_you_note = @nonprofit.miscellaneous_np_info.change_amount_message
|
|
||||||
else
|
|
||||||
@thank_you_note = nil
|
|
||||||
end
|
|
||||||
from = Format::Name.email_from_np(@nonprofit.name)
|
|
||||||
@previous_amount = previous_amount
|
|
||||||
mail(to: @donation.supporter.email, from: from, reply_to: reply_to, subject: "Recurring donation amount changed for #{@nonprofit.name}")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def donor_recurring_donation_change_amount(donation_id, previous_amount = nil)
|
||||||
|
@donation = RecurringDonation.find(donation_id).donation
|
||||||
|
@nonprofit = @donation.nonprofit
|
||||||
|
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
||||||
|
if @nonprofit.miscellaneous_np_info && ActionView::Base.full_sanitizer.sanitize(@nonprofit.miscellaneous_np_info.change_amount_message).present?
|
||||||
|
@thank_you_note = @nonprofit.miscellaneous_np_info.change_amount_message
|
||||||
|
else
|
||||||
|
@thank_you_note = nil
|
||||||
|
end
|
||||||
|
from = Format::Name.email_from_np(@nonprofit.name)
|
||||||
|
@previous_amount = previous_amount
|
||||||
|
mail(to: @donation.supporter.email, from: from, reply_to: reply_to, subject: "Recurring donation amount changed for #{@nonprofit.name}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class EventMailer < BaseMailer
|
class EventMailer < BaseMailer
|
||||||
|
helper :application
|
||||||
|
|
||||||
helper :application
|
include Devise::Controllers::UrlHelpers
|
||||||
|
|
||||||
include Devise::Controllers::UrlHelpers
|
|
||||||
|
|
||||||
def creation_followup(event)
|
|
||||||
@creator_profile = event.profile
|
|
||||||
@event = event
|
|
||||||
mail(:to => @creator_profile.user.email, :subject => "Get your new event rolling on #{Settings.general.name}!")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def creation_followup(event)
|
||||||
|
@creator_profile = event.profile
|
||||||
|
@event = event
|
||||||
|
mail(to: @creator_profile.user.email, subject: "Get your new event rolling on #{Settings.general.name}!")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class ExportMailer < BaseMailer
|
class ExportMailer < BaseMailer
|
||||||
|
|
||||||
# Subject can be set in your I18n file at config/locales/en.yml
|
# Subject can be set in your I18n file at config/locales/en.yml
|
||||||
# with the following lookup:
|
# with the following lookup:
|
||||||
#
|
#
|
||||||
|
@ -18,7 +19,6 @@ class ExportMailer < BaseMailer
|
||||||
mail(to: @export.user.email, subject: 'Your payment export has failed')
|
mail(to: @export.user.email, subject: 'Your payment export has failed')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def export_recurring_donations_completed_notification(export)
|
def export_recurring_donations_completed_notification(export)
|
||||||
@export = export
|
@export = export
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class GenericMailer < BaseMailer
|
class GenericMailer < BaseMailer
|
||||||
|
def generic_mail(from_email, from_name, message, subject, to_email, _to_name)
|
||||||
def generic_mail(from_email, from_name, message, subject, to_email, to_name)
|
|
||||||
@from_email = from_email
|
@from_email = from_email
|
||||||
@from_name = from_name
|
@from_name = from_name
|
||||||
@message = message
|
@message = message
|
||||||
mail(:to => to_email, :from => "#{from_name} <#{Settings.mailer.email}>", :reply_to => from_email, :subject => "#{subject}")
|
mail(to: to_email, from: "#{from_name} <#{Settings.mailer.email}>", reply_to: from_email, subject: subject.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
# For sending a system notice to super admins
|
# For sending a system notice to super admins
|
||||||
|
@ -16,5 +17,4 @@ class GenericMailer < BaseMailer
|
||||||
emails = QueryUsers.super_admin_emails
|
emails = QueryUsers.super_admin_emails
|
||||||
mail(to: emails, from: "#{@from_name} <#{@from_email}>", reply_to: @from_email, subject: options[:subject], template_name: 'generic_mail')
|
mail(to: emails, from: "#{@from_name} <#{@from_email}>", reply_to: @from_email, subject: options[:subject], template_name: 'generic_mail')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class ImportMailer < BaseMailer
|
class ImportMailer < BaseMailer
|
||||||
|
def import_completed_notification(import_id)
|
||||||
def import_completed_notification(import_id)
|
@import = Import.find(import_id)
|
||||||
@import = Import.find(import_id)
|
@nonprofit = @import.nonprofit
|
||||||
@nonprofit = @import.nonprofit
|
mail(to: @import.user.email, subject: 'Your import is complete!')
|
||||||
mail(to: @import.user.email, subject: "Your import is complete!")
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class NonprofitAdminMailer < BaseMailer
|
class NonprofitAdminMailer < BaseMailer
|
||||||
|
def new_invite(role, raw_token)
|
||||||
|
@user = role.user
|
||||||
|
@title_with_article = Format::Indefinitize.with_article(role.name.to_s.titleize)
|
||||||
|
@nonprofit = role.host
|
||||||
|
@token = raw_token
|
||||||
|
mail(to: @user.email, subject: "You're now #{@title_with_article} of #{@nonprofit.name} on #{Settings.general.name}. Let's set your password.")
|
||||||
|
end
|
||||||
|
|
||||||
def new_invite(role, raw_token)
|
def existing_invite(role)
|
||||||
@user = role.user
|
@user = role.user
|
||||||
@title_with_article = Format::Indefinitize.with_article(role.name.to_s.titleize)
|
@title_with_article = Format::Indefinitize.with_article(role.name.to_s.titleize)
|
||||||
@nonprofit = role.host
|
@nonprofit = role.host
|
||||||
@token = raw_token
|
mail(to: @user.email, subject: "You're now #{@title_with_article} of #{@nonprofit.name} on #{Settings.general.name}.")
|
||||||
mail(:to => @user.email, :subject => "You're now #{@title_with_article} of #{@nonprofit.name} on #{Settings.general.name}. Let's set your password.")
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def existing_invite(role)
|
def supporter_fundraiser(event_or_campaign)
|
||||||
@user = role.user
|
@fundraiser = event_or_campaign
|
||||||
@title_with_article = Format::Indefinitize.with_article(role.name.to_s.titleize)
|
@kind = event_or_campaign.class.name.downcase || 'event'
|
||||||
@nonprofit = role.host
|
@nonprofit = event_or_campaign.nonprofit
|
||||||
mail(:to => @user.email, :subject => "You're now #{@title_with_article} of #{@nonprofit.name} on #{Settings.general.name}.")
|
@profile = event_or_campaign.profile
|
||||||
end
|
recipients = @nonprofit.nonprofit_personnel_emails
|
||||||
|
mail(to: recipients, subject: "A Supporter has created #{Format::Indefinitize.with_article(@kind.capitalize)} for your Nonprofit!")
|
||||||
def supporter_fundraiser(event_or_campaign)
|
end
|
||||||
@fundraiser = event_or_campaign
|
|
||||||
@kind = event_or_campaign.class.name.downcase || 'event'
|
|
||||||
@nonprofit = event_or_campaign.nonprofit
|
|
||||||
@profile = event_or_campaign.profile
|
|
||||||
recipients = @nonprofit.nonprofit_personnel_emails
|
|
||||||
mail(to: recipients, subject: "A Supporter has created #{Format::Indefinitize.with_article(@kind.capitalize)} for your Nonprofit!")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class NonprofitMailer < BaseMailer
|
class NonprofitMailer < BaseMailer
|
||||||
|
|
||||||
def failed_verification_notice(np)
|
def failed_verification_notice(np)
|
||||||
@nonprofit = np
|
@nonprofit = np
|
||||||
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_payouts')
|
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_payouts')
|
||||||
|
@ -13,92 +14,93 @@ class NonprofitMailer < BaseMailer
|
||||||
mail(to: @emails, subject: "Verification successful on #{Settings.general.name}!")
|
mail(to: @emails, subject: "Verification successful on #{Settings.general.name}!")
|
||||||
end
|
end
|
||||||
|
|
||||||
def refund_notification(refund_id)
|
def refund_notification(refund_id)
|
||||||
@refund = Refund.find(refund_id)
|
@refund = Refund.find(refund_id)
|
||||||
@charge = @refund.charge
|
@charge = @refund.charge
|
||||||
@nonprofit = @refund.payment.nonprofit
|
@nonprofit = @refund.payment.nonprofit
|
||||||
@supporter = @refund.payment.supporter
|
@supporter = @refund.payment.supporter
|
||||||
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_payments')
|
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_payments')
|
||||||
mail(to: @emails, subject: "A new refund has been made for $#{Format::Currency.cents_to_dollars(@refund.amount)}")
|
mail(to: @emails, subject: "A new refund has been made for $#{Format::Currency.cents_to_dollars(@refund.amount)}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_bank_account_notification(ba)
|
def new_bank_account_notification(ba)
|
||||||
@nonprofit = ba.nonprofit
|
@nonprofit = ba.nonprofit
|
||||||
@bank_account = ba
|
@bank_account = ba
|
||||||
@emails = QueryUsers.all_nonprofit_user_emails(@nonprofit.id)
|
@emails = QueryUsers.all_nonprofit_user_emails(@nonprofit.id)
|
||||||
mail(to: @emails, subject: "We need to confirm the new bank account")
|
mail(to: @emails, subject: 'We need to confirm the new bank account')
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_payout_notification(payout_id)
|
def pending_payout_notification(payout_id)
|
||||||
@payout = Payout.find(payout_id)
|
@payout = Payout.find(payout_id)
|
||||||
@nonprofit = @payout.nonprofit
|
@nonprofit = @payout.nonprofit
|
||||||
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_payouts')
|
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_payouts')
|
||||||
mail(to: @emails, subject: "Payout of available balance now pending")
|
mail(to: @emails, subject: 'Payout of available balance now pending')
|
||||||
end
|
end
|
||||||
|
|
||||||
def successful_payout_notification(payout)
|
def successful_payout_notification(payout)
|
||||||
@nonprofit = payout.nonprofit
|
@nonprofit = payout.nonprofit
|
||||||
@payout = payout
|
@payout = payout
|
||||||
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_payouts')
|
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_payouts')
|
||||||
mail(to: @emails, subject: "Payout of available balance succeeded")
|
mail(to: @emails, subject: 'Payout of available balance succeeded')
|
||||||
end
|
end
|
||||||
|
|
||||||
def failed_payout_notification(payout)
|
def failed_payout_notification(payout)
|
||||||
@nonprofit = payout.nonprofit
|
@nonprofit = payout.nonprofit
|
||||||
@payout = payout
|
@payout = payout
|
||||||
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_payouts')
|
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_payouts')
|
||||||
mail(to: @emails, subject: "Payout could not be completed")
|
mail(to: @emails, subject: 'Payout could not be completed')
|
||||||
end
|
end
|
||||||
|
|
||||||
def failed_recurring_donation(recurring_donation)
|
def failed_recurring_donation(recurring_donation)
|
||||||
@recurring_donation = recurring_donation
|
@recurring_donation = recurring_donation
|
||||||
@nonprofit = recurring_donation.nonprofit
|
@nonprofit = recurring_donation.nonprofit
|
||||||
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_recurring_donations')
|
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_recurring_donations')
|
||||||
mail(to: @emails, subject: "A recurring donation from one of your supporters had a payment failure.")
|
mail(to: @emails, subject: 'A recurring donation from one of your supporters had a payment failure.')
|
||||||
end
|
end
|
||||||
|
|
||||||
def cancelled_recurring_donation(recurring_donation)
|
def cancelled_recurring_donation(recurring_donation)
|
||||||
@recurring_donation = recurring_donation
|
@recurring_donation = recurring_donation
|
||||||
@nonprofit = recurring_donation.nonprofit
|
@nonprofit = recurring_donation.nonprofit
|
||||||
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_recurring_donations')
|
@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_recurring_donations')
|
||||||
mail(to: @emails, subject: "A recurring donation from one of your supporters was cancelled.")
|
mail(to: @emails, subject: 'A recurring donation from one of your supporters was cancelled.')
|
||||||
end
|
end
|
||||||
|
|
||||||
def verified_notification(nonprofit)
|
def verified_notification(nonprofit)
|
||||||
@nonprofit = nonprofit
|
@nonprofit = nonprofit
|
||||||
@emails = QueryUsers.all_nonprofit_user_emails(@nonprofit.id)
|
@emails = QueryUsers.all_nonprofit_user_emails(@nonprofit.id)
|
||||||
mail(to: @emails, subject: "Your nonprofit has been verified!")
|
mail(to: @emails, subject: 'Your nonprofit has been verified!')
|
||||||
end
|
end
|
||||||
|
|
||||||
def button_code(nonprofit, to_email, to_name, from_email, message, code)
|
def button_code(nonprofit, to_email, to_name, from_email, message, code)
|
||||||
@nonprofit = nonprofit
|
@nonprofit = nonprofit
|
||||||
@to_email = to_email
|
@to_email = to_email
|
||||||
@to_name = to_name
|
@to_name = to_name
|
||||||
@from = from_email
|
@from = from_email
|
||||||
@message = message
|
@message = message
|
||||||
@code = code
|
@code = code
|
||||||
from = Format::Name.email_from_np(@nonprofit.name)
|
from = Format::Name.email_from_np(@nonprofit.name)
|
||||||
mail(to: to_email, from: from, reply_to: from_email, subject: "Please include this donate button code on the website")
|
mail(to: to_email, from: from, reply_to: from_email, subject: 'Please include this donate button code on the website')
|
||||||
end
|
end
|
||||||
|
|
||||||
def invoice_payment_notification(nonprofit_id, payment)
|
def invoice_payment_notification(nonprofit_id, payment)
|
||||||
@nonprofit = Nonprofit.find(nonprofit_id)
|
@nonprofit = Nonprofit.find(nonprofit_id)
|
||||||
@payment = payment
|
@payment = payment
|
||||||
@emails = QueryUsers.all_nonprofit_user_emails(@nonprofit.id, [:nonprofit_admin])
|
@emails = QueryUsers.all_nonprofit_user_emails(@nonprofit.id, [:nonprofit_admin])
|
||||||
@month_name = Date::MONTHNAMES[payment.date.month]
|
@month_name = Date::MONTHNAMES[payment.date.month]
|
||||||
mail(to: @emails, subject: "#{Settings.general.name} Subscription Receipt for #{@month_name}")
|
mail(to: @emails, subject: "#{Settings.general.name} Subscription Receipt for #{@month_name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# pass in all of:
|
# pass in all of:
|
||||||
# {is_unsubscribed_from_emails, supporter_email, message, email_unsubscribe_uuid, nonprofit_id, from_email, subject}
|
# {is_unsubscribed_from_emails, supporter_email, message, email_unsubscribe_uuid, nonprofit_id, from_email, subject}
|
||||||
def supporter_message(args)
|
def supporter_message(args)
|
||||||
return if args[:is_unsubscribed_from_emails] || args[:supporter_email].blank?
|
return if args[:is_unsubscribed_from_emails] || args[:supporter_email].blank?
|
||||||
@message = args[:message]
|
|
||||||
@uuid = args[:email_unsubscribe_uuid]
|
@message = args[:message]
|
||||||
@nonprofit = Nonprofit.find args[:nonprofit_id]
|
@uuid = args[:email_unsubscribe_uuid]
|
||||||
|
@nonprofit = Nonprofit.find args[:nonprofit_id]
|
||||||
from = Format::Name.email_from_np(@nonprofit.name)
|
from = Format::Name.email_from_np(@nonprofit.name)
|
||||||
mail(to: args[:supporter_email], reply_to: args[:from_email], from: from, subject: args[:subject])
|
mail(to: args[:supporter_email], reply_to: args[:from_email], from: from, subject: args[:subject])
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_verification(np_id)
|
def setup_verification(np_id)
|
||||||
@nonprofit = Nonprofit.find(np_id)
|
@nonprofit = Nonprofit.find(np_id)
|
||||||
|
@ -113,6 +115,4 @@ class NonprofitMailer < BaseMailer
|
||||||
@emails = QueryUsers.all_nonprofit_user_emails(np_id, [:nonprofit_admin])
|
@emails = QueryUsers.all_nonprofit_user_emails(np_id, [:nonprofit_admin])
|
||||||
mail(to: @emails, reply_to: 'support@commitchange.com', from: "#{Settings.general.name} Support", subject: "A hearty welcome from the #{Settings.general.name} team")
|
mail(to: @emails, reply_to: 'support@commitchange.com', from: "#{Settings.general.name} Support", subject: "A hearty welcome from the #{Settings.general.name} team")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class PaymentMailer < BaseMailer
|
class PaymentMailer < BaseMailer
|
||||||
|
|
||||||
# Send a donation receipt to a single admin
|
# Send a donation receipt to a single admin
|
||||||
# or a ticket receipt
|
# or a ticket receipt
|
||||||
def resend_admin_receipt(payment_id, user_id)
|
def resend_admin_receipt(payment_id, user_id)
|
||||||
|
@ -22,5 +23,4 @@ class PaymentMailer < BaseMailer
|
||||||
return TicketMailer.followup(payment.tickets.pluck(:id), payment.charge.id).deliver
|
return TicketMailer.followup(payment.tickets.pluck(:id), payment.charge.id).deliver
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class RecurringDonationMailer < BaseMailer
|
class RecurringDonationMailer < BaseMailer
|
||||||
|
def send_cancellation_notices(recurring_donation)
|
||||||
|
UserMailer.recurring_donation_cancelled(recurring_donation).deliver
|
||||||
|
NonprofitMailer.cancelled_recurring_donation(recurring_donation).deliver
|
||||||
|
recurring_donation
|
||||||
|
end
|
||||||
|
|
||||||
def send_cancellation_notices(recurring_donation)
|
def send_failure_notifications(recurring_donation)
|
||||||
UserMailer.recurring_donation_cancelled(recurring_donation).deliver
|
UserMailer.recurring_donation_failure(recurring_donation).deliver
|
||||||
NonprofitMailer.cancelled_recurring_donation(recurring_donation).deliver
|
NonprofitMailer.failed_recurring_donation(recurring_donation).deliver
|
||||||
return recurring_donation
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def send_failure_notifications(recurring_donation)
|
|
||||||
UserMailer.recurring_donation_failure(recurring_donation).deliver
|
|
||||||
NonprofitMailer.failed_recurring_donation(recurring_donation).deliver
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class Testing < ActionMailer::Base
|
class Testing < ActionMailer::Base
|
||||||
default from: "from@example.com"
|
default from: 'from@example.com'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,22 +1,23 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class TicketMailer < BaseMailer
|
class TicketMailer < BaseMailer
|
||||||
|
|
||||||
helper :application
|
helper :application
|
||||||
|
|
||||||
# Pass in ticket_ids, event_id, and supporter
|
# Pass in ticket_ids, event_id, and supporter
|
||||||
def followup(ticket_ids, charge_id=nil)
|
def followup(ticket_ids, charge_id = nil)
|
||||||
@charge = charge_id ? Charge.find(charge_id) : nil
|
@charge = charge_id ? Charge.find(charge_id) : nil
|
||||||
@tickets = Ticket.where("id IN(?)", ticket_ids)
|
@tickets = Ticket.where('id IN(?)', ticket_ids)
|
||||||
@event = @tickets.last.event
|
@event = @tickets.last.event
|
||||||
@supporter = @tickets.last.supporter
|
@supporter = @tickets.last.supporter
|
||||||
@nonprofit = @supporter.nonprofit
|
@nonprofit = @supporter.nonprofit
|
||||||
from = Format::Name.email_from_np(@nonprofit.name)
|
from = Format::Name.email_from_np(@nonprofit.name)
|
||||||
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
||||||
mail(from: from, to: @supporter.email, reply_to: reply_to, subject: "Your tickets#{@charge ? ' and receipt ' : ' '}for: #{@event.name}")
|
mail(from: from, to: @supporter.email, reply_to: reply_to, subject: "Your tickets#{@charge ? ' and receipt ' : ' '}for: #{@event.name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def receipt_admin(ticket_ids, user_id=nil)
|
def receipt_admin(ticket_ids, user_id = nil)
|
||||||
@tickets = Ticket.where("id IN (?)", ticket_ids)
|
@tickets = Ticket.where('id IN (?)', ticket_ids)
|
||||||
@charge = @tickets.last.charge
|
@charge = @tickets.last.charge
|
||||||
@supporter = @tickets.last.supporter
|
@supporter = @tickets.last.supporter
|
||||||
@event = @tickets.last.event
|
@event = @tickets.last.event
|
||||||
|
@ -25,9 +26,9 @@ class TicketMailer < BaseMailer
|
||||||
if user_id
|
if user_id
|
||||||
em = User.find(user_id).email
|
em = User.find(user_id).email
|
||||||
return unless recipients.include?(em)
|
return unless recipients.include?(em)
|
||||||
|
|
||||||
recipients = [em]
|
recipients = [em]
|
||||||
end
|
end
|
||||||
mail(to: recipients, subject: "Ticket redeemed for #{@event.name} - #{@supporter.name}")
|
mail(to: recipients, subject: "Ticket redeemed for #{@event.name} - #{@supporter.name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class UserMailer < BaseMailer
|
class UserMailer < BaseMailer
|
||||||
|
def refund_receipt(refund_id)
|
||||||
def refund_receipt(refund_id)
|
@refund = Refund.find(refund_id)
|
||||||
@refund = Refund.find(refund_id)
|
|
||||||
@nonprofit = @refund.payment.nonprofit
|
@nonprofit = @refund.payment.nonprofit
|
||||||
@charge = @refund.charge
|
@charge = @refund.charge
|
||||||
@supporter = @refund.payment.supporter
|
@supporter = @refund.payment.supporter
|
||||||
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
reply_to = @nonprofit.email.blank? ? @nonprofit.users.first.email : @nonprofit.email
|
||||||
from = Format::Name.email_from_np(@nonprofit.name)
|
from = Format::Name.email_from_np(@nonprofit.name)
|
||||||
mail(to: @supporter.email, from: from, reply_to: reply_to, subject: "Your refund receipt for #{@nonprofit.name}")
|
mail(to: @supporter.email, from: from, reply_to: reply_to, subject: "Your refund receipt for #{@nonprofit.name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def recurring_donation_failure(recurring_donation)
|
def recurring_donation_failure(recurring_donation)
|
||||||
@recurring_donation = recurring_donation
|
@recurring_donation = recurring_donation
|
||||||
mail(:to => @recurring_donation.email,
|
mail(to: @recurring_donation.email,
|
||||||
:subject => ("We couldn't process your recurring donation towards #{@recurring_donation.nonprofit.name}."))
|
subject: "We couldn't process your recurring donation towards #{@recurring_donation.nonprofit.name}.")
|
||||||
end
|
end
|
||||||
|
|
||||||
def recurring_donation_cancelled(recurring_donation)
|
|
||||||
@recurring_donation = recurring_donation
|
|
||||||
mail(:to => @recurring_donation.email,
|
|
||||||
:subject => ("Your recurring donation towards #{@recurring_donation.nonprofit.name} was successfully cancelled."))
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def recurring_donation_cancelled(recurring_donation)
|
||||||
|
@recurring_donation = recurring_donation
|
||||||
|
mail(to: @recurring_donation.email,
|
||||||
|
subject: "Your recurring donation towards #{@recurring_donation.nonprofit.name} was successfully cancelled.")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class Activity < ActiveRecord::Base
|
class Activity < ApplicationRecord
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
7
app/models/application_record.rb
Normal file
7
app/models/application_record.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
|
|
||||||
|
class ApplicationRecord < ActiveRecord::Base
|
||||||
|
self.abstract_class = true
|
||||||
|
end
|
|
@ -1,41 +1,41 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class BankAccount < ActiveRecord::Base
|
class BankAccount < ApplicationRecord
|
||||||
|
# TODO
|
||||||
|
# attr_accessible \
|
||||||
|
# :name, # str (readable bank name identifier, eg. "Wells Fargo *1234")
|
||||||
|
# :confirmation_token, # str (randomly generated private token for email confirmation)
|
||||||
|
# :account_number, # str (last digits only)
|
||||||
|
# :bank_name, # str
|
||||||
|
# :pending_verification, # bool (whether this bank account is still awaiting email confirmation)
|
||||||
|
# :status, # str
|
||||||
|
# :email, # str (contact email associated with the user who created this bank account)
|
||||||
|
# :deleted, # bool (soft delete flag)
|
||||||
|
# :stripe_bank_account_token, # str
|
||||||
|
# :stripe_bank_account_id, # str
|
||||||
|
# :nonprofit_id, :nonprofit
|
||||||
|
|
||||||
attr_accessible \
|
# validates :stripe_bank_account_token, presence: true, uniqueness: true
|
||||||
:name, # str (readable bank name identifier, eg. "Wells Fargo *1234")
|
# validates :stripe_bank_account_id, presence: true, uniqueness: true
|
||||||
:confirmation_token, # str (randomly generated private token for email confirmation)
|
# validates :nonprofit, presence: true
|
||||||
:account_number, # str (last digits only)
|
# validates :email, presence: true, format: {with: Email::Regex}
|
||||||
:bank_name, # str
|
# validate :nonprofit_must_be_vetted, on: :create
|
||||||
:pending_verification, # bool (whether this bank account is still awaiting email confirmation)
|
# validate :nonprofit_has_stripe_account
|
||||||
:status, # str
|
|
||||||
:email, # str (contact email associated with the user who created this bank account)
|
|
||||||
:deleted, # bool (soft delete flag)
|
|
||||||
:stripe_bank_account_token, # str
|
|
||||||
:stripe_bank_account_id, # str
|
|
||||||
:nonprofit_id, :nonprofit
|
|
||||||
|
|
||||||
#validates :stripe_bank_account_token, presence: true, uniqueness: true
|
has_many :payouts
|
||||||
# validates :stripe_bank_account_id, presence: true, uniqueness: true
|
belongs_to :nonprofit
|
||||||
#validates :nonprofit, presence: true
|
|
||||||
#validates :email, presence: true, format: {with: Email::Regex}
|
|
||||||
#validate :nonprofit_must_be_vetted, on: :create
|
|
||||||
#validate :nonprofit_has_stripe_account
|
|
||||||
|
|
||||||
has_many :payouts
|
def nonprofit_must_be_vetted
|
||||||
belongs_to :nonprofit
|
errors.add(:nonprofit, 'must be vetted') unless nonprofit&.vetted
|
||||||
|
end
|
||||||
|
|
||||||
def nonprofit_must_be_vetted
|
def nonprofit_has_stripe_account
|
||||||
errors.add(:nonprofit, "must be vetted") unless self.nonprofit && self.nonprofit.vetted
|
errors.add(:nonprofit, 'must have a Stripe account id') if !nonprofit || nonprofit.stripe_account_id.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def nonprofit_has_stripe_account
|
|
||||||
errors.add(:nonprofit, 'must have a Stripe account id') if !self.nonprofit || self.nonprofit.stripe_account_id.blank?
|
|
||||||
end
|
|
||||||
|
|
||||||
# Manually cause an instance to become invalid
|
|
||||||
def invalidate!
|
|
||||||
@not_valid = true
|
|
||||||
end
|
|
||||||
|
|
||||||
|
# Manually cause an instance to become invalid
|
||||||
|
def invalidate!
|
||||||
|
@not_valid = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
class BillingPlan < ActiveRecord::Base
|
class BillingPlan < ApplicationRecord
|
||||||
Names = ['Starter', 'Fundraising', 'Supporter Management']
|
Names = ['Starter', 'Fundraising', 'Supporter Management'].freeze
|
||||||
DefaultAmounts = [0, 9900, 29900] # in pennies
|
DefaultAmounts = [0, 9900, 29_900].freeze # in pennies
|
||||||
|
|
||||||
attr_accessible \
|
# TODO
|
||||||
:name, #str: readable name
|
# attr_accessible \
|
||||||
:tier, #int: 0-4 (0: Free, 1: Fundraising, 2: Supporter Management)
|
# :name, #str: readable name
|
||||||
:amount, #int (cents)
|
# :tier, #int: 0-4 (0: Free, 1: Fundraising, 2: Supporter Management)
|
||||||
:stripe_plan_id, #str (matches plan ID in Stripe) Not needed if it's not a paying subscription
|
# :amount, #int (cents)
|
||||||
:interval, #str ('monthly', 'annual')
|
# :stripe_plan_id, #str (matches plan ID in Stripe) Not needed if it's not a paying subscription
|
||||||
:percentage_fee # 0.038
|
# :interval, #str ('monthly', 'annual')
|
||||||
|
# :percentage_fee # 0.038
|
||||||
|
|
||||||
has_many :billing_subscriptions
|
has_many :billing_subscriptions
|
||||||
|
|
||||||
validates :name, :presence => true
|
validates :name, presence: true
|
||||||
validates :amount, :presence => true
|
validates :amount, presence: true
|
||||||
end
|
end
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue