effective_memberships 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/admin/registrar_actions_controller.rb +4 -4
- data/app/models/concerns/effective_memberships_registrar.rb +1 -1
- data/app/models/effective/membership.rb +8 -0
- data/app/models/effective/registrar_action.rb +14 -9
- data/app/views/admin/registrar_actions/_form_status_change.html.haml +15 -10
- data/db/seeds.rb +2 -0
- data/lib/effective_memberships/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 994cc88bc7e75f8660b8af1a9930175493759241323675edc72da9ab53640ab5
|
4
|
+
data.tar.gz: e29658115f728da1b3b33f5776fc24e461f6abe5ac9cb8d1362834153598a96e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 :
|
18
|
-
success: -> { "#{resource.owner} has been
|
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
|
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.
|
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
|
50
|
-
validates :
|
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
|
70
|
-
update!(current_action: :
|
71
|
-
EffectiveMemberships.Registrar.
|
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.
|
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)
|
24
|
-
|
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 '
|
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
|
-
|
31
|
-
|
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 #{
|
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
|
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",
|
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.
|
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-
|
11
|
+
date: 2022-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|