effective_committees 0.0.2

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.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +186 -0
  4. data/Rakefile +18 -0
  5. data/app/assets/config/effective_committees_manifest.js +3 -0
  6. data/app/assets/javascripts/effective_committees/base.js +0 -0
  7. data/app/assets/javascripts/effective_committeesjs +1 -0
  8. data/app/assets/stylesheets/effective_committees/base.scss +0 -0
  9. data/app/assets/stylesheets/effective_committees.scss +1 -0
  10. data/app/controllers/admin/committee_files_controller.rb +16 -0
  11. data/app/controllers/admin/committee_folders_controller.rb +16 -0
  12. data/app/controllers/admin/committee_members_controller.rb +16 -0
  13. data/app/controllers/admin/committees_controller.rb +22 -0
  14. data/app/controllers/effective/committee_folders_controller.rb +7 -0
  15. data/app/controllers/effective/committee_members_controller.rb +19 -0
  16. data/app/controllers/effective/committees_controller.rb +17 -0
  17. data/app/datatables/admin/effective_committee_files_datatable.rb +24 -0
  18. data/app/datatables/admin/effective_committee_folders_datatable.rb +28 -0
  19. data/app/datatables/admin/effective_committee_members_datatable.rb +32 -0
  20. data/app/datatables/admin/effective_committees_datatable.rb +34 -0
  21. data/app/datatables/effective_committee_members_datatable.rb +42 -0
  22. data/app/datatables/effective_committees_datatable.rb +31 -0
  23. data/app/helpers/effective_committees_helper.rb +3 -0
  24. data/app/models/concerns/effective_committees_user.rb +40 -0
  25. data/app/models/effective/committee.rb +55 -0
  26. data/app/models/effective/committee_file.rb +40 -0
  27. data/app/models/effective/committee_folder.rb +42 -0
  28. data/app/models/effective/committee_member.rb +76 -0
  29. data/app/views/admin/committee_files/_form.html.haml +14 -0
  30. data/app/views/admin/committee_folders/_form.html.haml +21 -0
  31. data/app/views/admin/committee_members/_form.html.haml +31 -0
  32. data/app/views/admin/committee_members/_user_fields.html.haml +7 -0
  33. data/app/views/admin/committees/_fields.html.haml +7 -0
  34. data/app/views/admin/committees/_form.html.haml +20 -0
  35. data/app/views/admin/committees/_form_committee.html.haml +6 -0
  36. data/app/views/effective/committee_folders/_committee_folder.html.haml +24 -0
  37. data/app/views/effective/committee_members/_form.html.haml +35 -0
  38. data/app/views/effective/committee_members/_user_fields.html.haml +7 -0
  39. data/app/views/effective/committees/_committee.html.haml +23 -0
  40. data/app/views/effective/committees/_dashboard.html.haml +10 -0
  41. data/app/views/effective/committees/_fields.html.haml +2 -0
  42. data/app/views/effective/committees/_form.html.haml +8 -0
  43. data/app/views/effective/committees/_form_committee.html.haml +11 -0
  44. data/app/views/effective/committees/index.html.haml +21 -0
  45. data/config/effective_committees.rb +13 -0
  46. data/config/routes.rb +24 -0
  47. data/db/migrate/01_create_effective_committees.rb.erb +14 -0
  48. data/db/seeds.rb +1 -0
  49. data/lib/effective_committees/engine.rb +18 -0
  50. data/lib/effective_committees/version.rb +3 -0
  51. data/lib/effective_committees.rb +18 -0
  52. data/lib/generators/effective_committees/install_generator.rb +31 -0
  53. data/lib/generators/templates/effective_committees_mailer_preview.rb +4 -0
  54. data/lib/tasks/effective_committees_tasks.rake +8 -0
  55. metadata +250 -0
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Effective
4
+ class CommitteeFile < ActiveRecord::Base
5
+ self.table_name = EffectiveCommittees.committee_files_table_name.to_s
6
+
7
+ log_changes(to: :committee) if respond_to?(:log_changes)
8
+
9
+ belongs_to :committee, polymorphic: true, counter_cache: true
10
+ belongs_to :committee_folder, counter_cache: true
11
+
12
+ has_one_attached :file
13
+
14
+ effective_resource do
15
+ title :string
16
+ notes :text
17
+
18
+ timestamps
19
+ end
20
+
21
+ before_validation do
22
+ self.committee ||= committee_folder&.committee
23
+ end
24
+
25
+ before_validation(if: -> { file.attached? }) do
26
+ self.title ||= file.filename.to_s
27
+ end
28
+
29
+ scope :deep, -> { with_attached_file }
30
+ scope :sorted, -> { order(:title) }
31
+
32
+ validates :title, presence: true
33
+ validates :file, presence: true
34
+
35
+ def to_s
36
+ title.presence || 'file'
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Effective
4
+ class CommitteeFolder < ActiveRecord::Base
5
+ self.table_name = EffectiveCommittees.committee_folders_table_name.to_s
6
+
7
+ acts_as_slugged
8
+ log_changes(to: :committee) if respond_to?(:log_changes)
9
+
10
+ belongs_to :committee, polymorphic: true, counter_cache: true
11
+
12
+ has_rich_text :body
13
+ has_many :committee_files, -> { Effective::CommitteeFile.sorted }, dependent: :destroy, inverse_of: :committee
14
+
15
+ effective_resource do
16
+ title :string
17
+ slug :string
18
+
19
+ position :integer
20
+ committee_files_count :integer # Counter Cache
21
+
22
+ timestamps
23
+ end
24
+
25
+ before_validation(if: -> { committee.present? }) do
26
+ self.position ||= (committee.committee_folders.map { |obj| obj.position }.compact.max || -1) + 1
27
+ end
28
+
29
+ scope :deep, -> { includes(:committee, :committee_files) }
30
+ scope :sorted, -> { order(:position) }
31
+
32
+ validates :title, presence: true, length: { maximum: 250 },
33
+ uniqueness: { scope: [:committee_id], message: 'already exists for this committee'}
34
+
35
+ validates :position, presence: true
36
+
37
+ def to_s
38
+ title.presence || 'folder'
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Effective
4
+ class CommitteeMember < ActiveRecord::Base
5
+ self.table_name = EffectiveCommittees.committee_members_table_name.to_s
6
+
7
+ attr_accessor :user_ids, :committee_ids
8
+
9
+ acts_as_role_restricted
10
+ log_changes(to: :committee) if respond_to?(:log_changes)
11
+
12
+ belongs_to :committee, polymorphic: true, counter_cache: true
13
+ belongs_to :user, polymorphic: true
14
+
15
+ accepts_nested_attributes_for :committee
16
+ accepts_nested_attributes_for :user
17
+
18
+ effective_resource do
19
+ roles_mask :integer
20
+
21
+ timestamps
22
+ end
23
+
24
+ scope :sorted, -> { order(:id) }
25
+ scope :deep, -> { includes(:user, :committee) }
26
+
27
+ before_validation(if: -> { user_ids.present? }) do
28
+ assign_attributes(user_id: user_ids.first, user_ids: user_ids[1..-1])
29
+ end
30
+
31
+ before_validation(if: -> { committee_ids.present? }) do
32
+ assign_attributes(committee_id: committee_ids.first, committee_ids: committee_ids[1..-1])
33
+ end
34
+
35
+ after_commit(if: -> { user_ids.present? }) do
36
+ additional = (user_ids - CommitteeMember.where(committee_id: committee_id, user_id: user_ids).pluck(:user_id))
37
+ additional = additional.map { |user_id| {committee_id: committee_id, committee_type: committee_type, user_id: user_id, user_type: user_type, roles_mask: roles_mask} }
38
+ CommitteeMember.insert_all(additional)
39
+ end
40
+
41
+ after_commit(if: -> { committee_ids.present? }) do
42
+ additional = (committee_ids - CommitteeMember.where(user_id: user_id, committee_id: committee_ids).pluck(:committee_id))
43
+ additional = additional.map { |committee_id| {committee_id: committee_id, committee_type: committee_type, user_id: user_id, user_type: user_type, roles_mask: roles_mask} }
44
+ CommitteeMember.insert_all(additional)
45
+ end
46
+
47
+ validates :committee, presence: true
48
+ validates :user, presence: true
49
+
50
+ validates :user_id, if: -> { user_id && user_type && committee_id && committee_type },
51
+ uniqueness: { scope: [:committee_id, :committee_type], message: 'already belongs to this committee' }
52
+
53
+ def to_s
54
+ user.to_s
55
+ end
56
+
57
+ def user_ids
58
+ Array(@user_ids) - [nil, '']
59
+ end
60
+
61
+ def committee_ids
62
+ Array(@committee_ids) - [nil, '']
63
+ end
64
+
65
+ def build_user(attributes = {})
66
+ raise('please assign user_type first') if user_type.blank?
67
+ self.user = user_type.constantize.new(attributes)
68
+ end
69
+
70
+ def build_committee(attributes = {})
71
+ raise('please assign committee_type first') if committee_type.blank?
72
+ self.committee = committee_type.constantize.new(attributes)
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,14 @@
1
+ = effective_form_with(model: [:admin, committee_file], engine: true) do |f|
2
+
3
+ - if inline_datatable? && inline_datatable.attributes[:committee_folder_id].present?
4
+ = f.hidden_field :committee_folder_id
5
+ - elsif inline_datatable?
6
+ = f.select :committee_folder_id, Effective::CommitteeFolder.sorted.all.where(committee: committee_file.committee)
7
+ - else
8
+ = f.select :committee_id, Effective::Committee.sorted.all
9
+ = f.select :committee_folder_id, Effective::CommitteeFolder.sorted.all
10
+
11
+ = f.file_field :file
12
+ = f.text_area :notes
13
+
14
+ = f.submit
@@ -0,0 +1,21 @@
1
+ = effective_form_with(model: [:admin, committee_folder], engine: true) do |f|
2
+ - if inline_datatable?
3
+ = f.hidden_field :committee_id
4
+ = f.hidden_field :committee_type
5
+ - else
6
+ = f.select :committee, { 'Committees' => Effective::Committee.sorted }, polymorphic: true
7
+
8
+ = f.text_field :title
9
+
10
+ - if f.object.persisted? || f.object.errors.include?(:slug)
11
+ - current_url = (effective_events.event_url(f.object) rescue nil)
12
+ = f.text_field :slug, hint: "The slug controls this event's internet address. Be careful, changing the slug will break links that other websites may have to the old address.<br>#{('This folder is currently reachable via ' + link_to(current_url.gsub(f.object.slug, '<strong>' + f.object.slug + '</strong>').html_safe, current_url)) if current_url }".html_safe
13
+
14
+ = f.rich_text_area :body, hint: 'Displayed on the folder page'
15
+
16
+ = f.submit
17
+
18
+ - if committee_folder.persisted?
19
+ %h2 #{committee_folder} Files
20
+ - datatable = Admin::EffectiveCommitteeFilesDatatable.new(committee_folder: committee_folder, committee: committee_folder.committee)
21
+ = render_inline_datatable(datatable)
@@ -0,0 +1,31 @@
1
+ = effective_form_with(model: [:admin, committee_member], engine: true) do |f|
2
+ - f.object.user_type ||= current_user.class.name
3
+ - f.object.committee_type ||= Effective::Committee.name
4
+
5
+ - committees = Effective::Committee.sorted.all
6
+
7
+ = f.hidden_field :user_type
8
+ = f.hidden_field :user_id
9
+
10
+ = f.hidden_field :committee_type
11
+ = f.hidden_field :committee_id
12
+
13
+ - if f.object.new_record?
14
+ - if inline_datatable? && inline_datatable.attributes[:committee_id].present?
15
+ = f.select :user_ids, current_user.class.sorted, label: 'Add user(s)', hint: 'Add one or more users'
16
+
17
+ - if inline_datatable? && inline_datatable.attributes[:user_id].present?
18
+ = f.select :committee_ids, committees, label: 'Add committee(s)', hint: 'Add one or more committees'
19
+
20
+ - unless inline_datatable?
21
+ = f.select :committee_id, committees, label: 'Committee'
22
+ = f.select :user_ids, current_user.class.sorted, label: 'User(s)', hint: 'Add one or more user at a time'
23
+
24
+ - if f.object.persisted?
25
+ = f.static_field :committee
26
+ = f.static_field :user, label: 'Committee Member'
27
+
28
+ - if EffectiveCommittees.use_effective_roles
29
+ = f.checks :roles, EffectiveRoles.roles_collection(f.object, skip_disabled: true)
30
+
31
+ = f.submit
@@ -0,0 +1,7 @@
1
+ = f.email_field :email
2
+
3
+ - if f.object.respond_to?(:first_name)
4
+ = f.text_field :first_name
5
+
6
+ - if f.object.respond_to?(:last_name)
7
+ = f.text_field :last_name
@@ -0,0 +1,7 @@
1
+ = f.text_field :title
2
+
3
+ - if f.object.persisted? || f.object.errors.include?(:slug)
4
+ - current_url = (effective_events.event_url(f.object) rescue nil)
5
+ = f.text_field :slug, hint: "The slug controls this event's internet address. Be careful, changing the slug will break links that other websites may have to the old address.<br>#{('This committee is currently reachable via ' + link_to(current_url.gsub(f.object.slug, '<strong>' + f.object.slug + '</strong>').html_safe, current_url)) if current_url }".html_safe
6
+
7
+ = f.rich_text_area :body, hint: 'Displayed on the committee page'
@@ -0,0 +1,20 @@
1
+ = tabs do
2
+ = tab 'Committee' do
3
+ = render 'admin/committees/form_committee', committee: committee
4
+
5
+ - if committee.persisted?
6
+ = tab 'Members' do
7
+ - datatable = Admin::EffectiveCommitteeMembersDatatable.new(committee: committee)
8
+ = render_inline_datatable(datatable)
9
+
10
+ = tab 'Folders' do
11
+ - datatable = Admin::EffectiveCommitteeFoldersDatatable.new(committee: committee)
12
+ = render_inline_datatable(datatable)
13
+
14
+ = tab 'Files' do
15
+ - datatable = Admin::EffectiveCommitteeFilesDatatable.new(committee: committee)
16
+ = render_inline_datatable(datatable)
17
+
18
+ - if committee.respond_to?(:log_changes_datatable)
19
+ = tab 'Logs' do
20
+ = render_inline_datatable(committee.log_changes_datatable)
@@ -0,0 +1,6 @@
1
+ = effective_form_with(model: [:admin, committee], engine: true) do |f|
2
+ = render 'admin/committees/fields', f: f
3
+
4
+ = f.submit do
5
+ = f.save 'Save'
6
+ = f.save 'Save and View', class: 'btn btn-secondary'
@@ -0,0 +1,24 @@
1
+ %nav{'aria-label': 'breadcrumb'}
2
+ %ol.breadcrumb
3
+ %li.breadcrumb-item= link_to('All Committees', effective_committees.committees_path)
4
+ %li.breadcrumb-item= link_to(committee_folder.committee, effective_committees.committee_path(committee_folder.committee))
5
+ %li.breadcrumb-item.active{'aria-current': 'page'}= committee_folder
6
+
7
+ .effective-committee-folder
8
+ - if committee_folder.rich_text_body.present?
9
+ .mb-4= committee_folder.rich_text_body
10
+
11
+ %table.table.table-striped
12
+ %thead
13
+ %tr
14
+ %th File
15
+ %th Date Added
16
+ %th Description
17
+
18
+ - committee_folder.committee_files.each do |file|
19
+ %tr
20
+ %td= link_to(icon('download') + file, url_for(file.file), target: '_blank')
21
+ %td= file.created_at.strftime('%F')
22
+ %td= file.notes
23
+
24
+ %p Displaying #{pluralize(committee_folder.committee_files.length, 'file')}
@@ -0,0 +1,35 @@
1
+ = effective_form_with(model: committee_member, engine: true) do |f|
2
+ - f.object.user_type ||= current_user.class.name
3
+
4
+ = f.hidden_field :user_id
5
+ = f.hidden_field :user_type
6
+ = f.hidden_field :committee_id
7
+ = f.hidden_field :committee_type
8
+
9
+ - if f.object.new_record?
10
+ - unless inline_datatable? && inline_datatable.attributes[:committee_id].present?
11
+ = f.select :committee, { 'Committees' => Effective::Committee.sorted }, polymorphic: true
12
+
13
+ - if EffectiveCommittees.use_effective_roles
14
+ = f.checks :roles, EffectiveRoles.roles_collection(f.object, skip_disabled: true)
15
+
16
+ - unless inline_datatable? && inline_datatable.attributes[:user_id].present?
17
+ = f.hidden_field :new_committee_member_user_action, value: 'Invite new user'
18
+
19
+ = f.fields_for :user, (f.object.user || f.object.build_user) do |fu|
20
+ = render 'effective/committee_members/user_fields', f: fu
21
+
22
+ - if f.object.persisted?
23
+ - unless inline_datatable? && inline_datatable.attributes[:committee_id].present?
24
+ = f.static_field :committee
25
+
26
+ - unless inline_datatable? && inline_datatable.attributes[:user_id].present?
27
+ = f.static_field :user
28
+
29
+ - if EffectiveCommittees.use_effective_roles
30
+ = f.checks :roles, EffectiveRoles.roles_collection(f.object, skip_disabled: true)
31
+
32
+ = f.fields_for :user, f.object.user do |fu|
33
+ = render 'effective/committee_members/user_fields', f: fu
34
+
35
+ = f.submit
@@ -0,0 +1,7 @@
1
+ = f.email_field :email
2
+
3
+ - if f.object.respond_to?(:first_name)
4
+ = f.text_field :first_name
5
+
6
+ - if f.object.respond_to?(:last_name)
7
+ = f.text_field :last_name
@@ -0,0 +1,23 @@
1
+ %nav{'aria-label': 'breadcrumb'}
2
+ %ol.breadcrumb
3
+ %li.breadcrumb-item= link_to('All Committees', effective_committees.committees_path)
4
+ %li.breadcrumb-item.active{'aria-current': 'page'}= committee
5
+
6
+ .effective-committee
7
+ - if committee.rich_text_body.present?
8
+ .mb-4= committee.rich_text_body
9
+
10
+ %table.table.table-striped
11
+ %thead
12
+ %tr
13
+ %th Folder
14
+ %th Files
15
+ %th Description
16
+
17
+ - committee.committee_folders.each do |folder|
18
+ %tr
19
+ %td= link_to(icon('folder') + folder, effective_committees.committee_committee_folder_path(committee, folder))
20
+ %td= pluralize(folder.committee_files.length, 'file')
21
+ %td= folder.body
22
+
23
+ %p Displaying #{pluralize(committee.committee_folders.length, 'folder')}
@@ -0,0 +1,10 @@
1
+ %h2 Committees
2
+
3
+ - if current_user.committees.present?
4
+ %p You are a member of #{pluralize(current_user.committees.length, 'committee')}.
5
+
6
+ - datatable = EffectiveResources.best('EffectiveCommitteesDatatable').new(self, namespace: :effective)
7
+ = render_datatable(datatable, simple: true)
8
+
9
+ - else
10
+ %p You are not a committee member. When you join a committee, we'll show it here.
@@ -0,0 +1,2 @@
1
+ = f.text_field :title
2
+ = f.rich_text_area :rich_text_body, hint: 'The main body'
@@ -0,0 +1,8 @@
1
+ = tabs do
2
+ = tab 'Committee' do
3
+ = render 'effective/committees/form_committee', committee: committee
4
+
5
+ - if committee.persisted?
6
+ - if committee.respond_to?(:log_changes_datatable)
7
+ = tab 'Logs' do
8
+ = render_inline_datatable(committee.log_changes_datatable)
@@ -0,0 +1,11 @@
1
+ - url = (committee.persisted? ? effective_committees.committee_path(committee) : effective_committees.committees_path)
2
+
3
+ = effective_form_with(model: committee, url: url) do |f|
4
+ = render 'effective/committees/fields', f: f
5
+
6
+ = f.submit
7
+
8
+ - if committee.persisted?
9
+ %h2 Committee Members
10
+ - datatable = EffectiveCommitteeMembersDatatable.new(committee: committee)
11
+ = render_inline_datatable(datatable)
@@ -0,0 +1,21 @@
1
+ - committees = @committees.where(id: current_user.committees)
2
+
3
+ %p
4
+ You have access to files for #{pluralize(committees.length, 'committee')}:
5
+ = committees.to_sentence
6
+
7
+ %nav{'aria-label': 'breadcrumb'}
8
+ %ol.breadcrumb
9
+ %li.breadcrumb-item.active{'aria-current': 'page'} All Committees
10
+
11
+ .effective-committees
12
+ - committees.each do |committee|
13
+ = card do
14
+ = link_to(icon('folder') + committee, effective_committees.committee_path(committee))
15
+
16
+ %table.table.table-striped.mt-3.ml-4
17
+ - committee.committee_folders.each do |folder|
18
+ %tr
19
+ %td= link_to(icon('folder') + folder, effective_committees.committee_committee_folder_path(committee, folder))
20
+ %td= pluralize(folder.committee_files.length, 'file')
21
+ %td= folder.body
@@ -0,0 +1,13 @@
1
+ EffectiveCommittees.setup do |config|
2
+ config.committees_table_name = :committees
3
+ config.committee_members_table_name = :committee_members
4
+ config.committee_folders_table_name = :committee_folders
5
+ config.committee_files_table_name = :committee_files
6
+
7
+ # Layout Settings
8
+ # Configure the Layout per controller, or all at once
9
+ # config.layout = { application: 'application', admin: 'admin' }
10
+
11
+ # Committee Members can belong to a committee with a role
12
+ config.use_effective_roles = true
13
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ mount EffectiveCommittees::Engine => '/', as: 'effective_committees'
5
+ end
6
+
7
+ EffectiveCommittees::Engine.routes.draw do
8
+ # Public routes
9
+ scope module: 'effective' do
10
+ resources :committees, only: [:index, :show] do
11
+ resources :committee_folders, only: [:show]
12
+ end
13
+
14
+ resources :committee_members, except: [:show]
15
+ end
16
+
17
+ namespace :admin do
18
+ resources :committees, except: [:show]
19
+ resources :committee_members, except: [:show]
20
+ resources :committee_folders, except: [:show]
21
+ resources :committee_files, except: [:show]
22
+ end
23
+
24
+ end
@@ -0,0 +1,14 @@
1
+ class CreateEffectiveCommittees < ActiveRecord::Migration[6.0]
2
+ def change
3
+ # Committees
4
+ create_table :committees do |t|
5
+ end
6
+
7
+ add_index :committees, :title
8
+
9
+ # Representatives
10
+ create_table :representatives do |t|
11
+ end
12
+
13
+ end
14
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1 @@
1
+ puts "Running effective_committees seeds"
@@ -0,0 +1,18 @@
1
+ module EffectiveCommittees
2
+ class Engine < ::Rails::Engine
3
+ engine_name 'effective_committees'
4
+
5
+ # Set up our default configuration options.
6
+ initializer 'effective_committees.defaults', before: :load_config_initializers do |app|
7
+ eval File.read("#{config.root}/config/effective_committees.rb")
8
+ end
9
+
10
+ # Include acts_as_addressable concern and allow any ActiveRecord object to call it
11
+ initializer 'effective_committees.active_record' do |app|
12
+ ActiveSupport.on_load :active_record do
13
+ ActiveRecord::Base.extend(EffectiveCommitteesUser::Base)
14
+ end
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module EffectiveCommittees
2
+ VERSION = '0.0.2'.freeze
3
+ end
@@ -0,0 +1,18 @@
1
+ require 'effective_resources'
2
+ require 'effective_datatables'
3
+ require 'effective_roles'
4
+ require 'effective_committees/engine'
5
+ require 'effective_committees/version'
6
+
7
+ module EffectiveCommittees
8
+
9
+ def self.config_keys
10
+ [
11
+ :committees_table_name, :committee_members_table_name, :committee_folders_table_name, :committee_files_table_name,
12
+ :layout, :use_effective_roles
13
+ ]
14
+ end
15
+
16
+ include EffectiveGem
17
+
18
+ end
@@ -0,0 +1,31 @@
1
+ module EffectiveMemberships
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+
6
+ desc 'Creates an EffectiveCommittees initializer in your application.'
7
+
8
+ source_root File.expand_path('../../templates', __FILE__)
9
+
10
+ def self.next_migration_number(dirname)
11
+ if not ActiveRecord::Base.timestamped_migrations
12
+ Time.new.utc.strftime("%Y%m%d%H%M%S")
13
+ else
14
+ '%.3d' % (current_migration_number(dirname) + 1)
15
+ end
16
+ end
17
+
18
+ def copy_initializer
19
+ template ('../' * 3) + 'config/effective_committees.rb', 'config/initializers/effective_committees.rb'
20
+ end
21
+
22
+ def create_migration_file
23
+ @committees_table_name = ':' + EffectiveCommittees.committees_table_name.to_s
24
+ @committee_members_table_name = ':' + EffectiveCommittees.committee_members_table_name.to_s
25
+
26
+ migration_template ('../' * 3) + 'db/migrate/01_create_effective_committees.rb.erb', 'db/migrate/create_effective_committees.rb'
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,4 @@
1
+ # Visit http://localhost:3000/rails/mailers
2
+
3
+ class EffectiveCommitteesMailerPreview < ActionMailer::Preview
4
+ end
@@ -0,0 +1,8 @@
1
+ namespace :effective_committees do
2
+
3
+ # bundle exec rake effective_committees:seed
4
+ task seed: :environment do
5
+ load "#{__dir__}/../../db/seeds.rb"
6
+ end
7
+
8
+ end