effective_memberships 0.6.9 → 0.6.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 070c1ddf76bc05b1659fe52e3dba9e940d2d1f22e61a106453e7f0ee319e58e1
4
- data.tar.gz: 57e590916bacc7c0fc34482c7850ac2b2b9c30b8b9181ad65d553ff530bb78eb
3
+ metadata.gz: 7ba47cb79fdfe1d53bfa440e0c6ecd4b454f7da034a9035d25e0306e0b57a1d9
4
+ data.tar.gz: 7b342075e2d9aa6e51d7cecd34011e491f1c95ae7123606d26a23b128915e34d
5
5
  SHA512:
6
- metadata.gz: 9c11227b561d087bf85a849200f930d3fa5cac68c8aa8f20aad25a84365548769e23ceec50c3a0cf583d8cf1b9542ce9cfa5fbc1cdc00726e0f941030f8d35a7
7
- data.tar.gz: 794d3a8e16605ed198cf501f9810107c6ddb20efee9ef94996a9978312e2af5cc371699f18f13e3be32a114b78b926c8e7519e8cd315c85bdf784350e3e98576
6
+ metadata.gz: 4033eb84334a81fe60aa6b67248f34feec629ca3a83bb6f0725ef2bb013dce6344b629eefd9f940f8a6f2b3a7dbdf35360b4027b925c5785d7e1ab7d359b0dcd
7
+ data.tar.gz: 59978379131bfb1a4e9988fdeda03e8e792ec37011c1c2a7338072c73c743dd1cd33999be0d1cbb41142e60ca43e1c15e8fe053b56a7ac9ffcc96e9e6ed6aa6d
@@ -68,7 +68,7 @@ module Effective
68
68
 
69
69
  def assigns_for(resource)
70
70
  if resource.class.respond_to?(:effective_memberships_applicant?)
71
- return applicant_assigns(resource).merge(owner_assigns(resource.owner))
71
+ return applicant_assigns(resource).merge(owner_assigns(resource.owner)).merge(membership_assigns(resource.owner.membership))
72
72
  end
73
73
 
74
74
  if resource.kind_of?(Effective::ApplicantEndorsement)
@@ -87,6 +87,7 @@ module Effective
87
87
 
88
88
  values = {
89
89
  date: (applicant.submitted_at || Time.zone.now).strftime('%F'),
90
+ approved_at: (applicant.approved_at&.strftime('%F') || 'not approved'),
90
91
 
91
92
  to_category: applicant.category.to_s,
92
93
  from_category: applicant.from_category.to_s,
@@ -102,6 +103,19 @@ module Effective
102
103
  { applicant: values }
103
104
  end
104
105
 
106
+ def membership_assigns(membership)
107
+ return {} if membership.blank?
108
+ raise('expected a membership') unless membership.kind_of?(Effective::Membership)
109
+
110
+ values = {
111
+ number: (membership.number || 'no membership number'),
112
+ joined_on: (membership.joined_on&.strftime('%F') || 'unknown'),
113
+ registration_on: (membership.registration_on.strftime('%F') || 'unknown')
114
+ }
115
+
116
+ { membership: values }
117
+ end
118
+
105
119
  def endorsement_assigns(applicant_endorsement)
106
120
  raise('expected a endorsement') unless applicant_endorsement.kind_of?(Effective::ApplicantEndorsement)
107
121
 
@@ -87,6 +87,7 @@ module EffectiveMembershipsApplicant
87
87
  # Admin Approve Step
88
88
  attr_accessor :approved_membership_number
89
89
  attr_accessor :approved_membership_date
90
+ attr_accessor :approved_email_action
90
91
 
91
92
  # Application Namespace
92
93
  belongs_to :user, polymorphic: true
@@ -763,6 +764,19 @@ module EffectiveMembershipsApplicant
763
764
  reviewed!
764
765
  end
765
766
 
767
+ def approve_email_templates
768
+ raise('expected EffectiveEmailTemplates') unless defined?(EffectiveEmailTemplates)
769
+ Effective::EmailTemplate.where('template_name ILIKE ?', 'applicant_approve%').order(:template_name)
770
+ end
771
+
772
+ def to_category
773
+ category
774
+ end
775
+
776
+ def to_status
777
+ nil
778
+ end
779
+
766
780
  # Admin approves an applicant. Registers the owner. Sends an email.
767
781
  def approve!
768
782
  raise('already approved') if was_approved?
@@ -778,12 +792,13 @@ module EffectiveMembershipsApplicant
778
792
  if apply_to_join?
779
793
  EffectiveMemberships.Registrar.register!(
780
794
  owner,
781
- to: category,
795
+ to: to_category,
796
+ status: to_status,
782
797
  date: approved_membership_date.presence, # Set by the Admin Process form, or nil
783
798
  number: approved_membership_number.presence # Set by the Admin Process form, or nil
784
799
  )
785
800
  elsif reclassification?
786
- EffectiveMemberships.Registrar.reclassify!(owner, to: category)
801
+ EffectiveMemberships.Registrar.reclassify!(owner, to: to_category, status: to_status)
787
802
  elsif reinstatement?
788
803
  EffectiveMemberships.Registrar.reinstate!(owner, from: from_status)
789
804
  else
@@ -9,7 +9,11 @@
9
9
  The member will keep their existing membership number: #{applicant.owner.membership.number}.
10
10
  - else
11
11
  - number = EffectiveMemberships.Registrar.next_membership_number(applicant.owner, to: applicant.category)
12
- = f.text_field :approved_membership_number, hint: "leave blank to assign the next number: #{number}."
12
+
13
+ - if number.present?
14
+ = f.text_field :approved_membership_number, hint: "leave blank to assign the next number: #{number || 'none'}."
15
+ - else
16
+ No membership number will be assigned.
13
17
 
14
18
  %h3 Fees
15
19
  %p The following fee(s) will be created:
@@ -24,7 +28,27 @@
24
28
  %li A #{month} discount fee from their old category
25
29
 
26
30
  %h3 Email to send
27
- %p The following email will be sent:
28
- = email_form_fields(f, :applicant_approved)
31
+ - email_templates = applicant.approve_email_templates
32
+
33
+ - f.object.approved_email_action ||= email_templates.first&.id
34
+ = f.hidden_field :approved_email_action
35
+
36
+ - if email_templates.length == 0
37
+ %p The following email will be sent:
38
+ = email_form_fields(f, :applicant_approve)
39
+
40
+ - if email_templates.length == 1
41
+ - template = email_templates.first
42
+ %p The following #{link_to(template, effective_email_templates.edit_admin_email_template_path(template), target: '_blank')} email will be sent:
43
+ = email_form_fields(f, template)
44
+
45
+ - if email_templates.length > 1
46
+ - collection = email_templates.map { |et| [et.to_s.titleize.sub('Applicant ', '') + " (#{et})", et.id] }
47
+ = f.select :approved_email_action, collection
48
+
49
+ - email_templates.each do |template|
50
+ = f.show_if(:approved_email_action, template.id) do
51
+ %p The following #{link_to(template, effective_email_templates.edit_admin_email_template_path(template), target: '_blank')} email will be sent:
52
+ = email_form_fields(f, template)
29
53
 
30
54
  = f.submit 'Approve Applicant', border: false, center: true, 'data-confirm': "Approve #{f.object.owner}?"
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.6.9'
2
+ VERSION = '0.6.10'
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.9
4
+ version: 0.6.10
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-06 00:00:00.000000000 Z
11
+ date: 2022-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails