effective_memberships 0.6.6 → 0.6.7

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: d5a9ac211f2370d13d88ee7b8ce0345c4c8363c530dd60dccbe4bc2da046bf98
4
- data.tar.gz: 69f0f40f0116c65bea68c949424921b2a87b821e50e664fc73b1312f90c79a79
3
+ metadata.gz: 994cc88bc7e75f8660b8af1a9930175493759241323675edc72da9ab53640ab5
4
+ data.tar.gz: e29658115f728da1b3b33f5776fc24e461f6abe5ac9cb8d1362834153598a96e
5
5
  SHA512:
6
- metadata.gz: 7edb8681ca649e8aa121cf38add83c1e21277a968682e8b183f5f3197a84dd061f5ebac01c0da824c64f59c93f47e17d46ea43d81ee4b31a1cb485235b24f7e7
7
- data.tar.gz: 4fe46479e76c85a356861d4b42f2e1b59675c3726e61c9791044b85133679e87f5d2b66e7a719311fe6c15a6d25a89db04f2b4f20232c462c5a028cf2c013f85
6
+ metadata.gz: 9b2a8938998de7838aef913e2e4f2262a0cde28fc04de5fb0d74816a1ff9ddc23db3000985aceca51b4578339553c9be2c39b0ca0df11c6bbecd7a620101e17f
7
+ data.tar.gz: 95f6268d44cc10e4dabe9c4208f5d42ae669533f31876643aa2b31749414dc5cbf68e8368c062c5997cc61261579e6bec5decfb446020c5497fe74cc02a29640
@@ -14,16 +14,16 @@ 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 :status_change, 'Change Status',
18
- success: -> { "#{resource.owner} has been status changed to #{resource.owner.membership.status || 'None'}" },
17
+ submit :status_assign, 'Assign Status',
18
+ success: -> { "#{resource.owner} has been assigned #{resource.owner.membership.statuses_sentence}" },
19
19
  redirect: -> { admin_owners_path(resource) }
20
20
 
21
21
  submit :status_remove, 'Remove Status',
22
- success: -> { "#{resource.owner} has had their status removed" },
22
+ success: -> { "#{resource.owner} has been removed from #{resource.status}" },
23
23
  redirect: -> { admin_owners_path(resource) }
24
24
 
25
25
  submit :assign, 'Assign',
26
- success: -> { "#{resource.owner} has been assigned to #{resource.owner.membership.categories.to_sentence}" },
26
+ success: -> { "#{resource.owner} has been assigned to #{resource.owner.membership.categories_sentence}" },
27
27
  redirect: -> { admin_owners_path(resource) }
28
28
 
29
29
  submit :remove, 'Remove',
@@ -262,7 +262,7 @@ module EffectiveMembershipsRegistrar
262
262
 
263
263
  def remove!(owner, date: nil)
264
264
  raise('expecting a memberships owner') unless owner.class.respond_to?(:effective_memberships_owner?)
265
- raise('expected a member') unless owner.membership.present?
265
+ raise('expected a member with a membership') unless owner.membership.present?
266
266
 
267
267
  # Date
268
268
  date ||= Time.zone.now
@@ -113,6 +113,10 @@ module Effective
113
113
  categories.first.id
114
114
  end
115
115
 
116
+ def categories_sentence
117
+ categories.map(&:to_s).to_sentence.presence || 'None'
118
+ end
119
+
116
120
  def membership_category(category:)
117
121
  raise('expected a category') unless category.class.respond_to?(:effective_memberships_category?)
118
122
  membership_categories.find { |mc| mc.category_id == category.id && mc.category_type == category.class.name }
@@ -134,6 +138,10 @@ module Effective
134
138
  membership_statuses.reject(&:marked_for_destruction?).map(&:status_id)
135
139
  end
136
140
 
141
+ def statuses_sentence
142
+ statuses.map(&:to_s).to_sentence.presence || 'None'
143
+ end
144
+
137
145
  # We might want to use singular memberships.
138
146
  def status
139
147
  raise('expected singular usage but there are more than one membership status') if statuses.length > 1
@@ -21,8 +21,8 @@ module Effective
21
21
  attr_accessor :skip_fees
22
22
 
23
23
  # Status Change
24
+ attr_accessor :status_ids
24
25
  attr_accessor :status_id
25
- attr_accessor :status_remove_action
26
26
 
27
27
  # Assign
28
28
  attr_accessor :category_ids
@@ -46,8 +46,11 @@ module Effective
46
46
  validates :category_id, presence: true,
47
47
  if: -> { current_action == :reclassify || current_action == :register }
48
48
 
49
- # Status Change
50
- validates :status_id, presence: true, if: -> { current_action == :status_change }
49
+ # Status Assign
50
+ validates :status_ids, presence: true, if: -> { current_action == :status_assign }
51
+
52
+ # Status Remove
53
+ validates :status_id, presence: true, if: -> { current_action == :status_remove }
51
54
 
52
55
  # Assign
53
56
  validates :category_ids, presence: true, if: -> { current_action == :assign }
@@ -66,14 +69,14 @@ module Effective
66
69
  EffectiveMemberships.Registrar.reclassify!(owner, to: category, skip_fees: skip_fees?)
67
70
  end
68
71
 
69
- def status_change!
70
- update!(current_action: :status_change)
71
- EffectiveMemberships.Registrar.status_change!(owner, to: status)
72
+ def status_assign!
73
+ update!(current_action: :status_assign)
74
+ EffectiveMemberships.Registrar.status_assign!(owner, status: statuses)
72
75
  end
73
76
 
74
77
  def status_remove!
75
78
  update!(current_action: :status_remove)
76
- EffectiveMemberships.Registrar.status_remove!(owner)
79
+ EffectiveMemberships.Registrar.status_remove!(owner, status: status)
77
80
  end
78
81
 
79
82
  def assign!
@@ -101,6 +104,10 @@ module Effective
101
104
  EffectiveMemberships.Registrar.remove!(owner)
102
105
  end
103
106
 
107
+ def assign_attributes(atts)
108
+ super(atts.reject { |k, _| k.to_s.start_with?('status_remove_action_') })
109
+ end
110
+
104
111
  def update!(atts)
105
112
  assign_attributes(atts); save!
106
113
  end
@@ -121,8 +128,6 @@ module Effective
121
128
  @owner_id || (@owner.id if @owner)
122
129
  end
123
130
 
124
- private
125
-
126
131
  def category
127
132
  EffectiveMemberships.Category.find(@category_id) if @category_id.present?
128
133
  end
@@ -3,6 +3,7 @@
3
3
  %h5.card-title Status Change
4
4
 
5
5
  = effective_form_with(model: [:admin, registrar_action], url: effective_memberships.admin_registrar_actions_path) do |f|
6
+
6
7
  = f.hidden_field :owner_id
7
8
  = f.hidden_field :owner_type
8
9
 
@@ -13,29 +14,33 @@
13
14
  Change or remove a member's existing status.
14
15
 
15
16
  = f.static_field :current_action, label: 'Current Status' do
16
- = (membership.status || 'None').to_s
17
+ = badges(membership.statuses) || 'None'
17
18
 
18
19
  = f.check_box :current_action, label: 'Yes, change member status'
19
20
 
20
21
  = f.show_if :current_action, true do
21
22
  %p The member will keep their existing membership number: #{membership.number}.
22
23
 
23
- - statuses = f.object.owner.registrar_action_statuses(:status_change) - membership.statuses
24
- = f.select :status_id, statuses, label: 'Change status to', required: true
24
+ - statuses = f.object.owner.registrar_action_statuses(:status_change)
25
+ - f.object.status_ids = membership.status_ids
26
+
27
+ = f.select :status_ids, statuses, label: 'Change status to', required: true, multiple: true
25
28
 
26
29
  %p No fees will be created
27
30
 
28
- = f.submit 'Change Status', border: false, center: true, 'data-confirm': "Really change #{f.object.owner}?"
31
+ = f.submit 'Assign Status', border: false, center: true, 'data-confirm': "Really assign #{f.object.owner} status?"
32
+
33
+ - # Remove Actions
34
+ - membership.statuses.each do |status|
35
+ = f.check_box "status_remove_action_#{status.id}", label: "Yes, remove #{status} status"
29
36
 
30
- - # Remove Action
31
- - if membership.status.present?
32
- = f.check_box :status_remove_action, label: "Yes, remove #{membership.status} status"
37
+ = f.show_if("status_remove_action_#{status.id}", true, validate: false) do
38
+ = f.hidden_field :status_id, value: status.id
33
39
 
34
- = f.show_if :status_remove_action, true do
35
40
  %p The member will keep their existing membership number: #{membership.number}
36
41
 
37
- %p This action will remove the #{membership.status} status
42
+ %p This action will remove the #{badge(status)} status
38
43
 
39
44
  %p No fees will be created
40
45
 
41
- = f.submit 'Remove Status', border: false, center: true, 'data-confirm': "Really remove status #{f.object.owner}?"
46
+ = f.submit "Remove Status", border: false, center: true, 'data-confirm': "Remove #{status} from #{f.object.owner}?"
data/db/seeds.rb CHANGED
@@ -10,6 +10,8 @@ if Rails.env.test?
10
10
  end
11
11
 
12
12
  Effective::Status.where(title: 'Resigned').first_or_create!
13
+ Effective::Status.where(title: 'Deceased').first_or_create!
14
+ Effective::Status.where(title: 'On Leave').first_or_create!
13
15
 
14
16
  member = Effective::Category.create!(
15
17
  title: "Full Member",
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.6.6'
2
+ VERSION = '0.6.7'
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.6.6
4
+ version: 0.6.7
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: 2022-09-02 00:00:00.000000000 Z
11
+ date: 2022-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails