effective_memberships 0.3.14 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/admin/membership_histories_controller.rb +24 -0
  3. data/app/controllers/admin/memberships_controller.rb +15 -0
  4. data/app/controllers/admin/organizations_controller.rb +19 -0
  5. data/app/controllers/admin/representatives_controller.rb +19 -0
  6. data/app/controllers/effective/applicants_controller.rb +2 -3
  7. data/app/controllers/effective/fee_payments_controller.rb +1 -2
  8. data/app/controllers/effective/organizations_controller.rb +16 -0
  9. data/app/controllers/effective/representatives_controller.rb +19 -0
  10. data/app/datatables/admin/effective_applicant_references_datatable.rb +22 -20
  11. data/app/datatables/admin/effective_applicants_datatable.rb +10 -5
  12. data/app/datatables/admin/effective_categories_datatable.rb +7 -0
  13. data/app/datatables/admin/effective_fee_payments_datatable.rb +11 -6
  14. data/app/datatables/admin/effective_fees_datatable.rb +2 -2
  15. data/app/datatables/admin/effective_membership_histories_datatable.rb +7 -3
  16. data/app/datatables/admin/effective_memberships_datatable.rb +2 -2
  17. data/app/datatables/admin/effective_organizations_datatable.rb +31 -0
  18. data/app/datatables/admin/effective_representatives_datatable.rb +28 -0
  19. data/app/datatables/effective_applicants_datatable.rb +1 -1
  20. data/app/datatables/effective_fee_payments_datatable.rb +5 -4
  21. data/app/datatables/effective_organizations_datatable.rb +18 -0
  22. data/app/datatables/effective_representatives_datatable.rb +40 -0
  23. data/app/helpers/effective_memberships_helper.rb +25 -0
  24. data/app/mailers/effective/memberships_mailer.rb +7 -7
  25. data/app/models/concerns/effective_memberships_applicant.rb +63 -30
  26. data/app/models/concerns/effective_memberships_category.rb +32 -5
  27. data/app/models/concerns/effective_memberships_fee_payment.rb +44 -45
  28. data/app/models/concerns/effective_memberships_organization.rb +94 -0
  29. data/app/models/concerns/effective_memberships_owner.rb +44 -55
  30. data/app/models/concerns/effective_memberships_registrar.rb +5 -3
  31. data/app/models/concerns/effective_memberships_user.rb +70 -0
  32. data/app/models/effective/fee.rb +1 -1
  33. data/app/models/effective/membership.rb +24 -2
  34. data/app/models/effective/membership_history.rb +15 -0
  35. data/app/models/effective/organization.rb +8 -0
  36. data/app/models/effective/registrar_action.rb +16 -1
  37. data/app/models/effective/representative.rb +56 -0
  38. data/app/views/admin/categories/_form_applicant_eligibility.html.haml +1 -1
  39. data/app/views/admin/categories/_form_applicant_steps.html.haml +29 -24
  40. data/app/views/admin/categories/_form_category.html.haml +3 -0
  41. data/app/views/admin/categories/_form_renewals.html.haml +0 -2
  42. data/app/views/admin/membership_histories/_form.html.haml +19 -0
  43. data/app/views/admin/membership_histories/_validation.html.haml +7 -0
  44. data/app/views/admin/memberships/_form.html.haml +17 -0
  45. data/app/views/admin/memberships/_form_membership.html.haml +22 -0
  46. data/app/views/admin/organizations/_fields.html.haml +6 -0
  47. data/app/views/admin/organizations/_form.html.haml +31 -0
  48. data/app/views/admin/organizations/_form_organization.html.haml +23 -0
  49. data/app/views/admin/registrar_actions/_form_fees_paid.html.haml +16 -0
  50. data/app/views/admin/representatives/_form.html.haml +38 -0
  51. data/app/views/{effective/applicants/_demographics_fields.html.haml → admin/representatives/_user_fields.html.haml} +2 -6
  52. data/app/views/effective/applicants/_dashboard.html.haml +24 -5
  53. data/app/views/effective/applicants/_demographics.html.haml +1 -1
  54. data/app/views/effective/applicants/_missing_info.html.haml +7 -3
  55. data/app/views/effective/applicants/_organization.html.haml +9 -0
  56. data/app/views/effective/applicants/_select_organization.html.haml +21 -0
  57. data/app/views/effective/applicants/_summary.html.haml +17 -9
  58. data/app/views/effective/applicants/billing.html.haml +2 -2
  59. data/app/views/effective/applicants/demographics.html.haml +7 -6
  60. data/app/views/effective/applicants/education.html.haml +2 -2
  61. data/app/views/effective/applicants/organization.html.haml +19 -0
  62. data/app/views/effective/applicants/references.html.haml +1 -1
  63. data/app/views/effective/applicants/select.html.haml +11 -1
  64. data/app/views/effective/applicants/stamp.html.haml +2 -2
  65. data/app/views/effective/applicants/start.html.haml +17 -11
  66. data/app/views/effective/applicants/submitted.html.haml +5 -5
  67. data/app/views/effective/applicants/summary.html.haml +1 -1
  68. data/app/views/effective/fee_payments/_demographics.html.haml +1 -1
  69. data/app/views/effective/fee_payments/_organization.html.haml +9 -0
  70. data/app/views/effective/fee_payments/_summary.html.haml +39 -1
  71. data/app/views/effective/fee_payments/billing.html.haml +2 -2
  72. data/app/views/effective/fee_payments/demographics.html.haml +2 -2
  73. data/app/views/effective/fee_payments/organization.html.haml +18 -0
  74. data/app/views/effective/fee_payments/start.html.haml +20 -17
  75. data/app/views/effective/fee_payments/submitted.html.haml +10 -3
  76. data/app/views/effective/fees/_dashboard.html.haml +20 -8
  77. data/app/views/effective/memberships/_dashboard.html.haml +16 -5
  78. data/app/views/effective/organizations/_dashboard.html.haml +10 -0
  79. data/app/views/effective/organizations/_form.html.haml +8 -0
  80. data/app/views/effective/organizations/_form_organization.html.haml +11 -0
  81. data/app/views/effective/representatives/_form.html.haml +33 -0
  82. data/app/views/effective/{fee_payments/_demographics_fields.html.haml → representatives/_user_fields.html.haml} +2 -6
  83. data/app/views/organizations/_demographics.html.haml +45 -0
  84. data/app/views/organizations/_fields_demographics.html.haml +29 -0
  85. data/app/views/users/_demographics.html.haml +50 -0
  86. data/app/views/users/_fields_demographics.html.haml +29 -0
  87. data/config/effective_memberships.rb +3 -0
  88. data/config/routes.rb +11 -1
  89. data/db/migrate/01_create_effective_memberships.rb.erb +57 -10
  90. data/db/seeds.rb +18 -0
  91. data/lib/effective_memberships/engine.rb +3 -0
  92. data/lib/effective_memberships/version.rb +1 -1
  93. data/lib/effective_memberships.rb +6 -2
  94. metadata +38 -20
  95. data/app/views/effective/applicants/_demographics_owner.html.haml +0 -20
  96. data/app/views/effective/fee_payments/_demographics_owner.html.haml +0 -20
@@ -0,0 +1,70 @@
1
+ # EffectiveMembershipsUser
2
+ #
3
+ # Mark your user model with effective_memberships_user to get all the includes
4
+
5
+ module EffectiveMembershipsUser
6
+ extend ActiveSupport::Concern
7
+
8
+ module Base
9
+ def effective_memberships_user
10
+ include ::EffectiveMembershipsUser
11
+ end
12
+ end
13
+
14
+ module ClassMethods
15
+ def effective_memberships_user?; true; end
16
+ end
17
+
18
+ included do
19
+ effective_memberships_owner
20
+
21
+ # App scoped
22
+ has_many :applicants, -> { order(:id) }, inverse_of: :user, as: :user
23
+ has_many :fee_payments, -> { order(:id) }, inverse_of: :user, as: :user
24
+
25
+ # Effective Scoped
26
+ has_many :representatives, -> { Effective::Representative.sorted },
27
+ class_name: 'Effective::Representative', inverse_of: :user, dependent: :delete_all
28
+
29
+ accepts_nested_attributes_for :representatives, allow_destroy: true
30
+ end
31
+
32
+ # Instance Methods
33
+ def memberships
34
+ Array(membership) + membership_organizations.map(&:membership)
35
+ end
36
+
37
+ def memberships_owners
38
+ Array(is?(:member) ? self : nil) + membership_organizations
39
+ end
40
+
41
+ def membership_present?
42
+ individual_membership_present? || organization_membership_present?
43
+ end
44
+
45
+ def individual_membership_present?
46
+ membership.present? && !membership.marked_for_destruction?
47
+ end
48
+
49
+ def organization_membership_present?(except: nil)
50
+ organizations.reject(&:archived?).any? { |organization| organization != except && organization.membership_present? }
51
+ end
52
+
53
+ def representative(organization:)
54
+ representatives.find { |rep| rep.organization_id == organization.id } if organization
55
+ end
56
+
57
+ # Find or build
58
+ def build_representative(organization:)
59
+ representative(organization: organization) || representatives.build(organization: organization)
60
+ end
61
+
62
+ def organizations
63
+ representatives.reject(&:marked_for_destruction?).map(&:organization)
64
+ end
65
+
66
+ def membership_organizations
67
+ organizations.select { |organization| organization.is?(:member) && !organization.archived? }
68
+ end
69
+
70
+ end
@@ -4,7 +4,7 @@ module Effective
4
4
 
5
5
  log_changes(to: :owner) if respond_to?(:log_changes)
6
6
 
7
- # Every fee is charged to a owner
7
+ # Every fee is charged to a owner: a user or an organization
8
8
  belongs_to :owner, polymorphic: true
9
9
 
10
10
  # This fee may belong to an application, fee payment, or other parent model
@@ -2,6 +2,8 @@ module Effective
2
2
  class Membership < ActiveRecord::Base
3
3
  belongs_to :owner, polymorphic: true
4
4
 
5
+ attr_accessor :current_action
6
+
5
7
  has_many :membership_categories, -> { order(:id) }, inverse_of: :membership, dependent: :delete_all
6
8
  accepts_nested_attributes_for :membership_categories
7
9
 
@@ -54,7 +56,10 @@ module Effective
54
56
 
55
57
  before_validation do
56
58
  self.registration_on ||= joined_on
57
- self.number_as_integer ||= (Integer(number) rescue nil)
59
+ end
60
+
61
+ before_validation(if: -> { number_changed? }) do
62
+ self.number_as_integer = (Integer(number) rescue nil)
58
63
  end
59
64
 
60
65
  validates :number, presence: true, uniqueness: true
@@ -66,12 +71,29 @@ module Effective
66
71
  self.errors.add(:owner_id, 'must be a memberships owner') unless owner.class.effective_memberships_owner?
67
72
  end
68
73
 
74
+ validate(if: -> { registration_on.present? && joined_on.present? }) do
75
+ self.errors.add(:registration_on, 'must match or be greater than the joined date') if registration_on < joined_on
76
+ end
77
+
69
78
  def self.max_number
70
79
  maximum('number_as_integer') || 0
71
80
  end
72
81
 
73
82
  def to_s
74
- 'membership'
83
+ return 'membership' if owner.blank?
84
+
85
+ summary = [
86
+ owner.to_s,
87
+ 'is',
88
+ (categories.to_sentence),
89
+ 'member',
90
+ "##{number_was}",
91
+ "who joined #{joined_on&.strftime('%F') || '-'}",
92
+ ("and last registered #{registration_on.strftime('%F')}" if registration_on > joined_on),
93
+ (". Membership is Not In Good Standing because #{bad_standing_reason}" if bad_standing?)
94
+ ].compact.join(' ')
95
+
96
+ (summary + '.').html_safe
75
97
  end
76
98
 
77
99
  # We can't use the polymorphic has_many. So this is a helper.
@@ -36,5 +36,20 @@ module Effective
36
36
  'membership history'
37
37
  end
38
38
 
39
+ # These two accessors are for the memberships history form.
40
+ # But we just assign categories and category_ids directly in registrar.
41
+ def membership_categories
42
+ category_ids.present? ? EffectiveMemberships.Category.where(id: category_ids) : []
43
+ end
44
+
45
+ def membership_category_ids
46
+ membership_categories.map(&:id)
47
+ end
48
+
49
+ def membership_category_ids=(ids)
50
+ categories = EffectiveMemberships.Category.where(id: ids)
51
+ assign_attributes(categories: categories.map(&:to_s), category_ids: categories.map(&:id))
52
+ end
53
+
39
54
  end
40
55
  end
@@ -0,0 +1,8 @@
1
+ module Effective
2
+ class Organization < ActiveRecord::Base
3
+ self.table_name = EffectiveMemberships.organizations_table_name.to_s
4
+
5
+ effective_memberships_organization
6
+
7
+ end
8
+ end
@@ -20,6 +20,12 @@ module Effective
20
20
  # Assign
21
21
  attr_accessor :category_ids
22
22
 
23
+ # Mark Fees Paid - Order Attributes
24
+ attr_accessor :payment_provider
25
+ attr_accessor :payment_card
26
+ attr_accessor :note_to_buyer
27
+ attr_accessor :note_internal
28
+
23
29
  # All Action Validations
24
30
  validates :current_action, presence: true
25
31
  validates :current_user, presence: true
@@ -65,7 +71,7 @@ module Effective
65
71
 
66
72
  def fees_paid!
67
73
  update!(current_action: :fees_paid)
68
- EffectiveMemberships.Registrar.fees_paid!(owner)
74
+ EffectiveMemberships.Registrar.fees_paid!(owner, order_attributes: order_attributes)
69
75
  end
70
76
 
71
77
  def remove!
@@ -103,6 +109,15 @@ module Effective
103
109
  EffectiveMemberships.Category.where(id: @category_ids) if @category_ids
104
110
  end
105
111
 
112
+ def order_attributes
113
+ {
114
+ payment_provider: @payment_provider.presence,
115
+ payment_card: @payment_card.presence,
116
+ note_to_buyer: @note_to_buyer.presence,
117
+ note_internal: @note_internal.presence
118
+ }.compact
119
+ end
120
+
106
121
  def skip_fees?
107
122
  EffectiveResources.truthy?(@skip_fees)
108
123
  end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Effective
4
+ class Representative < ActiveRecord::Base
5
+ attr_accessor :new_representative_user_action
6
+
7
+ acts_as_role_restricted
8
+
9
+ log_changes(to: :organization) if respond_to?(:log_changes)
10
+
11
+ belongs_to :organization, polymorphic: true, counter_cache: true
12
+ belongs_to :user, polymorphic: true
13
+
14
+ accepts_nested_attributes_for :organization
15
+ accepts_nested_attributes_for :user
16
+
17
+ effective_resource do
18
+ roles_mask :integer
19
+
20
+ timestamps
21
+ end
22
+
23
+ scope :sorted, -> { order(:id) }
24
+ scope :deep, -> { includes(:user, :organization) }
25
+
26
+ before_validation(if: -> { user && user.new_record? }) do
27
+ user.password ||= SecureRandom.base64(12) + '!@#123abcABC-'
28
+ end
29
+
30
+ after_commit(on: [:create, :destroy], if: -> { user.class.respond_to?(:effective_memberships_owner?) }) do
31
+ user.representatives.reload
32
+ user.update_member_role!
33
+ end
34
+
35
+ validates :organization, presence: true
36
+ validates :user, presence: true
37
+
38
+ validates :user_id, if: -> { user_id && user_type && organization_id && organization_type },
39
+ uniqueness: { scope: [:organization_id, :organization_type], message: 'already belongs to this organization' }
40
+
41
+ def to_s
42
+ user.to_s
43
+ end
44
+
45
+ def build_user(attributes = {})
46
+ raise('please assign user_type first') if user_type.blank?
47
+ self.user = user_type.constantize.new(attributes)
48
+ end
49
+
50
+ def build_organization(attributes = {})
51
+ raise('please assign organization_type first') if organization_type.blank?
52
+ self.organization = organization_type.constantize.new(attributes)
53
+ end
54
+
55
+ end
56
+ end
@@ -2,7 +2,7 @@
2
2
  %h3 Eligibility
3
3
  %p Please configure who may apply for this membership category.
4
4
 
5
- = f.check_box :can_apply_new, label: 'Yes, new users may apply to join'
5
+ = f.check_box :can_apply_new, label: 'Yes, new applicants may apply to join'
6
6
  = f.check_box :can_apply_existing, label: 'Yes, existing members of any category may apply to join'
7
7
  = f.check_box :can_apply_restricted, label: 'Only existing members of the following categories may apply to join'
8
8
 
@@ -14,29 +14,34 @@
14
14
 
15
15
  %table.table.table-sm
16
16
  %tbody
17
- %tr
18
- %td= applicant.wizard_step_title(:education)
19
- %td= f.number_field :min_applicant_educations, label: false
20
- %td minimum number of degrees
21
-
22
- %tr
23
- %td= applicant.wizard_step_title(:course_amounts)
24
- %td= f.number_field :min_applicant_courses, label: false
25
- %td minimum number of courses
26
-
27
- %tr
28
- %td= applicant.wizard_step_title(:experience)
29
- %td= f.number_field :min_applicant_experiences_months, label: false
30
- %td minimimum months of work experience
31
-
32
- %tr
33
- %td= applicant.wizard_step_title(:references)
34
- %td= f.number_field :min_applicant_references, label: false
35
- %td minimimum number of references
36
-
37
- %tr
38
- %td= applicant.wizard_step_title(:files)
39
- %td= f.number_field :min_applicant_files, label: false
40
- %td minimimum number of attached files
17
+ - if applicant.wizard_step_keys.include?(:education)
18
+ %tr
19
+ %td= applicant.wizard_step_title(:education)
20
+ %td= f.number_field :min_applicant_educations, label: false
21
+ %td minimum number of degrees
22
+
23
+ - if applicant.wizard_step_keys.include?(:course_amounts)
24
+ %tr
25
+ %td= applicant.wizard_step_title(:course_amounts)
26
+ %td= f.number_field :min_applicant_courses, label: false
27
+ %td minimum number of courses
28
+
29
+ - if applicant.wizard_step_keys.include?(:experience)
30
+ %tr
31
+ %td= applicant.wizard_step_title(:experience)
32
+ %td= f.number_field :min_applicant_experiences_months, label: false
33
+ %td minimimum months of work experience
34
+
35
+ - if applicant.wizard_step_keys.include?(:references)
36
+ %tr
37
+ %td= applicant.wizard_step_title(:references)
38
+ %td= f.number_field :min_applicant_references, label: false
39
+ %td minimimum number of references
40
+
41
+ - if applicant.wizard_step_keys.include?(:files)
42
+ %tr
43
+ %td= applicant.wizard_step_title(:files)
44
+ %td= f.number_field :min_applicant_files, label: false
45
+ %td minimimum number of attached files
41
46
 
42
47
  = f.submit
@@ -1,6 +1,9 @@
1
1
  = effective_form_with(model: [:admin, category], engine: true) do |f|
2
2
  = f.text_field :title
3
3
 
4
+ = f.select :category_type, f.object.class.category_types,
5
+ hint: 'When Organization, the organization will be given membership. Otherwise the individual user'
6
+
4
7
  - if f.object.class.categories.present?
5
8
  = f.select :category, f.object.class.categories
6
9
 
@@ -1,6 +1,4 @@
1
1
  = effective_form_with(model: [:admin, category], engine: true) do |f|
2
- %h2 Renewals
3
-
4
2
  %h3 Renewal Fees
5
3
  = f.check_box :create_renewal_fees, label: 'Yes, renewal fees should be created'
6
4
 
@@ -0,0 +1,19 @@
1
+ = effective_form_with(model: [:admin, membership_history], engine: true) do |f|
2
+ - if inline_datatable?
3
+ = f.hidden_field :owner_id
4
+ = f.hidden_field :owner_type
5
+ - else
6
+ - raise('todo')
7
+ - collection = EffectiveMembershipsOwner.descendants.map { |d| [d.name.to_s, d.members.sorted] }.to_h
8
+ = f.select :owner_id, collection, polymorphic: true
9
+
10
+ = f.date_field :start_on, hint: 'The start date of this period in history. Must be present.'
11
+
12
+ = f.date_field :end_on, hint: 'The end date of this period in history. Must be present for all past histories. Must be blank in the most recent history, unless membership removed.'
13
+ = f.text_field :number, hint: 'The membership number'
14
+ = f.select :membership_category_ids, EffectiveMemberships.Category.all.sorted, label: 'Membership Categories', hint: 'The membership category or categories held during this period in history.'
15
+
16
+ = f.check_box :bad_standing, hint: 'Membership in bad standing'
17
+ = f.check_box :removed, hint: 'Membership removed'
18
+
19
+ = f.submit 'Update History', border: false, center: true, 'data-confirm': "Really update #{f.object.owner}?"
@@ -0,0 +1,7 @@
1
+ - raise('expected a memberships owner with a membership') unless owner.present? && owner.try(:membership).present?
2
+
3
+ - errors = owner.membership_history_errors
4
+
5
+ - if errors.present?
6
+ - errors.each do |error|
7
+ .mb-2.alert.alert-warning= error
@@ -0,0 +1,17 @@
1
+ - membership ||= owner.membership
2
+ - owner ||= membership.owner
3
+
4
+ - if membership.present?
5
+ = card('Member Information') do
6
+ = render 'admin/memberships/form_membership', membership: membership
7
+
8
+ = card('History') do
9
+ = render 'admin/membership_histories/validation', owner: owner
10
+ = render_datatable(Admin::EffectiveMembershipHistoriesDatatable.new(owner: owner), inline: true, simple: true)
11
+
12
+ - # Always render this one
13
+ = render 'admin/registrar_actions/form', owner: owner
14
+
15
+ - if membership.blank? && owner.membership_histories.present?
16
+ = card('History') do
17
+ = render_datatable(Admin::EffectiveMembershipHistoriesDatatable.new(owner: owner), inline: true, simple: true)
@@ -0,0 +1,22 @@
1
+ = effective_form_with(model: [:admin, membership], engine: true) do |f|
2
+ = f.hidden_field :owner_id
3
+ = f.hidden_field :owner_type
4
+
5
+ %p.text-muted
6
+ Change a member's information.
7
+
8
+ - f.object.current_action = true if f.errors.present?
9
+
10
+ = f.static_field :current_action, label: 'Current Membership' do
11
+ = membership.to_s
12
+
13
+ = f.check_box :current_action, label: 'Yes, update membership information'
14
+
15
+ = f.show_if :current_action, true do
16
+ = f.date_field :joined_on, label: 'Joined', hint: 'When the member first received any membership category'
17
+ = f.date_field :registration_on, label: 'Registered', hint: 'When the membership category last changed'
18
+ = f.text_field :number, hint: 'The membership number. Must be unique.'
19
+
20
+ %p.text-muted To update the current membership categories, use the 'Assign' or 'Reclassify' actions below
21
+
22
+ = f.submit 'Update Membership', border: false, center: true, 'data-confirm': "Really update #{f.object.owner}?"
@@ -0,0 +1,6 @@
1
+ - categories = EffectiveMemberships.Organization.categories
2
+
3
+ - if categories.present?
4
+ = f.select :category, categories, required: true
5
+
6
+ = f.text_field :title
@@ -0,0 +1,31 @@
1
+ = tabs do
2
+ = tab 'Company Info' do
3
+ = render 'admin/organizations/form_organization', organization: organization
4
+
5
+ - if organization.persisted?
6
+ - if can?(:index, Effective::Membership)
7
+ = tab 'Membership' do
8
+ = render 'admin/registrar_actions/form', owner: organization
9
+
10
+ = tab 'Representatives' do
11
+ = render_datatable(Admin::EffectiveRepresentativesDatatable.new(organization: organization), inline: true, namespace: :admin)
12
+
13
+ - if can?(:index, Effective::Fee)
14
+ = tab 'Fees' do
15
+ = render_inline_datatable(Admin::EffectiveFeesDatatable.new(owner: organization))
16
+
17
+ - if can?(:index, EffectiveMemberships.FeePayment)
18
+ = tab 'Fee Payments' do
19
+ = render_inline_datatable(Admin::EffectiveFeePaymentsDatatable.new(organization: organization))
20
+
21
+ - if can?(:index, Effective::MembershipHistory)
22
+ = tab 'History' do
23
+ = render_datatable(Admin::EffectiveMembershipHistoriesDatatable.new(owner: organization))
24
+
25
+ - if can?(:index, Effective::Order)
26
+ = tab 'Orders' do
27
+ = render_datatable(Admin::EffectiveOrdersDatatable.new(user: organization))
28
+
29
+ - if can?(:index, Effective::Log)
30
+ = tab 'Logs' do
31
+ = render_datatable(organization.log_changes_datatable, inline: true, namespace: :admin)
@@ -0,0 +1,23 @@
1
+ = effective_form_with(model: [:admin, organization], engine: true) do |f|
2
+ .row
3
+ .col-sm-6
4
+ %h2 Demographics
5
+ = render 'admin/organizations/fields', f: f
6
+
7
+ %h2 Billing Address
8
+ = effective_address_fields(f, :billing)
9
+
10
+ .col-sm-6
11
+ %h2 Membership
12
+ = render 'admin/memberships/status', owner: f.object
13
+
14
+ - f.object.users.each do |user|
15
+ %p
16
+ = link_to(user, "/admin/users/#{user.to_param}/edit")
17
+ - if user.try(:archived?)
18
+ %span.badge.badge-warning Archived
19
+
20
+ %h2 Admin Only
21
+ %p No additional fields
22
+
23
+ = effective_submit(f)
@@ -25,6 +25,22 @@
25
25
  = f.check_box :current_action, label: 'Yes, mark this members fees paid in full'
26
26
 
27
27
  = f.show_if :current_action, true do
28
+ - if fees.blank?
29
+ %p There are no outstanding fee payment fees, so no order will be created.
30
+ - else
31
+ %p An order will be created and marked as paid with the following information:
32
+
33
+ = f.select :payment_provider, EffectiveOrders.admin_payment_providers, required: true
34
+
35
+ = f.text_field :payment_card,
36
+ label: 'Payment card type, cheque or transaction number',
37
+ hint: 'Do not enter credit card numbers here, or anywhere.'
38
+
39
+ .row
40
+ .col
41
+ = f.text_area :note_to_buyer, hint: 'This message will be displayed to the buyer on the receipt.'
42
+ .col
43
+ = f.text_area :note_internal, hint: 'For or internal admin use only. This note will never be displayed to the buyer.'
28
44
 
29
45
  = f.submit 'Mark Fees Paid', border: false, center: true,
30
46
  'data-confirm': "Really mark #{f.object.owner} fees paid?"
@@ -0,0 +1,38 @@
1
+ = effective_form_with(model: [:admin, representative], engine: true) do |f|
2
+ - f.object.user_type ||= current_user.class.name
3
+
4
+ = f.hidden_field :user_id
5
+ = f.hidden_field :user_type
6
+ = f.hidden_field :organization_id
7
+ = f.hidden_field :organization_type
8
+
9
+ - if f.object.new_record?
10
+ - unless inline_datatable? && inline_datatable.attributes[:organization_id].present?
11
+ = f.select :organization, { 'Organizations' => EffectiveMemberships.Organization.sorted }, polymorphic: true
12
+
13
+ = f.checks :roles, EffectiveRoles.roles_collection(f.object, skip_disabled: true)
14
+
15
+ - unless inline_datatable? && inline_datatable.attributes[:user_id].present?
16
+ = f.radios :new_representative_user_action, ['Invite new user', 'Add existing user'], inline: true, label: 'Representative'
17
+
18
+ = f.show_if :new_representative_user_action, 'Add existing user' do
19
+ = f.select :user, {'Users' => current_user.class.sorted }, polymorphic: true
20
+
21
+ = f.show_if :new_representative_user_action, 'Invite new user' do
22
+ = f.fields_for :user, (f.object.user || f.object.build_user) do |fu|
23
+ = render 'admin/representatives/user_fields', f: fu
24
+
25
+ - if f.object.persisted?
26
+ - unless inline_datatable? && inline_datatable.attributes[:organization_id].present?
27
+ = f.static_field :organization
28
+
29
+ - unless inline_datatable? && inline_datatable.attributes[:user_id].present?
30
+ = f.static_field :user
31
+
32
+ = f.checks :roles, EffectiveRoles.roles_collection(f.object, skip_disabled: true)
33
+
34
+ - unless inline_datatable? && inline_datatable.attributes[:user_id].present?
35
+ = f.fields_for :user, f.object.user do |fu|
36
+ = render 'admin/representatives/user_fields', f: fu
37
+
38
+ = f.submit
@@ -1,11 +1,7 @@
1
+ = f.email_field :email
2
+
1
3
  - if f.object.respond_to?(:first_name)
2
4
  = f.text_field :first_name
3
5
 
4
6
  - if f.object.respond_to?(:last_name)
5
7
  = f.text_field :last_name
6
-
7
- - if f.object.respond_to?(:date_of_birth)
8
- = f.date_field :date_of_birth
9
-
10
- - if f.object.respond_to?(:phone)
11
- = f.tel_field :phone
@@ -1,12 +1,31 @@
1
1
  - authorized = EffectiveResources.authorized?(self, :new, EffectiveMemberships.Applicant)
2
2
  - datatable = EffectiveResources.best('EffectiveApplicantsDatatable').new(self)
3
- - in_progress = current_user.effective_memberships_owner.applicants.in_progress
4
3
 
5
- - if in_progress.present?
4
+ - # In progress
5
+ - applicant = current_user.applicants.in_progress.first
6
+
7
+ - if applicant.present? && applicant.draft?
8
+ %h2 In-Progress Application
9
+
10
+ %p
11
+ Your submission is incomplete.
12
+
13
+ %p
14
+ Please
15
+ = link_to("Continue application", effective_memberships.applicant_build_path(applicant, applicant.next_step), 'data-turbolinks' => false, class: 'btn btn-primary')
16
+ or you can
17
+ = link_to('Abandon application', effective_memberships.applicant_path(applicant), 'data-confirm': "Really delete #{applicant}?", 'data-method': :delete, class: 'btn btn-danger')
18
+ to apply again.
19
+
20
+ %hr
21
+
22
+ - elsif applicant.present?
6
23
  %h2 Active Applications
7
24
 
8
- - in_progress.each do |applicant|
9
- = render 'effective/applicants/summary', applicant: applicant
25
+ = render 'effective/applicants/summary', applicant: applicant
26
+ = link_to("View application", effective_memberships.applicant_build_path(applicant, applicant.next_step), 'data-turbolinks' => false, class: 'btn btn-primary')
27
+
28
+ %hr
10
29
 
11
30
  %h2 Application History
12
31
 
@@ -15,5 +34,5 @@
15
34
  - else
16
35
  %p You have not yet created any applications. When you do, we'll show them here.
17
36
 
18
- - if authorized && in_progress.blank?
37
+ - if authorized && applicant.blank?
19
38
  %p= link_to 'Apply to join, reclassify, or provide a change of status notification', effective_memberships.new_applicant_path, class: 'btn btn-primary'
@@ -6,4 +6,4 @@
6
6
  .col-sm-auto.text-right
7
7
  = link_to('Edit', wizard_path(:demographics)) if edit_effective_wizard?
8
8
 
9
- = render 'effective/applicants/demographics_owner', applicant: applicant, owner: applicant.owner
9
+ = render 'users/demographics', parent: applicant, user: applicant.user
@@ -1,9 +1,11 @@
1
1
  %h3 Missing Information
2
- %p The following information is missing: #{resource.missing_info_reason}.
2
+ %p The following information is missing:
3
+ %ul
4
+ %li= resource.missing_info_reason
3
5
 
4
6
  %p
5
7
  Please revisit each wizard step and
6
- = link_to 'complete all missing information', wizard_path(:demographics)
8
+ = link_to 'Complete all missing information', wizard_path(:demographics), class: 'btn btn-primary'
7
9
  for this application.
8
10
 
9
11
  %p
@@ -12,7 +14,9 @@
12
14
  %p
13
15
  = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
14
16
  = f.hidden_field :id
15
- = f.save 'Submit Application', 'data-confirm': "Really submit application?"
17
+
18
+ - # If you change this label, update EffectiveMemberships ApplicantsController
19
+ = f.save 'Resubmit Application', 'data-confirm': "Really re-submit application?", class: 'btn-sm'
16
20
 
17
21
  %p
18
22
  %small * No additional payment required.
@@ -0,0 +1,9 @@
1
+ .card
2
+ .card-body
3
+ .row
4
+ .col-sm
5
+ %h5.card-title= applicant.wizard_step_title(:organization)
6
+ .col-sm-auto.text-right
7
+ = link_to('Edit', wizard_path(:organization)) if edit_effective_wizard?
8
+
9
+ = render 'organizations/demographics', parent: applicant, organization: applicant.organization