effective_memberships 0.10.1 → 0.12.0

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: '09cdd3d71c709fdaacb54d4abd0d21217bd6e7e3a7395e687004eb124994b75b'
4
- data.tar.gz: caebcbe36b5c113d715e47ef8df0d224f7ea825ae0fa3ea3f5efc59448bcc30f
3
+ metadata.gz: fcda6f904900bdb868f397b966b91246eb5199ccb40e2fd0ff585fe1a40a5c2d
4
+ data.tar.gz: 496de8f40e138891794d41f6ce816941638ace3701dbfd40e111f39c4e5aaa4a
5
5
  SHA512:
6
- metadata.gz: 50897b485cca843711185839c1e630b90211ac1559c7a956fd5d425d70a37ad7ef94b6a3863cd1055ac8efa226ef635a4b6186f32763e260c277cb198b4c7f3c
7
- data.tar.gz: 0a53cc0947501e0f89c07d56e052b81f5b6a7f2c676698e5e45227f0c9ae460b8c674d90fd0bc521601eb5adef49ab07d1433ce6ccd5f80fcefb670b6c9845d6
6
+ metadata.gz: 5bc4751c68972b32b0e851d42a837bfeacacf73291aa128871836fe339d339c56ef26f8cd78badb8b12bf2ad41ea0487b232d30b0fa71e0d2e955a7c2a2e8543
7
+ data.tar.gz: 8bdb806fe84d1c1034b6fa620a92268e6cf1c220f2679d58be9d705971501230a87af5a4a1d38e5bd7bd6f94f1a4638a464e15ce4937938f9269d10f404b189c
@@ -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
@@ -260,4 +260,8 @@ module EffectiveMembershipsCategory
260
260
  tax_exempt
261
261
  end
262
262
 
263
+ def cpd_target_score(cpd_cycle:)
264
+ nil
265
+ end
266
+
263
267
  end
@@ -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
@@ -144,7 +144,13 @@ module Effective
144
144
  end
145
145
 
146
146
  def default_title
147
- [period&.strftime('%Y'), category, fee_type, 'Fee'].compact.join(' ')
147
+ return nil unless period.present? && fee_type.present?
148
+
149
+ [
150
+ period.strftime('%Y'),
151
+ category,
152
+ EffectiveResources.et("effective_memberships.fees.#{fee_type.downcase}")
153
+ ].join(' ')
148
154
  end
149
155
 
150
156
  end
@@ -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
  #
@@ -0,0 +1,39 @@
1
+ en:
2
+ effective_memberships:
3
+ name: 'Effective Memberships'
4
+
5
+ fees:
6
+ applicant: 'Applicant Fee'
7
+ prorated: 'Prorated Fee'
8
+ reinstatement: 'Reinstatement Fee'
9
+ renewal: 'Renewal Fee'
10
+ late: 'Late Fee'
11
+ discount: 'Discount Fee'
12
+ admin: 'Admin Fee'
13
+
14
+ activerecord:
15
+ models:
16
+ # These ones might be app level
17
+ app/applicant: 'Applicant'
18
+ app/applicant_review: 'Applicant Review'
19
+ app/membership_card: 'Membership Card'
20
+ app/category: 'Category'
21
+ app/directory: 'Directory'
22
+ app/fee_payment: 'Fee Payment'
23
+ app/organization: 'Organization'
24
+ app/status: 'Status'
25
+
26
+ # These ones should stay effective
27
+ effective/applicant_course_area: 'Course Area'
28
+ effective/applicant_course_name: 'Course Name'
29
+ effective/applicant_course: 'Course'
30
+ effective/applicant_education: 'Education'
31
+ effective/applicant_endorsement: 'Endorsement'
32
+ effective/applicant_equivalence: 'Equivalence'
33
+ effective/applicant_experience: 'Experience'
34
+ effective/applicant_reference: 'Reference'
35
+ effective/document: 'Document'
36
+ effective/fee: 'Fee'
37
+ effective/membership_history: 'Membership History'
38
+ effective/membership: 'Membership'
39
+ effective/representative: 'Representative'
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.1'
2
+ VERSION = '0.12.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.1
4
+ version: 0.12.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-02-02 00:00:00.000000000 Z
11
+ date: 2023-03-06 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
@@ -507,6 +513,7 @@ files:
507
513
  - app/views/users/_demographics.html.haml
508
514
  - app/views/users/_fields_demographics.html.haml
509
515
  - config/effective_memberships.rb
516
+ - config/locales/effective_memberships.en.yml
510
517
  - config/routes.rb
511
518
  - db/migrate/01_create_effective_memberships.rb.erb
512
519
  - db/seeds.rb