effective_memberships 0.1.7 → 0.1.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b47c4f81099d5e4078814e9f04765ae8b2790ac3fe19ff0a0f5442e9e5f6475
4
- data.tar.gz: 727b05c16923003822a9383d3cd3b8f582655cae1e769df98de0245bdd0dedd7
3
+ metadata.gz: 23096ca68807bea4bee0124d266ccb80d5e26e2bd2fd9cd9357a527a451212af
4
+ data.tar.gz: ed6e17ce553edf22b22fabeb6b6a85bf3260b1dc595ef57a1c1dfbfce21e9e4f
5
5
  SHA512:
6
- metadata.gz: fc8454e6c624109974f4f6bbcb65a92a892a9a19ed72565fdc53414017d03a30de766b1609fff6b4dca89a3f93c8800502ba4841032860bf3733fedc9b01da56
7
- data.tar.gz: 0db5f5f98ea6271c36fd09c2cd32a3f757ef55ca7cda4f2be130e12f0162aaa6474993062247ef02cdca3dfb1da4df1cc54dc5a3e32f91cf49c412a351de30db
6
+ metadata.gz: 498f8de4da09f11cd4933563db907a608d5b261a1e84425f5d7dc07ddefa04bf5feeb58a0b511810a758188fc8c5748e24e67eadb1f1a748e8fc55f8283bf352
7
+ data.tar.gz: 061176c89de004535b1c619ef7b67f4849a72539689f678724e6217691f75e1653ae895f78a5597b38ac6f63b9122348b3d22785bf467161159fdff8ae2c438b
@@ -0,0 +1,9 @@
1
+ module Admin
2
+ class MembershipsController < 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
+ end
9
+ end
@@ -14,6 +14,10 @@ module Admin
14
14
  success: -> { "#{resource.owner} has been reclassified to #{resource.owner.membership.category}" },
15
15
  redirect: -> { admin_owners_path(resource) }
16
16
 
17
+ submit :assign, 'Assign',
18
+ success: -> { "#{resource.owner} has been assigned to #{resource.owner.membership.categories.to_sentence}" },
19
+ redirect: -> { admin_owners_path(resource) }
20
+
17
21
  submit :remove, 'Remove',
18
22
  success: -> { "#{resource.owner} has been removed" },
19
23
  redirect: -> { admin_owners_path(resource) }
@@ -14,7 +14,15 @@ module Admin
14
14
 
15
15
  col :number
16
16
 
17
- col :categories, label: 'Category'
17
+ col :categories, label: 'Category' do |history|
18
+ history.categories.map.with_index do |category, index|
19
+ category_id = history.category_ids[index]
20
+ link = link_to(category, effective_memberships.edit_admin_category_path(category_id))
21
+
22
+ content_tag(:div, link, class: 'col-resource_item')
23
+ end.join.html_safe
24
+ end
25
+
18
26
  col :category_ids, visible: false
19
27
 
20
28
  col :bad_standing
@@ -0,0 +1,40 @@
1
+ module Admin
2
+ class EffectiveMembershipsDatatable < Effective::Datatable
3
+
4
+ datatable do
5
+ order :id
6
+ col :id, visible: false
7
+
8
+ col :owner
9
+ col :categories
10
+
11
+ col :number
12
+ col :number_as_integer, visible: false
13
+
14
+ col :joined_on
15
+ col :registration_on
16
+
17
+ col :fees_paid_period, visible: false, label: 'Fees Paid'
18
+ col :fees_paid_through_period, label: 'Fees Paid Through'
19
+
20
+ col :bad_standing
21
+ col :bad_standing_admin, visible: false
22
+ col :bad_standing_reason, visible: false
23
+
24
+ actions_col
25
+ end
26
+
27
+ collection do
28
+ memberships = Effective::Membership.deep.all
29
+
30
+ raise('expected an owner_id, not user_id') if attributes[:user_id].present?
31
+
32
+ if attributes[:owner_id].present?
33
+ memberships = memberships.where(owner_id: attributes[:owner_id])
34
+ end
35
+
36
+ memberships
37
+ end
38
+
39
+ end
40
+ end
@@ -247,6 +247,12 @@ module EffectiveMembershipsApplicant
247
247
  validates :declare_truth, acceptance: true
248
248
  end
249
249
 
250
+ # Billing Step
251
+ validate(if: -> { current_step == :billing && owner.present? }) do
252
+ self.errors.add(:base, "must have a billing address") unless owner.billing_address.present?
253
+ self.errors.add(:base, "must have an email") unless owner.email.present?
254
+ end
255
+
250
256
  # Admin Approve
251
257
  validate(if: -> { approved_membership_date.present? }) do
252
258
  if approved_membership_date.to_date > Time.zone.now.to_date
@@ -110,6 +110,12 @@ module EffectiveMembershipsFeePayment
110
110
  validates :declare_truth, acceptance: true
111
111
  end
112
112
 
113
+ # Billing Step
114
+ validate(if: -> { current_step == :billing && owner.present? }) do
115
+ self.errors.add(:base, "must have a billing address") unless owner.billing_address.present?
116
+ self.errors.add(:base, "must have an email") unless owner.email.present?
117
+ end
118
+
113
119
  # Clear required steps memoization
114
120
  after_save { @_required_steps = nil }
115
121
 
@@ -103,6 +103,10 @@ module EffectiveMembershipsOwner
103
103
  membership_histories.find { |history| history.removed? }.start_on
104
104
  end
105
105
 
106
+ def registrar_action_categories(action)
107
+ EffectiveMemberships.Category.sorted.all
108
+ end
109
+
106
110
  # Instance Methods
107
111
  def additional_fee_attributes(fee)
108
112
  raise('expected an Effective::Fee') unless fee.kind_of?(Effective::Fee)
@@ -26,7 +26,7 @@ module Effective
26
26
  timestamps
27
27
  end
28
28
 
29
- scope :deep, -> { includes(owner: [:fees, :membership]) }
29
+ scope :deep, -> { includes(:membership_categories) }
30
30
  scope :sorted, -> { order(:id) }
31
31
 
32
32
  scope :with_paid_fees_through, -> (period = nil) {
@@ -17,6 +17,9 @@ module Effective
17
17
  attr_accessor :membership_number
18
18
  attr_accessor :skip_fees
19
19
 
20
+ # Assign
21
+ attr_accessor :category_ids
22
+
20
23
  # All Action Validations
21
24
  validates :current_action, presence: true
22
25
  validates :current_user, presence: true
@@ -29,10 +32,27 @@ module Effective
29
32
  validates :category_id, presence: true,
30
33
  if: -> { current_action == :reclassify || current_action == :register }
31
34
 
35
+ validates :category_ids, presence: true, if: -> { current_action == :assign }
36
+
32
37
  def to_s
33
38
  'action'
34
39
  end
35
40
 
41
+ def register!
42
+ update!(current_action: :register)
43
+ EffectiveMemberships.Registrar.register!(owner, to: category, number: membership_number.presence, skip_fees: skip_fees?)
44
+ end
45
+
46
+ def reclassify!
47
+ update!(current_action: :reclassify)
48
+ EffectiveMemberships.Registrar.reclassify!(owner, to: category, skip_fees: skip_fees?)
49
+ end
50
+
51
+ def assign!
52
+ update!(current_action: :assign)
53
+ EffectiveMemberships.Registrar.assign!(owner, categories: categories, number: membership_number.presence)
54
+ end
55
+
36
56
  def good_standing!
37
57
  update!(current_action: :good_standing)
38
58
  EffectiveMemberships.Registrar.good_standing!(owner)
@@ -43,11 +63,6 @@ module Effective
43
63
  EffectiveMemberships.Registrar.bad_standing!(owner, reason: bad_standing_reason)
44
64
  end
45
65
 
46
- def reclassify!
47
- update!(current_action: :reclassify)
48
- EffectiveMemberships.Registrar.reclassify!(owner, to: category, skip_fees: skip_fees?)
49
- end
50
-
51
66
  def fees_paid!
52
67
  update!(current_action: :fees_paid)
53
68
  EffectiveMemberships.Registrar.fees_paid!(owner)
@@ -58,11 +73,6 @@ module Effective
58
73
  EffectiveMemberships.Registrar.remove!(owner)
59
74
  end
60
75
 
61
- def register!
62
- update!(current_action: :register)
63
- EffectiveMemberships.Registrar.register!(owner, to: category, number: membership_number.presence, skip_fees: skip_fees?)
64
- end
65
-
66
76
  def update!(atts)
67
77
  assign_attributes(atts); save!
68
78
  end
@@ -89,6 +99,10 @@ module Effective
89
99
  EffectiveMemberships.Category.find(@category_id) if @category_id
90
100
  end
91
101
 
102
+ def categories
103
+ EffectiveMemberships.Category.where(id: @category_ids) if @category_ids
104
+ end
105
+
92
106
  def skip_fees?
93
107
  EffectiveResources.truthy?(@skip_fees)
94
108
  end
@@ -7,7 +7,7 @@
7
7
  = f.show_if(:create_renewal_fees, true) do
8
8
  - date = EffectiveMemberships.Registrar.renewal_fee_date(date: Time.zone.now)
9
9
 
10
- %p Charged to members, every #{date.strftime('%B %d')}, to renew their dues.
10
+ %p Charged to members, every #{date.strftime('%B %e')}, to renew their dues.
11
11
  = f.price_field :renewal_fee
12
12
 
13
13
  %h3 Late Fees
@@ -17,7 +17,7 @@
17
17
  - period = EffectiveMemberships.Registrar.current_period
18
18
  - date = EffectiveMemberships.Registrar.late_fee_date(period: period)
19
19
 
20
- %p Charged to members, on #{date.strftime('%B %d')}, with outstanding renewal fees
20
+ %p Charged to members, on #{date.strftime('%B %e')}, with outstanding renewal fees
21
21
  = f.price_field :late_fee
22
22
 
23
23
  %h3 Bad Standing
@@ -27,6 +27,6 @@
27
27
  - period = EffectiveMemberships.Registrar.current_period
28
28
  - date = EffectiveMemberships.Registrar.bad_standing_date(period: period)
29
29
 
30
- %p Members with outstanding fees, on #{date.strftime('%B %d')}, will automatically be marked in bad standing.
30
+ %p Members with outstanding fees, on #{date.strftime('%B %e')}, will automatically be marked in bad standing.
31
31
 
32
32
  = effective_submit(f)
@@ -0,0 +1,34 @@
1
+ .card
2
+ .card-body
3
+ %h5.card-title Assign
4
+
5
+ = effective_form_with(model: [:admin, registrar_action], url: effective_memberships.admin_registrar_actions_path) do |f|
6
+ = f.hidden_field :owner_id
7
+ = f.hidden_field :owner_type
8
+
9
+ - membership = f.object.owner.membership
10
+
11
+ %p.text-muted
12
+ Assign to one or more categories.
13
+
14
+ = f.static_field :current_action, label: 'Current Categories' do
15
+ - Array(membership&.categories).each do |category|
16
+ %div= link_to(category, effective_memberships.edit_admin_category_path(category))
17
+
18
+ - if membership.blank?
19
+ None
20
+
21
+ = f.check_box :current_action, label: 'Yes, assign this member to categories'
22
+
23
+ = f.show_if :current_action, true do
24
+ - categories = f.object.owner.registrar_action_categories(:assign)
25
+ = f.select :category_ids, categories, label: 'Assign to', required: true, multiple: true
26
+
27
+ - if membership.present?
28
+ %p The member will keep their existing membership number: #{membership.number}.
29
+ - else
30
+ = f.text_field :membership_number, hint: "leave blank to assign the next number"
31
+
32
+ %p No fees will be created
33
+
34
+ = f.submit 'Assign', border: false, center: true, 'data-confirm': "Really assign #{f.object.owner}?"
@@ -9,13 +9,14 @@
9
9
  - membership = f.object.owner.membership
10
10
 
11
11
  - period = EffectiveMemberships.Registrar.current_period
12
- - date = EffectiveMemberships.Registrar.bad_standing_date(period: period)
12
+ - date = (EffectiveMemberships.Registrar.bad_standing_date(period: period) rescue false)
13
13
 
14
14
  %p.text-muted
15
- Members with outstanding renewal fees are automatically marked
16
- not in good standing on #{date.strftime('%B %d')}.
17
- The status is cleared when they pay their fees.
18
- You can also mark a member as always not in good standing.
15
+ - if date.present?
16
+ Members with outstanding renewal fees are automatically marked
17
+ not in good standing on #{date.strftime('%B %e')}.
18
+ The status is cleared when they pay their fees.
19
+ You can also mark a member as always in bad standing.
19
20
 
20
21
  = f.static_field :current_action, label: 'Current Status' do
21
22
 
@@ -7,9 +7,7 @@
7
7
  = f.hidden_field :owner_type
8
8
 
9
9
  - membership = f.object.owner.membership
10
-
11
10
  - period = EffectiveMemberships.Registrar.current_period
12
- - date = EffectiveMemberships.Registrar.bad_standing_date(period: period)
13
11
 
14
12
  %p.text-muted
15
13
  Change a member's existing category and optionally create fees.
@@ -22,7 +20,8 @@
22
20
  = f.show_if :current_action, true do
23
21
  %p The member will keep their existing membership number: #{membership.number}.
24
22
 
25
- - categories = EffectiveMemberships.Category.all.where.not(id: membership.category_id)
23
+ - categories = f.object.owner.registrar_action_categories(:reclassify) - membership.categories
24
+
26
25
  = f.select :category_id, categories, label: 'Reclassify to', required: true
27
26
 
28
27
  = f.check_box :skip_fees, label: 'Yes, skip creating fees and just set the category'
@@ -17,7 +17,7 @@
17
17
  = f.check_box :current_action, label: 'Yes, register to a membership'
18
18
 
19
19
  = f.show_if :current_action, true do
20
- - categories = EffectiveMemberships.Category.all
20
+ - categories = f.object.owner.registrar_action_categories(:register)
21
21
  = f.select :category_id, categories, label: 'Register to'
22
22
 
23
23
  = f.text_field :membership_number, hint: "leave blank to assign the next number"
@@ -1,3 +1,3 @@
1
1
  .row
2
- .col-lg-3= render_wizard_sidebar(resource)
2
+ .col-lg-3.mb-3= render_wizard_sidebar(resource)
3
3
  .col-lg-9= yield
@@ -1,3 +1,3 @@
1
1
  .row
2
- .col-lg-3= render_wizard_sidebar(resource)
2
+ .col-lg-3.mb-3= render_wizard_sidebar(resource)
3
3
  .col-lg-9= yield
@@ -4,11 +4,12 @@
4
4
  - raise('expected a submitted fee_payment') unless resource.was_submitted?
5
5
  - raise('expected a purchased fee_payment submit_order') unless resource.submit_order&.purchased?
6
6
 
7
- .alert.alert-success.mb-4
8
- Fee successfully paid on
9
- = resource.submit_order.purchased_at.strftime('%F')
7
+ .alert.alert-warning.mb-4
8
+ Successfully paid on #{resource.submit_order.purchased_at.strftime('%F')}.
9
+
10
+ = link_to "Return to Dashboard", root_path, class: 'btn btn-lg btn-primary mb-4'
10
11
 
11
12
  = render 'effective/fee_payments/fee_payment', fee_payment: resource
12
13
  = render 'effective/fee_payments/orders', fee_payment: resource
13
14
 
14
- = link_to "Return to Dashboard", root_path, class: 'btn btn-lg btn-primary btn-block'
15
+ = link_to "Return to Dashboard", root_path, class: 'btn btn-lg btn-primary'
@@ -7,11 +7,11 @@
7
7
  - if membership.present?
8
8
  - if membership.category.create_renewal_fees?
9
9
  - date = EffectiveMemberships.Registrar.renewal_fee_date(date: Time.zone.now)
10
- %p Annual fees become available for purchase on #{date.strftime('%B %d')} of each year.
10
+ %p Annual fees become available for purchase on #{date.strftime('%B %e')} of each year.
11
11
 
12
12
  - if membership.category.create_late_fees?
13
13
  - date = EffectiveMemberships.Registrar.late_fee_date(date: Time.zone.now)
14
- %p Late fees will be applied on #{date.strftime('%B %d')}.
14
+ %p Late fees will be applied on #{date.strftime('%B %e')}.
15
15
 
16
16
  - if fees.present?
17
17
  .alert.alert-warning.mb-3 You have #{pluralize(fees.length , 'outstanding fee')}.
data/config/routes.rb CHANGED
@@ -27,6 +27,7 @@ EffectiveMemberships::Engine.routes.draw do
27
27
  resources :applicant_course_names, except: [:show]
28
28
 
29
29
  resources :fee_payments, only: [:index, :show]
30
+ resources :memberships, only: [:index]
30
31
  resources :registrar_actions, only: [:create]
31
32
  end
32
33
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.11'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_memberships
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-22 00:00:00.000000000 Z
11
+ date: 2021-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -216,6 +216,7 @@ files:
216
216
  - app/controllers/admin/categories_controller.rb
217
217
  - app/controllers/admin/fee_payments_controller.rb
218
218
  - app/controllers/admin/fees_controller.rb
219
+ - app/controllers/admin/memberships_controller.rb
219
220
  - app/controllers/admin/registrar_actions_controller.rb
220
221
  - app/controllers/effective/applicant_references_controller.rb
221
222
  - app/controllers/effective/applicants_controller.rb
@@ -227,6 +228,7 @@ files:
227
228
  - app/datatables/admin/effective_fee_payments_datatable.rb
228
229
  - app/datatables/admin/effective_fees_datatable.rb
229
230
  - app/datatables/admin/effective_membership_histories_datatable.rb
231
+ - app/datatables/admin/effective_memberships_datatable.rb
230
232
  - app/datatables/effective_applicant_courses_datatable.rb
231
233
  - app/datatables/effective_applicant_educations_datatable.rb
232
234
  - app/datatables/effective_applicant_experiences_datatable.rb
@@ -282,6 +284,7 @@ files:
282
284
  - app/views/admin/fees/_form.html.haml
283
285
  - app/views/admin/memberships/_status.html.haml
284
286
  - app/views/admin/registrar_actions/_form.html.haml
287
+ - app/views/admin/registrar_actions/_form_assign.html.haml
285
288
  - app/views/admin/registrar_actions/_form_bad_standing.html.haml
286
289
  - app/views/admin/registrar_actions/_form_fees_paid.html.haml
287
290
  - app/views/admin/registrar_actions/_form_reclassify.html.haml