effective_memberships 0.10.1 → 0.11.0
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/documents_controller.rb +15 -0
- data/app/datatables/admin/effective_documents_datatable.rb +28 -0
- data/app/datatables/effective_documents_datatable.rb +31 -0
- data/app/models/effective/document.rb +50 -0
- data/app/views/admin/documents/_form.html.haml +19 -0
- data/app/views/effective/documents/_dashboard.html.haml +8 -0
- data/config/effective_memberships.rb +5 -0
- data/config/routes.rb +1 -0
- data/db/migrate/01_create_effective_memberships.rb.erb +14 -0
- data/lib/effective_memberships/version.rb +1 -1
- data/lib/effective_memberships.rb +2 -2
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab9a748ab11ca8d852d0b69ed6f5d05e40e0e67b966e1c85f6cf98592db2dc32
|
4
|
+
data.tar.gz: b048158b7cea70c82fa04ab13cc91a37fcc20edcd5b6356b0ff6d9efbb967314
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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
|
@@ -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
@@ -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
|
@@ -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.
|
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-02-
|
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
|