effective_mentorships 0.3.1 → 0.3.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 945b289d8db3d3677c664afe604a39f8def52d09a0aa7d29adebfcd655a6cb89
|
4
|
+
data.tar.gz: 497b103498c79371700c455440edf05a37f04b37bcf9f076f3e222cc13abc10a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a33123dce1938db8df87d14bba03791d4c92ddf3ca9e1446dd70c041016d2c0aba1eafc84357af750e50a65931d15d07b46571204359304a3860a246f0ee588
|
7
|
+
data.tar.gz: fde52709889007242daf8b59ef0789d2a019ba3c2a1a81493d81a663950b99268abca7f3c1e9a8a6b028292c57b4885fecfeda4f5c7e9ec16e72f496e06844e2
|
@@ -29,6 +29,7 @@ module EffectiveMentorshipsUser
|
|
29
29
|
scope :deep_effective_mentorships_user, -> { all }
|
30
30
|
|
31
31
|
scope :mentorships_opted_in, -> (mentorship_cycle) {
|
32
|
+
mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
|
32
33
|
raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
|
33
34
|
|
34
35
|
opted_in = EffectiveMentorships.MentorshipRegistration.opt_in.where(mentorship_cycle: mentorship_cycle)
|
@@ -36,6 +37,7 @@ module EffectiveMentorshipsUser
|
|
36
37
|
}
|
37
38
|
|
38
39
|
scope :mentorships_opted_out, -> (mentorship_cycle) {
|
40
|
+
mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
|
39
41
|
raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
|
40
42
|
|
41
43
|
opted_out = EffectiveMentorships.MentorshipRegistration.opt_out.where(mentorship_cycle: mentorship_cycle)
|
@@ -43,6 +45,7 @@ module EffectiveMentorshipsUser
|
|
43
45
|
}
|
44
46
|
|
45
47
|
scope :mentorships_opted_in_mentors, -> (mentorship_cycle) {
|
48
|
+
mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
|
46
49
|
raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
|
47
50
|
|
48
51
|
opted_in_mentors = EffectiveMentorships.MentorshipRegistration.opt_in.mentors.where(mentorship_cycle: mentorship_cycle)
|
@@ -50,6 +53,7 @@ module EffectiveMentorshipsUser
|
|
50
53
|
}
|
51
54
|
|
52
55
|
scope :mentorships_opted_in_mentees, -> (mentorship_cycle) {
|
56
|
+
mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
|
53
57
|
raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
|
54
58
|
|
55
59
|
opted_in_mentees = EffectiveMentorships.MentorshipRegistration.opt_in.mentees.where(mentorship_cycle: mentorship_cycle)
|
@@ -57,6 +61,7 @@ module EffectiveMentorshipsUser
|
|
57
61
|
}
|
58
62
|
|
59
63
|
scope :mentorships_with_groups, -> (mentorship_cycle) {
|
64
|
+
mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
|
60
65
|
raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
|
61
66
|
|
62
67
|
grouped = Effective::MentorshipGroupUser.where(mentorship_cycle: mentorship_cycle)
|
@@ -64,11 +69,40 @@ module EffectiveMentorshipsUser
|
|
64
69
|
}
|
65
70
|
|
66
71
|
scope :mentorships_without_groups, -> (mentorship_cycle) {
|
72
|
+
mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
|
67
73
|
raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
|
68
74
|
|
69
75
|
grouped = Effective::MentorshipGroupUser.where(mentorship_cycle: mentorship_cycle)
|
70
76
|
where.not(id: grouped.select(:user_id))
|
71
77
|
}
|
78
|
+
|
79
|
+
scope :mentorships_mentors_with_groups, -> (mentorship_cycle) {
|
80
|
+
mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
|
81
|
+
raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
|
82
|
+
|
83
|
+
grouped = Effective::MentorshipGroupUser.mentors.where(mentorship_cycle: mentorship_cycle)
|
84
|
+
where(id: grouped.select(:user_id))
|
85
|
+
}
|
86
|
+
|
87
|
+
scope :mentorships_mentees_with_groups, -> (mentorship_cycle) {
|
88
|
+
mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
|
89
|
+
raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
|
90
|
+
|
91
|
+
grouped = Effective::MentorshipGroupUser.mentees.where(mentorship_cycle: mentorship_cycle)
|
92
|
+
where(id: grouped.select(:user_id))
|
93
|
+
}
|
94
|
+
|
95
|
+
scope :mentorships_participant_in_mentorship_cycle_id, -> (membership_cycle_id) {
|
96
|
+
mentorships_with_groups(membership_cycle_id)
|
97
|
+
}
|
98
|
+
|
99
|
+
scope :mentorships_mentor_in_mentorship_cycle_id, -> (membership_cycle_id) {
|
100
|
+
mentorships_mentors_with_groups(membership_cycle_id)
|
101
|
+
}
|
102
|
+
|
103
|
+
scope :mentorships_mentee_in_mentorship_cycle_id, -> (membership_cycle_id) {
|
104
|
+
mentorships_mentees_with_groups(membership_cycle_id)
|
105
|
+
}
|
72
106
|
end
|
73
107
|
|
74
108
|
# Used for the dashboard datatables. Which cycles can we register for?
|
@@ -25,6 +25,9 @@ module Effective
|
|
25
25
|
scope :deep, -> { includes(:mentorship_cycle, :mentorship_group, :user) }
|
26
26
|
scope :sorted, -> { order(:mentorship_cycle_id).order(:position) }
|
27
27
|
|
28
|
+
scope :mentors, -> { where(mentorship_role: 'mentor') }
|
29
|
+
scope :mentees, -> { where(mentorship_role: 'mentee') }
|
30
|
+
|
28
31
|
# Assign position and cycle
|
29
32
|
before_validation(if: -> { mentorship_group.present? }) do
|
30
33
|
self.position ||= (mentorship_group.mentorship_group_users.map(&:position).compact.max || -1) + 1
|
data/config/routes.rb
CHANGED
@@ -13,7 +13,7 @@ EffectiveMentorships::Engine.routes.draw do
|
|
13
13
|
|
14
14
|
namespace :admin do
|
15
15
|
resources :mentorship_cycles, except: [:show]
|
16
|
-
resources :mentorship_registrations,
|
16
|
+
resources :mentorship_registrations, except: [:show]
|
17
17
|
|
18
18
|
resources :mentorship_bulk_groups, only: [:index, :new, :show, :destroy] do
|
19
19
|
resources :build, controller: :mentorship_bulk_groups, only: [:show, :update]
|