effective_memberships 0.10.0 → 0.11.0

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: 978c99bc1bc8f0106fac7867dc8a07acea70bd94456d248e20cbb2e57c633b76
4
- data.tar.gz: af1183a241f5b564c7b3ca4aa1ded0768dfde262d3b75da1933ddd177e430ede
3
+ metadata.gz: ab9a748ab11ca8d852d0b69ed6f5d05e40e0e67b966e1c85f6cf98592db2dc32
4
+ data.tar.gz: b048158b7cea70c82fa04ab13cc91a37fcc20edcd5b6356b0ff6d9efbb967314
5
5
  SHA512:
6
- metadata.gz: caa13055dda3360d3d1426710a39923cc79fcf99cf0af710acead650e3f56089d068e4d30fde0072ba2708cc144515a948a4a265624f0726e6afee4e1457861d
7
- data.tar.gz: 5f8241aba4c6d6ca7757346ae74520993d48d4d04af8c5bdf486337ec2e939da8f2d7641fe746319d8c284190c07594b0be1b675240e996beee98815bb124c74
6
+ metadata.gz: 0603ffd2a17a89df9de2e7325f0d2c4a0d03583da2d3f431425f2e69edbadb201878582a60086ff48c9313dfd218c6d7b173a876a17e35737ebb98e3ebecd7ef
7
+ data.tar.gz: dbe77a3674d19fa2fed6be7bc23a09f1a66b7b7c2dfe7908516193c99f378b81e3a522d2a7ceaf2e105fd59d2247a2c1f87097451deadf9d29e0d22b92d6ff98
@@ -0,0 +1,15 @@
1
+ module Admin
2
+ class DocumentsController < 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
+ private
9
+
10
+ def permitted_params
11
+ params.require(:effective_document).permit!
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,28 @@
1
+ module Admin
2
+ class EffectiveDocumentsDatatable < Effective::Datatable
3
+ datatable do
4
+ order :updated_at
5
+
6
+ col :updated_at, visible: false
7
+ col :created_at, visible: false
8
+ col :id, visible: false
9
+
10
+ col :file
11
+ col :owner, label: 'User'
12
+ col :display_to_owner, label: 'Display to user'
13
+
14
+ if (categories = Array(EffectiveMemberships.document_categories)).present?
15
+ col :category, search: categories
16
+ end
17
+
18
+ col :title, visible: false
19
+ col :notes
20
+
21
+ actions_col
22
+ end
23
+
24
+ collection do
25
+ Effective::Document.deep.all
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,31 @@
1
+ # Dashboard Documents
2
+ class EffectiveDocumentsDatatable < Effective::Datatable
3
+ datatable do
4
+ order :updated_at
5
+
6
+ col :updated_at, visible: false
7
+ col :created_at, visible: false
8
+ col :id, visible: false
9
+
10
+ col :owner, label: 'User or Organization'
11
+
12
+ if (categories = Array(EffectiveMemberships.document_categories)).present?
13
+ col :category, search: categories
14
+ end
15
+
16
+ col :file
17
+
18
+ col :title, visible: false
19
+ col :notes
20
+
21
+ actions_col do |document|
22
+ dropdown_link_to('Download', url_for(document.file)) if document.file.attached?
23
+ end
24
+
25
+ end
26
+
27
+ collection(apply_belongs_to: false) do
28
+ Effective::Document.deep.for(current_user).display_to_owner
29
+ end
30
+
31
+ end
@@ -267,8 +267,25 @@ module EffectiveMembershipsOwner
267
267
  # Build the renewal fee
268
268
  fee ||= fees.build()
269
269
 
270
- late_on ||= EffectiveMemberships.Registrar.late_fee_date(period: period) if category.create_late_fees?
271
- not_in_good_standing_on ||= EffectiveMemberships.Registrar.not_in_good_standing_date(period: period) if category.create_not_in_good_standing?
270
+ # Late on this period's late date, or 60 days, whichever is later
271
+ late_on ||= if category.create_late_fees?
272
+ late_date = EffectiveMemberships.Registrar.late_fee_date(period: period)
273
+
274
+ duration = EffectiveMemberships.Registrar.min_late_duration
275
+ min_date = ((fee.created_at || Time.zone.now) + duration) if duration.present?
276
+
277
+ [late_date, min_date].compact.max
278
+ end
279
+
280
+ # NIGS on this period's late date, or 60 days, whichever is later
281
+ not_in_good_standing_on ||= if category.create_not_in_good_standing?
282
+ nigs_date = EffectiveMemberships.Registrar.not_in_good_standing_date(period: period)
283
+
284
+ duration = EffectiveMemberships.Registrar.min_not_in_good_standing_duration
285
+ min_date = ((fee.created_at || Time.zone.now) + duration) if duration.present?
286
+
287
+ [nigs_date, min_date].compact.max
288
+ end
272
289
 
273
290
  fee.assign_attributes(
274
291
  fee_type: 'Renewal',
@@ -33,6 +33,18 @@ module EffectiveMembershipsRegistrar
33
33
  raise('to be implemented by app registrar')
34
34
  end
35
35
 
36
+ # A renewal fee must be at least this old to be considered late?
37
+ # Must be less than (late_fee_date - renewal_fee_date) but this is not enforced
38
+ def min_late_duration
39
+ 60.days
40
+ end
41
+
42
+ # A renewal fee must be at least this old to be considered nigs?
43
+ # Must be less than (nigs_date - renewal_fee_date) but this is not enforced
44
+ def min_not_in_good_standing_duration
45
+ 60.days
46
+ end
47
+
36
48
  # scope
37
49
  def not_in_good_standing_status
38
50
  EffectiveMemberships.Status.where(title: 'Not In Good Standing')
@@ -0,0 +1,50 @@
1
+ module Effective
2
+ class Document < ActiveRecord::Base
3
+ self.table_name = EffectiveMemberships.documents_table_name.to_s
4
+
5
+ log_changes(to: :owner) if respond_to?(:log_changes)
6
+
7
+ # This fee may belong to an user, organization or other parent model
8
+ belongs_to :owner, polymorphic: true, optional: true
9
+
10
+ has_one_attached :file
11
+
12
+ effective_resource do
13
+ title :string
14
+ category :string
15
+ display_to_owner :boolean # Display on dashbaord
16
+
17
+ notes :text
18
+
19
+ timestamps
20
+ end
21
+
22
+ scope :sorted, -> { order(:id) }
23
+ scope :deep, -> { with_attached_file }
24
+ scope :display_to_owner, -> { where(display_to_owner: true) }
25
+
26
+ scope :for, -> (user) {
27
+ raise('expected a effective memberships user') unless user.class.try(:effective_memberships_user?)
28
+ where(owner: user).or(where(owner: user.organizations))
29
+ }
30
+
31
+ before_validation(if: -> { file.attached? && title.blank? }) do
32
+ assign_attributes(title: file.filename.to_s)
33
+ end
34
+
35
+ validates :title, presence: true
36
+ validates :file, presence: true
37
+
38
+ validate do
39
+ if (categories = Array(EffectiveMemberships.document_categories)).present?
40
+ self.errors.add(:category, "can't be blank") if category.blank?
41
+ self.errors.add(:category, "is invalid") unless categories.include?(category)
42
+ end
43
+ end
44
+
45
+ def to_s
46
+ title.presence || model_name.human
47
+ end
48
+
49
+ end
50
+ end
@@ -87,14 +87,26 @@ module Effective
87
87
  return false if late_on.blank?
88
88
  return false if purchased?
89
89
 
90
- late_on <= Time.zone.now.to_date
90
+ now = Time.zone.now
91
+
92
+ if(duration = EffectiveMemberships.Registrar.min_late_duration).present?
93
+ return false if ((created_at || now) + duration > now)
94
+ end
95
+
96
+ late_on <= now.to_date
91
97
  end
92
98
 
93
99
  def not_in_good_standing?
94
100
  return false if not_in_good_standing_on.blank?
95
101
  return false if purchased?
96
102
 
97
- not_in_good_standing_on <= Time.zone.now.to_date
103
+ now = Time.zone.now
104
+
105
+ if(duration = EffectiveMemberships.Registrar.min_not_in_good_standing_duration).present?
106
+ return false if ((created_at || now) + duration > now)
107
+ end
108
+
109
+ not_in_good_standing_on <= now.to_date
98
110
  end
99
111
 
100
112
  # Used by applicant.applicant_submit_fees
@@ -0,0 +1,19 @@
1
+ = effective_form_with(model: [:admin, document], engine: true) do |f|
2
+ - if inline_datatable?
3
+ = f.hidden_field :owner_id
4
+ = f.hidden_field :owner_type
5
+ - else
6
+ = f.hidden_field :owner_type, value: current_user.class.name
7
+
8
+ - ajax_url = (@select2_ajax_path || effective_resources.users_admin_select2_ajax_index_path) unless Rails.env.test?
9
+ = f.select :owner_id, current_user.class.all, label: 'User', ajax_url: ajax_url
10
+
11
+ - if (categories = Array(EffectiveMemberships.document_categories)).present?
12
+ - f.object.category ||= categories.first
13
+ = f.select :category, categories, required: true
14
+
15
+ = f.file_field :file
16
+ = f.text_area :notes
17
+ = f.check_box :display_to_owner, label: "Yes, display this document on the user dashboard"
18
+
19
+ = effective_submit(f)
@@ -0,0 +1,8 @@
1
+ - datatable = EffectiveResources.best('EffectiveDocumentsDatatable').new(self, namespace: :effective)
2
+
3
+ %h2 Documents
4
+
5
+ - if datatable.present?
6
+ = render_simple_datatable(datatable)
7
+ - else
8
+ %p You have not been shared any documents. When you do, we'll show them here.
@@ -2,6 +2,7 @@ EffectiveMemberships.setup do |config|
2
2
  config.categories_table_name = :categories
3
3
  config.applicants_table_name = :applicants
4
4
  config.applicant_reviews_table_name = :applicant_reviews
5
+ config.documents_table_name = :documents
5
6
  config.fee_payments_table_name = :fee_payments
6
7
  config.organizations_table_name = :organizations
7
8
  config.representatives_table_name = :representatives
@@ -37,6 +38,10 @@ EffectiveMemberships.setup do |config|
37
38
  # When false, hide the reviewed state entirely
38
39
  # config.applicant_reviews = false
39
40
 
41
+ # Documents
42
+ # Documents will require a category when present
43
+ # config.document_categories = ['Documents']
44
+
40
45
  # Mailer Settings
41
46
  # Please see config/initializers/effective_resources.rb for default effective_* gem mailer settings
42
47
  #
data/config/routes.rb CHANGED
@@ -52,6 +52,7 @@ EffectiveMemberships::Engine.routes.draw do
52
52
 
53
53
  resources :applicant_reviews, only: [:index, :show]
54
54
 
55
+ resources :documents, except: [:show]
55
56
  resources :fees, except: [:show]
56
57
  resources :categories, only: [:index, :edit, :update]
57
58
 
@@ -529,5 +529,19 @@ class CreateEffectiveMemberships < ActiveRecord::Migration[6.0]
529
529
  add_index :fee_payments, :status
530
530
  add_index :fee_payments, :token
531
531
 
532
+ # Documents
533
+ create_table :documents do |t|
534
+ t.integer :owner_id
535
+ t.string :owner_type
536
+
537
+ t.string :title
538
+ t.string :category
539
+ t.boolean :display_to_owner
540
+
541
+ t.text :notes
542
+
543
+ t.timestamps
544
+ end
545
+
532
546
  end
533
547
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.10.0'
2
+ VERSION = '0.11.0'
3
3
  end
@@ -6,9 +6,9 @@ module EffectiveMemberships
6
6
 
7
7
  def self.config_keys
8
8
  [
9
- :categories_table_name, :applicants_table_name, :applicant_reviews_table_name, :fee_payments_table_name, :organizations_table_name, :representatives_table_name, :statuses_table_name,
9
+ :documents_table_name, :categories_table_name, :applicants_table_name, :applicant_reviews_table_name, :fee_payments_table_name, :organizations_table_name, :representatives_table_name, :statuses_table_name,
10
10
  :category_class_name, :organization_class_name, :applicant_class_name, :applicant_review_class_name, :fee_payment_class_name, :registrar_class_name, :membership_card_class_name, :membership_directory_class_name, :status_class_name,
11
- :additional_fee_types, :applicant_reviews, :applicant_endorsements_endorser_collection,
11
+ :additional_fee_types, :applicant_reviews, :applicant_endorsements_endorser_collection, :document_categories,
12
12
  :layout,
13
13
  :mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject, :use_effective_email_templates
14
14
  ]
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.10.0
4
+ version: 0.11.0
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: 2023-01-31 00:00:00.000000000 Z
11
+ date: 2023-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -261,6 +261,7 @@ files:
261
261
  - app/controllers/admin/applicant_reviews_controller.rb
262
262
  - app/controllers/admin/applicants_controller.rb
263
263
  - app/controllers/admin/categories_controller.rb
264
+ - app/controllers/admin/documents_controller.rb
264
265
  - app/controllers/admin/fee_payments_controller.rb
265
266
  - app/controllers/admin/fees_controller.rb
266
267
  - app/controllers/admin/membership_histories_controller.rb
@@ -285,6 +286,7 @@ files:
285
286
  - app/datatables/admin/effective_applicant_reviews_datatable.rb
286
287
  - app/datatables/admin/effective_applicants_datatable.rb
287
288
  - app/datatables/admin/effective_categories_datatable.rb
289
+ - app/datatables/admin/effective_documents_datatable.rb
288
290
  - app/datatables/admin/effective_fee_payments_datatable.rb
289
291
  - app/datatables/admin/effective_fees_datatable.rb
290
292
  - app/datatables/admin/effective_membership_histories_datatable.rb
@@ -302,6 +304,7 @@ files:
302
304
  - app/datatables/effective_applicant_reviews_datatable.rb
303
305
  - app/datatables/effective_applicants_datatable.rb
304
306
  - app/datatables/effective_available_applicant_reviews_datatable.rb
307
+ - app/datatables/effective_documents_datatable.rb
305
308
  - app/datatables/effective_fee_payments_datatable.rb
306
309
  - app/datatables/effective_memberships_directory_datatable.rb
307
310
  - app/datatables/effective_organizations_datatable.rb
@@ -330,6 +333,7 @@ files:
330
333
  - app/models/effective/applicant_reference.rb
331
334
  - app/models/effective/applicant_review.rb
332
335
  - app/models/effective/category.rb
336
+ - app/models/effective/document.rb
333
337
  - app/models/effective/fee.rb
334
338
  - app/models/effective/fee_payment.rb
335
339
  - app/models/effective/membership.rb
@@ -366,6 +370,7 @@ files:
366
370
  - app/views/admin/categories/_form_fee_payment_content.html.haml
367
371
  - app/views/admin/categories/_form_fee_payment_steps.html.haml
368
372
  - app/views/admin/categories/_form_fees.html.haml
373
+ - app/views/admin/documents/_form.html.haml
369
374
  - app/views/admin/fee_payments/_fee_payment.html.haml
370
375
  - app/views/admin/fees/_fee.html.haml
371
376
  - app/views/admin/fees/_form.html.haml
@@ -461,6 +466,7 @@ files:
461
466
  - app/views/effective/applicants/submitted.html.haml
462
467
  - app/views/effective/applicants/summary.html.haml
463
468
  - app/views/effective/applicants/transcripts.html.haml
469
+ - app/views/effective/documents/_dashboard.html.haml
464
470
  - app/views/effective/fee_payments/_content.html.haml
465
471
  - app/views/effective/fee_payments/_dashboard.html.haml
466
472
  - app/views/effective/fee_payments/_declarations.html.haml