effective_memberships 0.3.12 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/admin/organizations_controller.rb +19 -0
  3. data/app/controllers/admin/representatives_controller.rb +19 -0
  4. data/app/controllers/effective/applicants_controller.rb +2 -3
  5. data/app/controllers/effective/fee_payments_controller.rb +1 -2
  6. data/app/controllers/effective/organizations_controller.rb +16 -0
  7. data/app/controllers/effective/representatives_controller.rb +19 -0
  8. data/app/datatables/admin/effective_applicants_datatable.rb +10 -5
  9. data/app/datatables/admin/effective_categories_datatable.rb +7 -0
  10. data/app/datatables/admin/effective_fee_payments_datatable.rb +11 -6
  11. data/app/datatables/admin/effective_organizations_datatable.rb +31 -0
  12. data/app/datatables/admin/effective_representatives_datatable.rb +28 -0
  13. data/app/datatables/effective_applicants_datatable.rb +1 -1
  14. data/app/datatables/effective_fee_payments_datatable.rb +5 -4
  15. data/app/datatables/effective_organizations_datatable.rb +18 -0
  16. data/app/datatables/effective_representatives_datatable.rb +40 -0
  17. data/app/helpers/effective_memberships_helper.rb +25 -0
  18. data/app/mailers/effective/memberships_mailer.rb +35 -15
  19. data/app/models/concerns/effective_memberships_applicant.rb +63 -30
  20. data/app/models/concerns/effective_memberships_category.rb +32 -5
  21. data/app/models/concerns/effective_memberships_fee_payment.rb +44 -45
  22. data/app/models/concerns/effective_memberships_organization.rb +94 -0
  23. data/app/models/concerns/effective_memberships_owner.rb +0 -55
  24. data/app/models/concerns/effective_memberships_registrar.rb +2 -2
  25. data/app/models/concerns/effective_memberships_user.rb +70 -0
  26. data/app/models/effective/fee.rb +1 -1
  27. data/app/models/effective/organization.rb +8 -0
  28. data/app/models/effective/representative.rb +56 -0
  29. data/app/views/admin/categories/_form_applicant_eligibility.html.haml +1 -1
  30. data/app/views/admin/categories/_form_applicant_steps.html.haml +29 -24
  31. data/app/views/admin/categories/_form_category.html.haml +3 -0
  32. data/app/views/admin/categories/_form_renewals.html.haml +0 -2
  33. data/app/views/admin/organizations/_fields.html.haml +6 -0
  34. data/app/views/admin/organizations/_form.html.haml +31 -0
  35. data/app/views/admin/organizations/_form_organization.html.haml +23 -0
  36. data/app/views/admin/representatives/_form.html.haml +38 -0
  37. data/app/views/{effective/applicants/_demographics_fields.html.haml → admin/representatives/_user_fields.html.haml} +2 -6
  38. data/app/views/effective/applicants/_dashboard.html.haml +24 -5
  39. data/app/views/effective/applicants/_demographics.html.haml +1 -1
  40. data/app/views/effective/applicants/_missing_info.html.haml +7 -3
  41. data/app/views/effective/applicants/_organization.html.haml +9 -0
  42. data/app/views/effective/applicants/_select_organization.html.haml +21 -0
  43. data/app/views/effective/applicants/_summary.html.haml +17 -9
  44. data/app/views/effective/applicants/billing.html.haml +2 -2
  45. data/app/views/effective/applicants/demographics.html.haml +7 -6
  46. data/app/views/effective/applicants/education.html.haml +2 -2
  47. data/app/views/effective/applicants/organization.html.haml +19 -0
  48. data/app/views/effective/applicants/references.html.haml +1 -1
  49. data/app/views/effective/applicants/select.html.haml +11 -1
  50. data/app/views/effective/applicants/stamp.html.haml +2 -2
  51. data/app/views/effective/applicants/start.html.haml +17 -11
  52. data/app/views/effective/applicants/submitted.html.haml +5 -5
  53. data/app/views/effective/applicants/summary.html.haml +1 -1
  54. data/app/views/effective/fee_payments/_demographics.html.haml +1 -1
  55. data/app/views/effective/fee_payments/_organization.html.haml +9 -0
  56. data/app/views/effective/fee_payments/_summary.html.haml +39 -1
  57. data/app/views/effective/fee_payments/billing.html.haml +2 -2
  58. data/app/views/effective/fee_payments/demographics.html.haml +2 -2
  59. data/app/views/effective/fee_payments/organization.html.haml +18 -0
  60. data/app/views/effective/fee_payments/start.html.haml +20 -17
  61. data/app/views/effective/fee_payments/submitted.html.haml +10 -3
  62. data/app/views/effective/fees/_dashboard.html.haml +20 -8
  63. data/app/views/effective/memberships/_dashboard.html.haml +16 -5
  64. data/app/views/effective/organizations/_dashboard.html.haml +10 -0
  65. data/app/views/effective/organizations/_form.html.haml +8 -0
  66. data/app/views/effective/organizations/_form_organization.html.haml +11 -0
  67. data/app/views/effective/representatives/_form.html.haml +33 -0
  68. data/app/views/effective/{fee_payments/_demographics_fields.html.haml → representatives/_user_fields.html.haml} +2 -6
  69. data/app/views/organizations/_demographics.html.haml +45 -0
  70. data/app/views/organizations/_fields_demographics.html.haml +29 -0
  71. data/app/views/users/_demographics.html.haml +50 -0
  72. data/app/views/users/_fields_demographics.html.haml +29 -0
  73. data/config/effective_memberships.rb +18 -21
  74. data/config/routes.rb +9 -0
  75. data/db/migrate/01_create_effective_memberships.rb.erb +57 -10
  76. data/db/seeds.rb +18 -0
  77. data/lib/effective_memberships/engine.rb +3 -0
  78. data/lib/effective_memberships/version.rb +1 -1
  79. data/lib/effective_memberships.rb +7 -31
  80. metadata +33 -21
  81. data/app/views/effective/applicants/_demographics_owner.html.haml +0 -20
  82. data/app/views/effective/fee_payments/_demographics_owner.html.haml +0 -20
  83. data/app/views/layouts/effective_memberships_mailer_layout.html.haml +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32668e9dd393f60b922e5133dccf0204b0506f6a6fcff74f955be98e417b9398
4
- data.tar.gz: 9b15d17b3e60142c3db939e1ecedd92a028540fb20234443a2c46be8e7427dea
3
+ metadata.gz: 223d0bdf9ce08beacd79d4fdeb3e184878bb9e9cdb8b5964aa1c4ace9f1d2735
4
+ data.tar.gz: 158b570a8dc933b247245e450c74a78c63877ece8f35a59b1e400b0fdb017b43
5
5
  SHA512:
6
- metadata.gz: b91b4b36706dce52f0fb43962a87977163364adcc0fb453d494f1e05895bf9e8edc737cf8a10df51d6cf5cf8da415957f0239ae1ef57de5425471bb68dc35e04
7
- data.tar.gz: 14f41d1145244e763dab621c0db7cbfbea2e0ee2a5ad88eceaf953da5634a19ba562e44aff38557561a5ed60a6aee6d758b1c980180652fbba9d673f4b56241e
6
+ metadata.gz: b8e3fe9641f2826a4df557f1817163d719bb53112a835b3a5456ea7020283f360e4bcdc99d75c1a79256f6515b2fa05f5a2c0001b6eb1ecfa988dd09eba8eb5d
7
+ data.tar.gz: 013d39152828dce9d873e1eb1f1bb9f3a42aa83fc31105e020adbd47734f42902eec0659ff661b1fd4e8bd1983a389374848847221b6aec35dcbb8bfb5552661
@@ -0,0 +1,19 @@
1
+ module Admin
2
+ class OrganizationsController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_memberships) }
5
+
6
+ include Effective::CrudController
7
+
8
+ resource_scope -> { EffectiveMemberships.Organization.deep.all }
9
+ datatable -> { EffectiveResources.best('Admin::EffectiveMembershipsDatatable').new }
10
+
11
+ private
12
+
13
+ def permitted_params
14
+ model = (params.key?(:effective_organization) ? :effective_organization : :organization)
15
+ params.require(model).permit!
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Admin
2
+ class RepresentativesController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_memberships) }
5
+
6
+ include Effective::CrudController
7
+
8
+ resource_scope -> { Effective::Representative.deep.all }
9
+ datatable -> { Admin::EffectiveRepresentativesDatatable.new }
10
+
11
+ private
12
+
13
+ def permitted_params
14
+ model = (params.key?(:effective_representative) ? :effective_representative : :representative)
15
+ params.require(model).permit!
16
+ end
17
+
18
+ end
19
+ end
@@ -4,9 +4,8 @@ module Effective
4
4
 
5
5
  include Effective::WizardController
6
6
 
7
- resource_scope -> { EffectiveMemberships.Applicant.deep.where(owner: current_user.effective_memberships_owners) }
8
-
9
- submit :resubmit, 'Submit Application'
7
+ resource_scope -> { EffectiveMemberships.Applicant.deep.where(user: current_user) }
10
8
 
9
+ submit :resubmit, 'Resubmit Application'
11
10
  end
12
11
  end
@@ -4,7 +4,6 @@ module Effective
4
4
 
5
5
  include Effective::WizardController
6
6
 
7
- resource_scope -> { EffectiveMemberships.FeePayment.deep.where(owner: current_user.effective_memberships_owners) }
8
-
7
+ resource_scope -> { EffectiveMemberships.FeePayment.deep.where(user: current_user) }
9
8
  end
10
9
  end
@@ -0,0 +1,16 @@
1
+ module Effective
2
+ class OrganizationsController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+
5
+ include Effective::CrudController
6
+
7
+ resource_scope -> { EffectiveMemberships.Organization.deep.where(id: current_user.organizations) }
8
+
9
+ private
10
+
11
+ def permitted_params
12
+ params.require(:organization).permit!
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ module Effective
2
+ class RepresentativesController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+
5
+ include Effective::CrudController
6
+
7
+ resource_scope -> {
8
+ organizations = EffectiveMemberships.Organization.deep.where(id: current_user.organizations)
9
+ Effective::Representative.deep.where(organization: organizations)
10
+ }
11
+
12
+ private
13
+
14
+ def permitted_params
15
+ params.require(:effective_representative).permit!
16
+ end
17
+
18
+ end
19
+ end
@@ -26,7 +26,8 @@ module Admin
26
26
 
27
27
  col :approved_at, label: 'Approved', visible: false, as: :date
28
28
 
29
- col :owner
29
+ col :user
30
+ col :organization
30
31
 
31
32
  col :applicant_type
32
33
  col :category, search: { collection: EffectiveMemberships.Category.all, polymorphic: false }
@@ -40,14 +41,18 @@ module Admin
40
41
  collection do
41
42
  applicants = EffectiveMemberships.Applicant.deep.all
42
43
 
43
- raise('expected an owner_id, not user_id') if attributes[:user_id].present?
44
+ raise('expected a user_id or organization_id, not owner_id') if attributes[:owner_id].present?
44
45
 
45
- if scope == :in_progress && attributes[:owner_id].blank?
46
+ if scope == :in_progress && attributes[:user_id].blank? && attributes[:organization_id].blank?
46
47
  applicants = applicants.where.not(status: :draft)
47
48
  end
48
49
 
49
- if attributes[:owner_id].present?
50
- applicants = applicants.where(owner_id: attributes[:owner_id])
50
+ if attributes[:user_id].present?
51
+ applicants = applicants.where(user_id: attributes[:owner_id])
52
+ end
53
+
54
+ if attributes[:organization_id].present?
55
+ applicants = applicants.where(organization_id: attributes[:organization_id])
51
56
  end
52
57
 
53
58
  if attributes[:except_id].present?
@@ -8,13 +8,20 @@ module Admin
8
8
  col :id, visible: false
9
9
 
10
10
  col :title
11
+ col :can_apply_new, label: 'Can Apply'
11
12
  col :applicant_fee, as: :price
13
+
12
14
  col :renewal_fee, as: :price
13
15
  col :late_fee, as: :price
14
16
  col :rich_text_body, label: 'Body'
15
17
  col :tax_exempt
16
18
  col :qb_item_name, visible: false
17
19
 
20
+ col :category_type, search: EffectiveMemberships.Category.category_types
21
+
22
+ col :optional_applicant_wizard_steps, label: 'Applicant Steps'
23
+ col :optional_fee_payment_wizard_steps, label: 'Fee Payment Steps'
24
+
18
25
  actions_col
19
26
  end
20
27
 
@@ -18,7 +18,8 @@ module Admin
18
18
  col :period, visible: false
19
19
  col :submitted_at, label: 'Submitted', visible: false, as: :date
20
20
 
21
- col :owner
21
+ col :user
22
+ col :organization
22
23
 
23
24
  col :category, search: { collection: EffectiveMemberships.Category.all, polymorphic: false }
24
25
 
@@ -27,17 +28,21 @@ module Admin
27
28
  actions_col
28
29
  end
29
30
 
30
- collection do
31
+ collection(apply_belongs_to: false) do
31
32
  fee_payments = EffectiveMemberships.FeePayment.deep.all
32
33
 
33
- raise('expected an owner_id, not user_id') if attributes[:user_id].present?
34
+ raise('expected an user_id but was given an owner_id') if attributes[:owner_id].present?
34
35
 
35
- if fee_payments == :in_progress && attributes[:owner_id].blank?
36
+ if fee_payments == :in_progress && attributes[:user_id].blank? && attributes[:organization_id].blank?
36
37
  fee_payments = fee_payments.where.not(status: :draft)
37
38
  end
38
39
 
39
- if attributes[:owner_id].present?
40
- fee_payments = fee_payments.where(owner_id: attributes[:owner_id])
40
+ if attributes[:user_id].present?
41
+ fee_payments = fee_payments.where(user_id: attributes[:user_id])
42
+ end
43
+
44
+ if attributes[:organization_id].present?
45
+ fee_payments = fee_payments.where(organization_id: attributes[:organization_id])
41
46
  end
42
47
 
43
48
  if attributes[:except_id].present?
@@ -0,0 +1,31 @@
1
+ module Admin
2
+ class EffectiveOrganizationsDatatable < Effective::Datatable
3
+ datatable do
4
+
5
+ col :updated_at, visible: false
6
+ col :created_at, visible: false
7
+
8
+ col :id, visible: false
9
+
10
+ if categories.present?
11
+ col :category, search: categories
12
+ end
13
+
14
+ col :title
15
+
16
+ col :representatives_count
17
+ col :representatives
18
+
19
+ actions_col
20
+ end
21
+
22
+ collection do
23
+ EffectiveMemberships.Organization.deep.all
24
+ end
25
+
26
+ def categories
27
+ EffectiveMemberships.Organization.categories
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,28 @@
1
+ module Admin
2
+ class EffectiveRepresentativesDatatable < Effective::Datatable
3
+ datatable do
4
+ col :id, visible: false
5
+ col :user_id, visible: false
6
+
7
+ col :organization
8
+ col :user
9
+
10
+ col :email do |representative|
11
+ mail_to(representative.user.email)
12
+ end
13
+
14
+ col :roles, search: roles_collection
15
+
16
+ actions_col
17
+ end
18
+
19
+ collection do
20
+ Effective::Representative.deep.all
21
+ end
22
+
23
+ def roles_collection
24
+ EffectiveRoles.roles_collection(Effective::Representative.new).map(&:second)
25
+ end
26
+
27
+ end
28
+ end
@@ -34,7 +34,7 @@ class EffectiveApplicantsDatatable < Effective::Datatable
34
34
  end
35
35
 
36
36
  collection do
37
- EffectiveMemberships.Applicant.deep.where(owner: current_user.effective_memberships_owners)
37
+ EffectiveMemberships.Applicant.deep.for(current_user)
38
38
  end
39
39
 
40
40
  end
@@ -6,7 +6,9 @@ class EffectiveFeePaymentsDatatable < Effective::Datatable
6
6
  col :token, visible: false
7
7
  col :created_at, visible: false
8
8
 
9
- col :owner
9
+ col :user
10
+ col :organization
11
+
10
12
  col :status, visible: false
11
13
  col :submitted_at, label: 'Submitted', as: :date
12
14
  col :period, visible: false
@@ -16,9 +18,8 @@ class EffectiveFeePaymentsDatatable < Effective::Datatable
16
18
  actions_col(new: false)
17
19
  end
18
20
 
19
- collection do
20
- EffectiveMemberships.FeePayment.deep.done
21
- .where(owner: current_user.effective_memberships_owners)
21
+ collection(apply_belongs_to: false) do
22
+ scope = EffectiveMemberships.FeePayment.deep.done.for(current_user)
22
23
  end
23
24
 
24
25
  end
@@ -0,0 +1,18 @@
1
+ # Dashboard Organizations
2
+ class EffectiveOrganizationsDatatable < Effective::Datatable
3
+ datatable do
4
+ order :title
5
+
6
+ col :id, visible: false
7
+
8
+ col :title
9
+ col :representatives
10
+
11
+ actions_col
12
+ end
13
+
14
+ collection do
15
+ EffectiveMemberships.Organization.deep.where(id: current_user.organizations)
16
+ end
17
+
18
+ end
@@ -0,0 +1,40 @@
1
+ class EffectiveRepresentativesDatatable < Effective::Datatable
2
+ datatable do
3
+ col :id, visible: false
4
+
5
+ col :organization
6
+ col :user
7
+
8
+ unless attributes[:user_id]
9
+ col :email do |representative|
10
+ mail_to(representative.user.email)
11
+ end
12
+ end
13
+
14
+ col :roles, search: roles_collection
15
+
16
+ unless attributes[:actions] == false
17
+ actions_col
18
+ end
19
+
20
+ end
21
+
22
+ collection do
23
+ scope = Effective::Representative.deep.all.where(organization: current_user.organizations)
24
+
25
+ if attributes[:organization_id]
26
+ scope = scope.where(organization_id: attributes[:organization_id])
27
+ end
28
+
29
+ if attributes[:user_id]
30
+ scope = scope.where(user_id: attributes[:user_id])
31
+ end
32
+
33
+ scope
34
+ end
35
+
36
+ def roles_collection
37
+ EffectiveRoles.roles_collection(Effective::Representative.new).map(&:second)
38
+ end
39
+
40
+ end
@@ -8,4 +8,29 @@ module EffectiveMembershipsHelper
8
8
  end.compact
9
9
  end
10
10
 
11
+ def effective_memberships_select_applicant_organization_collection(resource)
12
+ user = (resource.respond_to?(:user) ? resource.user : resource)
13
+ raise('expected an effective memberships user') unless user.class.try(:effective_memberships_user?)
14
+
15
+ representatives = user.representatives.select { |rep| rep.is?(:owner) || rep.is?(:billing) }
16
+ organizations = representatives.map { |rep| [rep.organization.to_s, rep.organization.id] }
17
+
18
+ organizations + [['New Organization...', 'new']]
19
+ end
20
+
21
+ # This is the select yourself or organization field on FeePayments#start
22
+ def effective_memberships_select_fee_payment_organization(resource)
23
+ user = (resource.respond_to?(:user) ? resource.user : resource)
24
+ raise('expected an effective memberships user') unless user.class.try(:effective_memberships_user?)
25
+
26
+ owners = user.memberships_owners.select { |owner| owner.outstanding_fee_payment_fees.present? }
27
+
28
+ owners.map do |owner|
29
+ [
30
+ owner.to_s,
31
+ (owner.to_param if owner.kind_of?(EffectiveMemberships.Organization)) # Nil when user
32
+ ]
33
+ end
34
+ end
35
+
11
36
  end
@@ -1,48 +1,68 @@
1
1
  module Effective
2
2
  class MembershipsMailer < EffectiveMemberships.parent_mailer_class
3
- include EffectiveEmailTemplatesMailer
4
3
 
5
- default from: -> { EffectiveMemberships.mailer_sender }
6
- layout -> { EffectiveMemberships.mailer_layout || 'effective_memberships_mailer_layout' }
4
+ include EffectiveMailer
5
+ include EffectiveEmailTemplatesMailer if EffectiveMemberships.use_effective_email_templates
7
6
 
8
7
  def applicant_completed(resource, opts = {})
9
8
  @assigns = assigns_for(resource)
10
- mail(to: resource.owner.email, **headers_for(resource, opts))
9
+ @applicant = resource
10
+
11
+ subject = subject_for(__method__, 'Applicant Completed', resource, opts)
12
+ headers = headers_for(resource, opts)
13
+
14
+ mail(to: resource.user.email, subject: subject, **headers)
11
15
  end
12
16
 
13
17
  def applicant_missing_info(resource, opts = {})
14
18
  @assigns = assigns_for(resource)
15
- mail(to: resource.owner.email, **headers_for(resource, opts))
19
+ @applicant = resource
20
+
21
+ subject = subject_for(__method__, 'Applicant Missing Info', resource, opts)
22
+ headers = headers_for(resource, opts)
23
+
24
+ mail(to: resource.user.email, subject: subject, **headers)
16
25
  end
17
26
 
18
27
  def applicant_approved(resource, opts = {})
19
28
  @assigns = assigns_for(resource)
20
- mail(to: resource.owner.email, **headers_for(resource, opts))
29
+ @applicant = resource
30
+
31
+ subject = subject_for(__method__, 'Applicant Approved', resource, opts)
32
+ headers = headers_for(resource, opts)
33
+
34
+ mail(to: resource.user.email, subject: subject, **headers)
21
35
  end
22
36
 
23
37
  def applicant_declined(resource, opts = {})
24
38
  @assigns = assigns_for(resource)
25
- mail(to: resource.owner.email, **headers_for(resource, opts))
39
+ @applicant = resource
40
+
41
+ subject = subject_for(__method__, 'Applicant Declined', resource, opts)
42
+ headers = headers_for(resource, opts)
43
+
44
+ mail(to: resource.user.email, subject: subject, **headers)
26
45
  end
27
46
 
28
47
  def applicant_reference_notification(resource, opts = {})
29
48
  @assigns = assigns_for(resource)
30
- mail(to: resource.email, **headers_for(resource, opts))
31
- end
49
+ @applicant_reference = resource
32
50
 
33
- protected
51
+ subject = subject_for(__method__, 'Reference Requested', resource, opts)
52
+ headers = headers_for(resource, opts)
34
53
 
35
- def headers_for(resource, opts = {})
36
- resource.respond_to?(:log_changes_datatable) ? opts.merge(log: resource) : opts
54
+ mail(to: resource.email, subject: subject, **headers)
37
55
  end
38
56
 
57
+ protected
58
+
39
59
  def assigns_for(resource)
40
60
  if resource.class.respond_to?(:effective_memberships_applicant?)
41
- return applicant_assigns(resource).merge(user_assigns(resource.owner))
61
+ return applicant_assigns(resource).merge(owner_assigns(resource.owner))
42
62
  end
43
63
 
44
64
  if resource.kind_of?(Effective::ApplicantReference)
45
- return reference_assigns(resource).merge(user_assigns(resource.applicant.owner))
65
+ return reference_assigns(resource).merge(owner_assigns(resource.applicant.owner))
46
66
  end
47
67
 
48
68
  raise('unexpected resource')
@@ -79,7 +99,7 @@ module Effective
79
99
  { reference: values }
80
100
  end
81
101
 
82
- def user_assigns(owner)
102
+ def owner_assigns(owner)
83
103
  raise('expected a owner') unless owner.class.respond_to?(:effective_memberships_owner?)
84
104
 
85
105
  values = {