effective_mentorships 0.0.1

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 (34) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +88 -0
  4. data/Rakefile +18 -0
  5. data/app/assets/config/effective_mentorships_manifest.js +3 -0
  6. data/app/assets/javascripts/effective_mentorships.js +1 -0
  7. data/app/assets/stylesheets/effective_mentorships.scss +0 -0
  8. data/app/controllers/admin/mentorship_cycles_controller.rb +17 -0
  9. data/app/controllers/effective/mentorship_cycles_controller.rb +9 -0
  10. data/app/datatables/admin/effective_mentorship_cycles_datatable.rb +27 -0
  11. data/app/helpers/effective_mentorships_helper.rb +39 -0
  12. data/app/mailers/effective/mentorships_mailer.rb +18 -0
  13. data/app/models/concerns/effective_mentorships_group.rb +51 -0
  14. data/app/models/concerns/effective_mentorships_registration.rb +58 -0
  15. data/app/models/concerns/effective_mentorships_user.rb +54 -0
  16. data/app/models/effective/mentorship_cycle.rb +104 -0
  17. data/app/models/effective/mentorship_group.rb +5 -0
  18. data/app/models/effective/mentorship_registration.rb +5 -0
  19. data/app/views/admin/mentorship_cycles/_form.html.haml +8 -0
  20. data/app/views/admin/mentorship_cycles/_form_mentorship_cycle.html.haml +31 -0
  21. data/app/views/effective/mentorships/_dashboard.html.haml +1 -0
  22. data/app/views/effective/mentorships_mailer/README.md +1 -0
  23. data/config/effective_mentorships.rb +31 -0
  24. data/config/locales/effective_mentorships.en.yml +15 -0
  25. data/config/routes.rb +12 -0
  26. data/db/migrate/101_create_effective_mentorships.rb +45 -0
  27. data/db/seeds.rb +20 -0
  28. data/lib/effective_mentorships/engine.rb +20 -0
  29. data/lib/effective_mentorships/version.rb +3 -0
  30. data/lib/effective_mentorships.rb +47 -0
  31. data/lib/generators/effective_mentorships/install_generator.rb +42 -0
  32. data/lib/generators/templates/effective_mentorship_mailer_preview.rb +4 -0
  33. data/lib/tasks/effective_mentorships_tasks.rake +8 -0
  34. metadata +257 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8d38ae69a59937ebf5e1c21dad2407001277481495e60af6a1d1870609c9c6fb
4
+ data.tar.gz: a8d9c6644d62270c9f2c28662d94e3e833ecbf57ee1daa99b5ac2668f3dbc234
5
+ SHA512:
6
+ metadata.gz: f99ac651786e4cbcc30363b4170ace9ba1d44537fe174a8dd67d35ff004a4bb7d2b0e5556015952c0a20450c9d4871b706f659a1cce42074b726233a3d958a0a
7
+ data.tar.gz: 62124e0a9999292cc0d61e736d808c619f1e942a027edab3fc4c912dda2639fe605cb87bc8b82b87dca3ca8ead57b8b8c6a95c70f312713f752fd3cba3907be8
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2024 Code and Effect Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # Effective Mentorships
2
+
3
+ Mentorship program to match mentors and mentees.
4
+
5
+ ## Getting Started
6
+
7
+ This requires Rails 6+ and Twitter Bootstrap 4 and just works with Devise.
8
+
9
+ Please first install the [effective_datatables](https://github.com/code-and-effect/effective_datatables) gem.
10
+
11
+ Please download and install the [Twitter Bootstrap4](http://getbootstrap.com)
12
+
13
+ Add to your Gemfile:
14
+
15
+ ```ruby
16
+ gem 'haml-rails'
17
+ gem 'effective_mentorships'
18
+ ```
19
+
20
+ Run the bundle command to install it:
21
+
22
+ ```console
23
+ bundle install
24
+ ```
25
+
26
+ Then run the generator:
27
+
28
+ ```ruby
29
+ rails generate effective_mentorships:install
30
+ ```
31
+
32
+ The generator will install an initializer which describes all configuration options and creates a database migration.
33
+
34
+ If you want to tweak the table names, manually adjust both the configuration file and the migration now.
35
+
36
+ Then migrate the database:
37
+
38
+ ```ruby
39
+ rake db:migrate
40
+ ```
41
+
42
+ Please add the following to your User model:
43
+
44
+ ```
45
+ ```
46
+
47
+ Add a link to the admin menu:
48
+
49
+ ```haml
50
+ - if can? :admin, :effective_mentorships
51
+ = nav_link_to Effective::MentorshipCycle, effective_mentorship.admin_mentorship_cycles_path
52
+ ```
53
+
54
+ ## Configuration
55
+
56
+ As an admin, visit the Mentorship Cycles, and groups
57
+
58
+ ## Authorization
59
+
60
+ All authorization checks are handled via the effective_resources gem found in the `config/initializers/effective_resources.rb` file.
61
+
62
+ ## Permissions
63
+
64
+ The permissions you actually want to define are as follows (using CanCanCan):
65
+
66
+ ```ruby
67
+ ```
68
+
69
+ ## License
70
+
71
+ Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
72
+
73
+ ## Testing
74
+
75
+ Run tests by:
76
+
77
+ ```ruby
78
+ rails test
79
+ ```
80
+
81
+ ## Contributing
82
+
83
+ 1. Fork it
84
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
85
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
86
+ 4. Push to the branch (`git push origin my-new-feature`)
87
+ 5. Bonus points for test coverage
88
+ 6. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
9
+
10
+ require "rake/testtask"
11
+
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = false
16
+ end
17
+
18
+ task default: :test
@@ -0,0 +1,3 @@
1
+ //= link_directory ../javascripts .js
2
+ //= link_directory ../stylesheets .css
3
+ //= link_tree ../images
@@ -0,0 +1 @@
1
+ //= require_tree ./effective_mentorship
File without changes
@@ -0,0 +1,17 @@
1
+ module Admin
2
+ class MentorshipCyclesController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_mentorships) }
5
+
6
+ include Effective::CrudController
7
+
8
+ resource_scope -> { Effective::MentorshipCycle.deep.all }
9
+
10
+ private
11
+
12
+ def permitted_params
13
+ params.require(:effective_mentorship_cycle).permit!
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module Effective
2
+ class MentorshipCyclesController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+
5
+ include Effective::CrudController
6
+
7
+ resource_scope -> { Effective::MentorshipCycle.deep.all }
8
+ end
9
+ end
@@ -0,0 +1,27 @@
1
+ module Admin
2
+ class EffectiveMentorshipCyclesDatatable < Effective::Datatable
3
+ datatable do
4
+ order :start_at, :desc
5
+
6
+ col :id, visible: false
7
+ col :created_at, visible: false
8
+ col :updated_at, visible: false
9
+
10
+ col :title
11
+ col :start_at
12
+ col :end_at
13
+
14
+ col :registration_start_at
15
+ col :registration_end_at
16
+
17
+ col :max_pairings_mentor, label: "Max #{mentorships_mentors_label}"
18
+ col :max_pairings_mentee, label: "Max #{mentorships_mentees_label}"
19
+
20
+ actions_col
21
+ end
22
+
23
+ collection do
24
+ Effective::MentorshipCycle.all.deep
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,39 @@
1
+ module EffectiveMentorshipsHelper
2
+
3
+ def mentorships_name_label
4
+ et('effective_mentorships.name')
5
+ end
6
+
7
+ def mentorships_mentee_label
8
+ et('effective_mentorships.mentee')
9
+ end
10
+
11
+ def mentorships_mentees_label
12
+ ets('effective_mentorships.mentee')
13
+ end
14
+
15
+ def mentorships_mentor_label
16
+ et('effective_mentorships.mentor')
17
+ end
18
+
19
+ def mentorships_mentors_label
20
+ ets('effective_mentorships.mentor')
21
+ end
22
+
23
+ def mentorship_cycle_label
24
+ et(Effective::MentorshipCycle)
25
+ end
26
+
27
+ def mentorship_cycles_label
28
+ ets(Effective::MentorshipCycle)
29
+ end
30
+
31
+ def mentorship_group_label
32
+ et(EffectiveMentorships.MentorshipGroup)
33
+ end
34
+
35
+ def mentorship_groups_label
36
+ ets(EffectiveMentorships.MentorshipGroup)
37
+ end
38
+
39
+ end
@@ -0,0 +1,18 @@
1
+ module Effective
2
+ class MentorshipsMailer < EffectiveMentorships.parent_mailer_class
3
+
4
+ include EffectiveMailer
5
+ include EffectiveEmailTemplatesMailer
6
+
7
+ protected
8
+
9
+ def assigns_for(resource)
10
+ unless resource.kind_of?(EffectiveMentorships.MentorshipGroup)
11
+ raise('expected an EffectiveMentorships.MentorshipGroup')
12
+ end
13
+
14
+ {}
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # EffectiveMentorshipsGroup
4
+ #
5
+ # Mark your group model with effective_mentorships_group to get all the includes
6
+
7
+ module EffectiveMentorshipsGroup
8
+ extend ActiveSupport::Concern
9
+
10
+ module Base
11
+ def effective_mentorships_group
12
+ include ::EffectiveMentorshipsGroup
13
+ end
14
+ end
15
+
16
+ module ClassMethods
17
+ def effective_mentorships_group?; true; end
18
+ end
19
+
20
+ included do
21
+ log_changes if respond_to?(:log_changes)
22
+ acts_as_archived
23
+ acts_as_tokened
24
+
25
+ # rich_text_body
26
+ has_many_rich_texts
27
+
28
+ # Effective Scoped
29
+ belongs_to :mentorship_cycle, class_name: 'Effective::MentorshipCycle', counter_cache: true
30
+
31
+ # App Scoped
32
+ belongs_to :user
33
+
34
+ effective_resource do
35
+ archived :boolean
36
+
37
+ token :string
38
+
39
+ timestamps
40
+ end
41
+
42
+ scope :deep, -> { includes(:rich_texts) }
43
+ scope :sorted, -> { order(:id) }
44
+ end
45
+
46
+ # Instance Methods
47
+ def to_s
48
+ model_name.human
49
+ end
50
+
51
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ # EffectiveMentorshipsRegistration
4
+ #
5
+ # Mark your group model with effective_mentorships_registration to get all the includes
6
+
7
+ module EffectiveMentorshipsRegistration
8
+ extend ActiveSupport::Concern
9
+
10
+ module Base
11
+ def effective_mentorships_registration
12
+ include ::EffectiveMentorshipsRegistration
13
+ end
14
+ end
15
+
16
+ module ClassMethods
17
+ def effective_mentorships_registration?; true; end
18
+
19
+ def mentorship_roles
20
+ ['A Mentor', 'A Protege', 'Both']
21
+ end
22
+ end
23
+
24
+ included do
25
+ log_changes if respond_to?(:log_changes)
26
+ acts_as_tokened
27
+
28
+ # rich_text_body
29
+ has_many_rich_texts
30
+
31
+ # Effective Scoped
32
+ belongs_to :mentorship_cycle, class_name: 'Effective::MentorshipCycle', counter_cache: true
33
+
34
+ # App Scoped
35
+ belongs_to :user
36
+
37
+ effective_resource do
38
+ # Preferences
39
+ mentorship_role :string
40
+
41
+ token :string
42
+
43
+ timestamps
44
+ end
45
+
46
+ scope :deep, -> { includes(:rich_texts, :user, :mentorship_cycle) }
47
+ scope :sorted, -> { order(:id) }
48
+
49
+ # User
50
+ validates :user_id, uniqueness: { scope: [:mentorship_cycle_id] }
51
+ validates :mentorship_role, presence: true, inclusion: { in: mentorship_roles }
52
+ end
53
+
54
+ # Instance Methods
55
+ def to_s
56
+ mentorship_role.presence || model_name.human
57
+ end
58
+ end
@@ -0,0 +1,54 @@
1
+ # EffectiveMentorshipsUser
2
+ #
3
+ # Mark your user model with effective_mentorship_user to get a few helpers
4
+ # And user specific point required scores
5
+
6
+ module EffectiveMentorshipsUser
7
+ extend ActiveSupport::Concern
8
+
9
+ module Base
10
+ def effective_mentorships_user
11
+ include ::EffectiveMentorshipsUser
12
+ end
13
+ end
14
+
15
+ module ClassMethods
16
+ def effective_mentorships_user?; true; end
17
+ end
18
+
19
+ included do
20
+ # App Scoped
21
+ has_many :mentorship_groups, -> { order(:mentorship_cycle_id) }, inverse_of: :user, dependent: :destroy
22
+ accepts_nested_attributes_for :mentorship_groups, allow_destroy: true
23
+
24
+ has_many :mentorship_registrations, -> { order(:mentorship_cycle_id) }, inverse_of: :user, dependent: :destroy
25
+ accepts_nested_attributes_for :mentorship_registrations, allow_destroy: true
26
+
27
+ scope :deep_effective_mentorships_user, -> { all }
28
+ end
29
+
30
+ # Find
31
+ def mentorship_group(mentorship_cycle:)
32
+ raise('expected an MentorshipCycle') unless mentorship_cycle.class.respond_to?(:effective_mentorships_mentorship_cycle?)
33
+ mentorship_groups.find { |mentorship_group| mentorship_group.mentorship_cycle_id == mentorship_cycle.id }
34
+ end
35
+
36
+ # Find or build
37
+ def build_mentorship_group(mentorship_cycle:)
38
+ raise('expected an MentorshipCycle') unless mentorship_cycle.class.respond_to?(:effective_mentorships_mentorship_cycle?)
39
+ mentorship_group(mentorship_cycle: mentorship_cycle) || mentorship_groups.build(mentorship_cycle: mentorship_cycle)
40
+ end
41
+
42
+ # Find
43
+ def mentorship_registration(mentorship_cycle:)
44
+ raise('expected an MentorshipCycle') unless mentorship_cycle.class.respond_to?(:effective_mentorships_mentorship_cycle?)
45
+ mentorship_registrations.find { |mentorship_registration| mentorship_registration.mentorship_cycle_id == mentorship_cycle.id }
46
+ end
47
+
48
+ # Find or build
49
+ def build_mentorship_registration(mentorship_cycle:)
50
+ raise('expected an MentorshipCycle') unless mentorship_cycle.class.respond_to?(:effective_mentorships_mentorship_cycle?)
51
+ mentorship_registration(mentorship_cycle: mentorship_cycle) || mentorship_registrations.build(mentorship_cycle: mentorship_cycle)
52
+ end
53
+
54
+ end
@@ -0,0 +1,104 @@
1
+ module Effective
2
+ class MentorshipCycle < ActiveRecord::Base
3
+ has_many_rich_texts
4
+
5
+ has_many :mentorship_groups
6
+
7
+ if respond_to?(:log_changes)
8
+ log_changes(except: [:mentorship_groups])
9
+ end
10
+
11
+ effective_resource do
12
+ title :string # 2021 Mentorship Program
13
+
14
+ # Availability starts and ends at
15
+ start_at :datetime
16
+ end_at :datetime
17
+
18
+ registration_start_at :datetime
19
+ registration_end_at :datetime
20
+
21
+ max_pairings_mentor :integer
22
+ max_pairings_mentee :integer
23
+
24
+ timestamps
25
+ end
26
+
27
+ scope :deep, -> { includes(:rich_texts) }
28
+
29
+ scope :shallow, -> { select(:id, :title) }
30
+ scope :sorted, -> { order(:id) }
31
+
32
+ scope :upcoming, -> { where('start_at > ?', Time.zone.now) }
33
+ scope :available, -> { where('start_at <= ? AND (end_at > ? OR end_at IS NULL)', Time.zone.now, Time.zone.now) }
34
+ scope :completed, -> { where('end_at < ?', Time.zone.now) }
35
+
36
+ validates :title, presence: true
37
+ validates :start_at, presence: true
38
+
39
+ validate(if: -> { start_at.present? && end_at.present? }) do
40
+ errors.add(:end_at, 'must be after the start date') unless end_at > start_at
41
+ end
42
+
43
+ validate(if: -> { registration_start_at.present? && registration_end_at.present? }) do
44
+ errors.add(:registration_end_at, 'must be after the registration start date') unless registration_end_at > registration_start_at
45
+ end
46
+
47
+ # before_destroy do
48
+ # if (count = mentorship_groups.length) > 0
49
+ # raise("#{count} groups belong to this cycle")
50
+ # end
51
+ # end
52
+
53
+ def self.effective_mentorships_mentorship_cycle?
54
+ true
55
+ end
56
+
57
+ def self.latest_cycle
58
+ order(id: :desc).first
59
+ end
60
+
61
+ def to_s
62
+ title.presence || model_name.human
63
+ end
64
+
65
+ # Returns a duplicated event object, or throws an exception
66
+ def duplicate
67
+ MentorshipCycle.new(attributes.except('id', 'updated_at', 'created_at', 'token')).tap do |mentorship|
68
+ mentorship.start_at = mentorship.start_at.advance(years: 1) if mentorship.start_at.present?
69
+ mentorship.end_at = mentorship.end_at.advance(years: 1) if mentorship.end_at.present?
70
+ mentorship.registration_start_at = mentorship.registration_start_at.advance(years: 1) if mentorship.registration_start_at.present?
71
+ mentorship.registration_end_at = mentorship.registration_end_at.advance(years: 1) if mentorship.registration_end_at.present?
72
+
73
+ mentorship.title = mentorship.title + ' (Copy)'
74
+
75
+ mentorship.rich_texts.each { |rt| self.send("rich_text_#{rt.name}=", rt.body) }
76
+ end
77
+ end
78
+
79
+ # def available?
80
+ # started? && !ended?
81
+ # end
82
+
83
+ # def unavailable?
84
+ # !available?
85
+ # end
86
+
87
+ # def started?
88
+ # start_at.present? && Time.zone.now >= start_at
89
+ # end
90
+
91
+ # def ended?
92
+ # end_at.present? && end_at < Time.zone.now
93
+ # end
94
+
95
+ # def available_date
96
+ # if start_at && end_at
97
+ # "#{start_at.strftime('%F')} to #{end_at.strftime('%F')}"
98
+ # elsif start_at
99
+ # "#{start_at.strftime('%F')}"
100
+ # end
101
+ # end
102
+
103
+ end
104
+ end
@@ -0,0 +1,5 @@
1
+ module Effective
2
+ class MentorshipGroup < ActiveRecord::Base
3
+ effective_mentorships_group
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Effective
2
+ class MentorshipRegistration < ActiveRecord::Base
3
+ effective_mentorships_registration
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ = tabs do
2
+ = tab(Effective::MentorshipCycle) do
3
+ = render 'admin/mentorship_cycles/form_mentorship_cycle', mentorship_cycle: mentorship_cycle
4
+
5
+ - if mentorship_cycle.persisted?
6
+ - if mentorship_cycle.respond_to?(:logs_datatable)
7
+ = tab 'Logs' do
8
+ = render_inline_datatable(mentorship_cycle.logs_datatable)
@@ -0,0 +1,31 @@
1
+ = effective_form_with(model: [:admin, mentorship_cycle], engine: true) do |f|
2
+ = f.text_field :title,
3
+ hint: "The title of this #{mentorship_cycle_label}. Something like #{Time.zone.now.year} #{mentorships_name_label}"
4
+
5
+ .row
6
+ .col-md-6= f.datetime_field :start_at, label: "#{mentorships_name_label} start"
7
+ .col-md-6= f.datetime_field :end_at, label: "#{mentorships_name_label} end"
8
+
9
+ .row
10
+ .col-md-6
11
+ = f.number_field :max_pairings_mentor,
12
+ label: "Max #{mentorships_mentors_label} per #{mentorship_group_label}",
13
+ hint: "The maximum number of #{mentorships_mentors_label} that will be assigned to a #{mentorship_group_label}. Leave blank for no maximum."
14
+
15
+ = f.number_field :max_pairings_mentee, label: "Max #{mentorships_mentees_label} per #{mentorship_group_label}",
16
+ hint: "The maximum number of #{mentorships_mentees_label} that will be assigned to a #{mentorship_group_label}. Leave blank for no maximum."
17
+
18
+ %hr
19
+
20
+ .row
21
+ .col-md-6
22
+ %h2 Registration Opt-In
23
+ %p The online registration opt-in will be available between:
24
+ = f.datetime_field :registration_start_at, label: "Registration start", hint: "The first day that #{mentorships_mentors_label} and #{mentorships_mentees_label} can register for this #{mentorship_cycle_label}"
25
+ = f.datetime_field :registration_end_at, label: "Registration end", hint: "The last day that #{mentorships_mentors_label} and #{mentorships_mentees_label} can register for this #{mentorship_cycle_label}"
26
+
27
+ = f.submit do
28
+ = f.save 'Save'
29
+ - if f.object.persisted?
30
+ = f.save 'Duplicate', class: 'btn btn-info'
31
+
@@ -0,0 +1 @@
1
+ %h2 #{mentorships_name_label}
@@ -0,0 +1 @@
1
+ If you're not using effective_email_templates each of these views needs to be written.
@@ -0,0 +1,31 @@
1
+ EffectiveMentorships.setup do |config|
2
+ # Layout Settings
3
+ # Configure the Layout per controller, or all at once
4
+ config.layout = {
5
+ mentorships: 'application',
6
+ admin: 'admin'
7
+ }
8
+
9
+ # Mentorship Class Settings
10
+ # Configure the class responsible for the mentorships
11
+ # config.mentorship_group_class_name = 'Effective::MentorshipGroup'
12
+ # config.mentorship_registration_class_name = 'Effective::MentorshipRegistration'
13
+
14
+ # Mailer Settings
15
+ # Please see config/initializers/effective_resources.rb for default effective_* gem mailer settings
16
+ #
17
+ # Configure the class responsible to send e-mails.
18
+ # config.mailer = 'Effective::MentorshipMailer'
19
+ #
20
+ # Override effective_resource mailer defaults
21
+ #
22
+ # config.parent_mailer = nil # The parent class responsible for sending emails
23
+ # config.deliver_method = nil # The deliver method, deliver_later or deliver_now
24
+ # config.mailer_layout = nil # Default mailer layout
25
+ # config.mailer_sender = nil # Default From value
26
+ # config.mailer_froms = nil # Default Froms collection
27
+ # config.mailer_admin = nil # Default To value for Admin correspondence
28
+ # config.mailer_subject = nil # Proc.new method used to customize Subject
29
+ #
30
+ # All mailers work through effective_email_templates
31
+ end
@@ -0,0 +1,15 @@
1
+ en:
2
+ effective_mentorships:
3
+ name: 'Mentorship Program'
4
+ acronym: 'Mentorships'
5
+ mentor: 'Mentor'
6
+ mentee: 'Mentee'
7
+
8
+ activerecord:
9
+ models:
10
+ # Application namespace
11
+ mentorship_group: 'Mentorship Group'
12
+ mentorship_registration: 'Mentorship Registration'
13
+
14
+ # Effective namespace
15
+ effective/mentorship_cycle: 'Mentorship Cycle'
data/config/routes.rb ADDED
@@ -0,0 +1,12 @@
1
+ Rails.application.routes.draw do
2
+ mount EffectiveMentorships::Engine => '/', as: 'effective_mentorships'
3
+ end
4
+
5
+ EffectiveMentorships::Engine.routes.draw do
6
+ scope module: 'effective' do
7
+ end
8
+
9
+ namespace :admin do
10
+ resources :mentorship_cycles, except: [:show]
11
+ end
12
+ end
@@ -0,0 +1,45 @@
1
+ class CreateEffectiveMentorships < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :mentorship_cycles do |t|
4
+ t.string :title
5
+
6
+ t.datetime :start_at
7
+ t.datetime :end_at
8
+
9
+ t.datetime :registration_start_at
10
+ t.datetime :registration_end_at
11
+
12
+ t.integer :max_pairings_mentor
13
+ t.integer :max_pairings_mentee
14
+
15
+ t.integer :mentorship_groups_count, default: 0
16
+ t.integer :mentorship_registrations_count, default: 0
17
+
18
+ t.datetime :updated_at
19
+ t.datetime :created_at
20
+ end
21
+
22
+ create_table :mentorship_groups do |t|
23
+ t.integer :mentorship_cycle_id
24
+ t.integer :user_id
25
+
26
+ t.boolean :archived, default: false
27
+ t.string :token
28
+
29
+ t.datetime :updated_at
30
+ t.datetime :created_at
31
+ end
32
+
33
+ create_table :mentorship_registrations do |t|
34
+ t.integer :mentorship_cycle_id
35
+ t.integer :user_id
36
+
37
+ t.string :mentorship_role
38
+
39
+ t.string :token
40
+
41
+ t.datetime :updated_at
42
+ t.datetime :created_at
43
+ end
44
+ end
45
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,20 @@
1
+ puts "Running effective_mentorships seeds"
2
+
3
+ now = Time.zone.now
4
+
5
+ if Rails.env.test?
6
+ Effective::MentorshipCycle.delete_all
7
+ ActionText::RichText.where(record_type: ['Effective::MentorshipCycle']).delete_all
8
+ end
9
+
10
+ # Build the first MentorshipCycle
11
+ cycle = Effective::MentorshipCycle.create!(
12
+ title: "#{now.year} Mentorship",
13
+ start_at: now.beginning_of_year,
14
+ end_at: now.end_of_year,
15
+ registration_start_at: now.beginning_of_year,
16
+ registration_end_at: now.end_of_year,
17
+ rich_text_all_steps_content: "All Steps Content",
18
+ )
19
+
20
+ puts "All Done"
@@ -0,0 +1,20 @@
1
+ module EffectiveMentorships
2
+ class Engine < ::Rails::Engine
3
+ engine_name 'effective_mentorships'
4
+
5
+ # Set up our default configuration options.
6
+ initializer 'effective_mentorships.defaults', before: :load_config_initializers do |app|
7
+ eval File.read("#{config.root}/config/effective_mentorships.rb")
8
+ end
9
+
10
+ # Include concerns and allow any ActiveRecord object to call it
11
+ initializer 'effective_mentorships.active_record' do |app|
12
+ app.config.to_prepare do
13
+ ActiveRecord::Base.extend(EffectiveMentorshipsUser::Base)
14
+ ActiveRecord::Base.extend(EffectiveMentorshipsGroup::Base)
15
+ ActiveRecord::Base.extend(EffectiveMentorshipsRegistration::Base)
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module EffectiveMentorships
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,47 @@
1
+ require 'effective_resources'
2
+ require 'effective_datatables'
3
+ require 'effective_mentorships/engine'
4
+ require 'effective_mentorships/version'
5
+
6
+ module EffectiveMentorships
7
+
8
+ def self.config_keys
9
+ [
10
+ :mentorship_cycles_table_name, :mentorship_groups_table_name, :mentorship_registrations_table_name,
11
+ :mentorship_group_class_name, :mentorship_registration_class_name,
12
+ :layout,
13
+ :mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_froms, :mailer_admin, :mailer_subject,
14
+ ]
15
+ end
16
+
17
+ include EffectiveGem
18
+
19
+ def self.mailer_class
20
+ mailer&.constantize || Effective::MentorshipsMailer
21
+ end
22
+
23
+ def self.MentorshipGroup
24
+ mentorship_group_class_name&.constantize || Effective::MentorshipGroup
25
+ end
26
+
27
+ def self.MentorshipRegistration
28
+ mentorship_registration_class_name&.constantize || Effective::MentorshipRegistration
29
+ end
30
+
31
+ def self.MentorshipCycle
32
+ Effective::MentorshipCycle
33
+ end
34
+
35
+ def self.current_mentorship_cycle(date: nil)
36
+ date ||= Time.zone.now
37
+ mentorship_cycles = Effective::MentorshipCycle.all.reorder(start_at: :asc).all.where('start_at <= ?', date)
38
+ mentorship_cycles.to_a.last
39
+ end
40
+
41
+ def self.previous_mentorship_cycle(date: nil)
42
+ date ||= Time.zone.now
43
+ mentorship_cycles = Effective::MentorshipCycle.all.reorder(start_at: :asc).all.where('start_at <= ?', date)
44
+ mentorship_cycles.to_a.last(2).first
45
+ end
46
+
47
+ end
@@ -0,0 +1,42 @@
1
+ module EffectiveMentorships
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+
6
+ desc 'Creates an EffectiveMentorships 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_mentorship.rb', 'config/initializers/effective_mentorship.rb'
20
+ end
21
+
22
+ def copy_locale
23
+ template ('../' * 3) + 'config/locales/effective_mentorships.en.yml', 'config/locales/effective_mentorships.en.yml'
24
+ end
25
+
26
+ def create_migration_file
27
+ migration_template ('../' * 3) + 'db/migrate/101_create_effective_mentorships.rb.erb', 'db/migrate/create_effective_mentorships.rb'
28
+ end
29
+
30
+ def copy_mailer_preview
31
+ mailer_preview_path = (Rails.application.config.action_mailer.preview_path rescue nil)
32
+
33
+ if mailer_preview_path.present?
34
+ template 'effective_mentorships_mailer_preview.rb', File.join(mailer_preview_path, 'effective_mentorships_mailer_preview.rb')
35
+ else
36
+ puts "couldn't find action_mailer.preview_path. Skipping effective_mentorships_mailer_preview."
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,4 @@
1
+ # Visit http://localhost:3000/rails/mailers
2
+
3
+ class EffectiveMentorshipsMailerPreview < ActionMailer::Preview
4
+ end
@@ -0,0 +1,8 @@
1
+ namespace :effective_mentorships do
2
+
3
+ # bundle exec rake effective_mentorship:seed
4
+ task seed: :environment do
5
+ load "#{__dir__}/../../db/seeds.rb"
6
+ end
7
+
8
+ end
metadata ADDED
@@ -0,0 +1,257 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: effective_mentorships
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Code and Effect
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-11-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 6.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: effective_bootstrap
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: effective_datatables
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 4.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 4.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: effective_email_templates
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: effective_resources
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: wicked
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sqlite3
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: devise
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: haml-rails
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry-byebug
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: effective_developer
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: effective_roles
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: psych
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "<"
186
+ - !ruby/object:Gem::Version
187
+ version: '4'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "<"
193
+ - !ruby/object:Gem::Version
194
+ version: '4'
195
+ description: Mentorship matching for mentors and mentees rails engine
196
+ email:
197
+ - info@codeandeffect.com
198
+ executables: []
199
+ extensions: []
200
+ extra_rdoc_files: []
201
+ files:
202
+ - MIT-LICENSE
203
+ - README.md
204
+ - Rakefile
205
+ - app/assets/config/effective_mentorships_manifest.js
206
+ - app/assets/javascripts/effective_mentorships.js
207
+ - app/assets/stylesheets/effective_mentorships.scss
208
+ - app/controllers/admin/mentorship_cycles_controller.rb
209
+ - app/controllers/effective/mentorship_cycles_controller.rb
210
+ - app/datatables/admin/effective_mentorship_cycles_datatable.rb
211
+ - app/helpers/effective_mentorships_helper.rb
212
+ - app/mailers/effective/mentorships_mailer.rb
213
+ - app/models/concerns/effective_mentorships_group.rb
214
+ - app/models/concerns/effective_mentorships_registration.rb
215
+ - app/models/concerns/effective_mentorships_user.rb
216
+ - app/models/effective/mentorship_cycle.rb
217
+ - app/models/effective/mentorship_group.rb
218
+ - app/models/effective/mentorship_registration.rb
219
+ - app/views/admin/mentorship_cycles/_form.html.haml
220
+ - app/views/admin/mentorship_cycles/_form_mentorship_cycle.html.haml
221
+ - app/views/effective/mentorships/_dashboard.html.haml
222
+ - app/views/effective/mentorships_mailer/README.md
223
+ - config/effective_mentorships.rb
224
+ - config/locales/effective_mentorships.en.yml
225
+ - config/routes.rb
226
+ - db/migrate/101_create_effective_mentorships.rb
227
+ - db/seeds.rb
228
+ - lib/effective_mentorships.rb
229
+ - lib/effective_mentorships/engine.rb
230
+ - lib/effective_mentorships/version.rb
231
+ - lib/generators/effective_mentorships/install_generator.rb
232
+ - lib/generators/templates/effective_mentorship_mailer_preview.rb
233
+ - lib/tasks/effective_mentorships_tasks.rake
234
+ homepage: https://github.com/code-and-effect/effective_mentorships
235
+ licenses:
236
+ - MIT
237
+ metadata: {}
238
+ post_install_message:
239
+ rdoc_options: []
240
+ require_paths:
241
+ - lib
242
+ required_ruby_version: !ruby/object:Gem::Requirement
243
+ requirements:
244
+ - - ">="
245
+ - !ruby/object:Gem::Version
246
+ version: '0'
247
+ required_rubygems_version: !ruby/object:Gem::Requirement
248
+ requirements:
249
+ - - ">="
250
+ - !ruby/object:Gem::Version
251
+ version: '0'
252
+ requirements: []
253
+ rubygems_version: 3.3.7
254
+ signing_key:
255
+ specification_version: 4
256
+ summary: Mentorship matching for mentors and mentees rails engine
257
+ test_files: []