mumuki-domain 9.10.0 → 9.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/application_record.rb +2 -0
- data/app/models/concerns/organization/status/base.rb +22 -0
- data/app/models/concerns/organization/status/disabled.rb +28 -0
- data/app/models/concerns/organization/status/enabled.rb +26 -0
- data/app/models/concerns/organization/status/in_preparation.rb +27 -0
- data/app/models/concerns/with_assignments.rb +6 -0
- data/app/models/concerns/with_discussion_creation/subscription.rb +1 -1
- data/app/models/concerns/with_notifications.rb +1 -1
- data/app/models/concerns/with_organization_status.rb +32 -0
- data/app/models/concerns/with_progress.rb +4 -0
- data/app/models/concerns/with_reminders.rb +1 -2
- data/app/models/discussion.rb +9 -4
- data/app/models/exam_authorization_request.rb +1 -1
- data/app/models/exam_registration/authorization_criterion.rb +7 -3
- data/app/models/exam_registration.rb +5 -2
- data/app/models/message.rb +5 -0
- data/app/models/notification.rb +13 -1
- data/app/models/organization.rb +5 -0
- data/app/models/organization_access_mode/base.rb +53 -0
- data/app/models/organization_access_mode/coming_soon.rb +5 -0
- data/app/models/organization_access_mode/forbidden.rb +22 -0
- data/app/models/organization_access_mode/full.rb +28 -0
- data/app/models/organization_access_mode/gone.rb +5 -0
- data/app/models/organization_access_mode/read_only.rb +41 -0
- data/app/models/organization_access_mode.rb +2 -0
- data/app/models/user.rb +28 -4
- data/db/migrate/20210719145706_add_new_fields_to_notifications.rb +8 -0
- data/db/migrate/20210803175124_add_ignored_notifications_to_users.rb +5 -0
- data/lib/mumuki/domain/helpers/organization.rb +0 -5
- data/lib/mumuki/domain/incognito.rb +16 -0
- data/lib/mumuki/domain/organization/settings.rb +1 -1
- data/lib/mumuki/domain/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d31db11eea83cf47119ccf9d3e59f9664d58fb855d8d07ba28c8a3a82e21f43
|
4
|
+
data.tar.gz: 58a403f7d731986fdcb6226b388a650c990a3ddbb38543a25a1edf6574389076
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4527364cb58249d910cc3d89452638bf4447a0fb538da1291abbd89df0b0621785d473a5e61d25a35bf2278271506ae1e8ced880ab73bd2a9c2fd232def15d7b
|
7
|
+
data.tar.gz: 21077fb1b6576f433ebce3e9d3b24ad6466498454dee37ece7bfa650625cea3ea3ee12e7796ed4e26f4c96beaa44ec7d7c3bf031f837940fea9637b4a5ec25ec
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Organization::Status::Base
|
2
|
+
|
3
|
+
attr_reader :organization
|
4
|
+
|
5
|
+
implements :teacher_access_mode, :student_access_mode, :ex_student_access_mode, :outsider_access_mode, :validate!
|
6
|
+
|
7
|
+
def initialize(organization)
|
8
|
+
@organization = organization
|
9
|
+
end
|
10
|
+
|
11
|
+
def access_mode(user)
|
12
|
+
if user&.teacher_of? organization
|
13
|
+
teacher_access_mode(user)
|
14
|
+
elsif user&.student_of? organization
|
15
|
+
student_access_mode(user)
|
16
|
+
elsif user&.ex_student_of? organization
|
17
|
+
ex_student_access_mode(user)
|
18
|
+
else
|
19
|
+
outsider_access_mode(user)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Organization::Status::Disabled < Organization::Status::Base
|
2
|
+
|
3
|
+
def teacher_access_mode(user)
|
4
|
+
OrganizationAccessMode::Full.new user, organization
|
5
|
+
end
|
6
|
+
|
7
|
+
def student_access_mode(user)
|
8
|
+
OrganizationAccessMode::ReadOnly.new user, organization, :faqs, :profile, :exercises, :discussions
|
9
|
+
end
|
10
|
+
|
11
|
+
def ex_student_access_mode(user)
|
12
|
+
OrganizationAccessMode::ReadOnly.new user, organization, :faqs, :profile
|
13
|
+
end
|
14
|
+
|
15
|
+
def outsider_access_mode(user)
|
16
|
+
if organization.public?
|
17
|
+
OrganizationAccessMode::Gone.new user, organization
|
18
|
+
else
|
19
|
+
OrganizationAccessMode::Forbidden.new user, organization
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate!(user = nil)
|
24
|
+
raise Mumuki::Domain::DisabledOrganizationError unless user
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Organization::Status::Enabled < Organization::Status::Base
|
2
|
+
|
3
|
+
def teacher_access_mode(user)
|
4
|
+
OrganizationAccessMode::Full.new user, organization
|
5
|
+
end
|
6
|
+
|
7
|
+
def student_access_mode(user)
|
8
|
+
OrganizationAccessMode::Full.new user, organization
|
9
|
+
end
|
10
|
+
|
11
|
+
def ex_student_access_mode(user)
|
12
|
+
OrganizationAccessMode::ReadOnly.new user, organization, :faqs, :profile, :discussions, exercises: :submitted
|
13
|
+
end
|
14
|
+
|
15
|
+
def outsider_access_mode(user)
|
16
|
+
if organization.public?
|
17
|
+
OrganizationAccessMode::Full.new user, organization
|
18
|
+
else
|
19
|
+
OrganizationAccessMode::Forbidden.new user, organization
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate!(_user = nil)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Organization::Status::InPreparation < Organization::Status::Base
|
2
|
+
|
3
|
+
def teacher_access_mode(user)
|
4
|
+
OrganizationAccessMode::Full.new user, organization
|
5
|
+
end
|
6
|
+
|
7
|
+
def student_access_mode(user)
|
8
|
+
OrganizationAccessMode::ComingSoon.new user, organization
|
9
|
+
end
|
10
|
+
|
11
|
+
def ex_student_access_mode(user)
|
12
|
+
OrganizationAccessMode::Forbidden.new user, organization
|
13
|
+
end
|
14
|
+
|
15
|
+
def outsider_access_mode(user)
|
16
|
+
if organization.public?
|
17
|
+
OrganizationAccessMode::ComingSoon.new user, organization
|
18
|
+
else
|
19
|
+
OrganizationAccessMode::Forbidden.new user, organization
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate!(user = nil)
|
24
|
+
raise Mumuki::Domain::UnpreparedOrganizationError unless user
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -30,4 +30,10 @@ module WithAssignments
|
|
30
30
|
def assignment_for(user, organization=Organization.current)
|
31
31
|
find_assignment_for(user, organization) || user.build_assignment(self, organization)
|
32
32
|
end
|
33
|
+
|
34
|
+
def has_progress_for?(user, organization)
|
35
|
+
user.present? && find_assignment_for(user, organization).present?
|
36
|
+
end
|
37
|
+
|
38
|
+
|
33
39
|
end
|
@@ -8,7 +8,7 @@ module WithDiscussionCreation::Subscription
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def subscriptions_in_organization
|
11
|
-
subscriptions.
|
11
|
+
subscriptions.where(discussion: Organization.current.discussions)
|
12
12
|
end
|
13
13
|
|
14
14
|
def subscribed_to?(discussion)
|
@@ -7,7 +7,7 @@ module WithNotifications
|
|
7
7
|
|
8
8
|
def unread_notifications
|
9
9
|
# TODO: message and discussion should trigger a notification instead of being one
|
10
|
-
all =
|
10
|
+
all = notifications_in_organization.where(read: false) + unread_messages + unread_discussions
|
11
11
|
all.sort_by(&:created_at).reverse
|
12
12
|
end
|
13
13
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module WithOrganizationStatus
|
2
|
+
|
3
|
+
def status
|
4
|
+
@status ||= _status
|
5
|
+
end
|
6
|
+
|
7
|
+
def access_mode(user)
|
8
|
+
status.access_mode(user)
|
9
|
+
end
|
10
|
+
|
11
|
+
def validate_active!
|
12
|
+
status.validate!
|
13
|
+
end
|
14
|
+
|
15
|
+
def validate_active_for!(user)
|
16
|
+
status.validate!(user)
|
17
|
+
access_mode(user).validate_active!
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def _status
|
23
|
+
if disabled?
|
24
|
+
Organization::Status::Disabled.new self
|
25
|
+
elsif in_preparation?
|
26
|
+
Organization::Status::InPreparation.new self
|
27
|
+
else
|
28
|
+
Organization::Status::Enabled.new self
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -7,6 +7,10 @@ module WithProgress
|
|
7
7
|
progress_for(user, organization).completion_percentage
|
8
8
|
end
|
9
9
|
|
10
|
+
def has_progress_for?(user, organization)
|
11
|
+
progress_for(user, organization).persisted?
|
12
|
+
end
|
13
|
+
|
10
14
|
def dirty_progresses!
|
11
15
|
Indicator.dirty_by_content_change! self
|
12
16
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module WithReminders
|
2
2
|
extend ActiveSupport::Concern
|
3
|
-
include WithPgLock
|
4
3
|
|
5
4
|
def build_reminder
|
6
5
|
mailer = UserMailer.new
|
@@ -10,7 +9,7 @@ module WithReminders
|
|
10
9
|
end
|
11
10
|
|
12
11
|
def remind!
|
13
|
-
build_reminder.
|
12
|
+
build_reminder.post!
|
14
13
|
update! last_reminded_date: Time.current
|
15
14
|
end
|
16
15
|
|
data/app/models/discussion.rb
CHANGED
@@ -21,7 +21,7 @@ class Discussion < ApplicationRecord
|
|
21
21
|
scope :no_responsible_moderator, -> { where('responsible_moderator_at < ?', Time.now - MODERATOR_MAX_RESPONSIBLE_TIME)
|
22
22
|
.or(where(responsible_moderator_at: nil)) }
|
23
23
|
scope :pending_review, -> { where(status: :pending_review) }
|
24
|
-
scope :unread_first, -> {
|
24
|
+
scope :unread_first, -> { includes(:subscriptions).reorder('subscriptions.read', created_at: :desc) }
|
25
25
|
|
26
26
|
after_create :subscribe_initiator!
|
27
27
|
|
@@ -96,15 +96,15 @@ class Discussion < ApplicationRecord
|
|
96
96
|
upvotes.find_by(user: user)
|
97
97
|
end
|
98
98
|
|
99
|
-
def
|
100
|
-
subscriptions.where.not(user: user).
|
99
|
+
def mark_subscriptions_as_unread!(user)
|
100
|
+
subscriptions.where.not(user: user).each(&:unread!)
|
101
101
|
end
|
102
102
|
|
103
103
|
def submit_message!(message, user)
|
104
104
|
message.merge!(sender: user.uid)
|
105
105
|
messages.create(message)
|
106
106
|
user.subscribe_to! self
|
107
|
-
|
107
|
+
mark_subscriptions_as_unread!(user)
|
108
108
|
no_responsible! if responsible?(user)
|
109
109
|
end
|
110
110
|
|
@@ -183,6 +183,11 @@ class Discussion < ApplicationRecord
|
|
183
183
|
klazz.constantize.find(debatable_id)
|
184
184
|
end
|
185
185
|
|
186
|
+
# TODO remove this once discussions generate notifications
|
187
|
+
def subject
|
188
|
+
'discussion'
|
189
|
+
end
|
190
|
+
|
186
191
|
private
|
187
192
|
|
188
193
|
def messages_by_updated_at(direction = :desc)
|
@@ -32,6 +32,6 @@ class ExamAuthorizationRequest < ApplicationRecord
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def notify_user!
|
35
|
-
Notification.
|
35
|
+
Notification.create_and_notify_via_email! organization: organization, user: user, target: self, subject: 'exam_authorization_request_updated' if saved_change_to_status?
|
36
36
|
end
|
37
37
|
end
|
@@ -34,6 +34,10 @@ class ExamRegistration::AuthorizationCriterion
|
|
34
34
|
rescue
|
35
35
|
raise "Invalid criterion type #{type}"
|
36
36
|
end
|
37
|
+
|
38
|
+
def meets_authorization_criteria?(authorization_request)
|
39
|
+
meets_criterion? authorization_request.user, authorization_request.organization
|
40
|
+
end
|
37
41
|
end
|
38
42
|
|
39
43
|
class ExamRegistration::AuthorizationCriterion::None < ExamRegistration::AuthorizationCriterion
|
@@ -45,7 +49,7 @@ class ExamRegistration::AuthorizationCriterion::None < ExamRegistration::Authori
|
|
45
49
|
!value
|
46
50
|
end
|
47
51
|
|
48
|
-
def
|
52
|
+
def meets_criterion?(_user, _organization)
|
49
53
|
true
|
50
54
|
end
|
51
55
|
end
|
@@ -55,7 +59,7 @@ class ExamRegistration::AuthorizationCriterion::PassedExercises < ExamRegistrati
|
|
55
59
|
value.positive?
|
56
60
|
end
|
57
61
|
|
58
|
-
def
|
59
|
-
|
62
|
+
def meets_criterion?(user, organization)
|
63
|
+
user.passed_submissions_count_in(organization) >= value
|
60
64
|
end
|
61
65
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class ExamRegistration < ApplicationRecord
|
2
|
-
include WithPgLock
|
3
2
|
include WithTimedEnablement
|
4
3
|
include TerminalNavigation
|
5
4
|
|
@@ -73,9 +72,13 @@ class ExamRegistration < ApplicationRecord
|
|
73
72
|
registrees.include? user
|
74
73
|
end
|
75
74
|
|
75
|
+
def meets_criterion?(user)
|
76
|
+
authorization_criterion.meets_criterion?(user, organization)
|
77
|
+
end
|
78
|
+
|
76
79
|
private
|
77
80
|
|
78
81
|
def notify_registree!(registree)
|
79
|
-
Notification.
|
82
|
+
Notification.create_and_notify_via_email! organization: organization, user: registree, subject: :exam_registration, target: self
|
80
83
|
end
|
81
84
|
end
|
data/app/models/message.rb
CHANGED
data/app/models/notification.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
class Notification < ApplicationRecord
|
2
2
|
belongs_to :user
|
3
3
|
belongs_to :organization
|
4
|
-
belongs_to :target, polymorphic: true
|
4
|
+
belongs_to :target, polymorphic: true, optional: true
|
5
5
|
|
6
|
+
enum subject: %i(
|
7
|
+
custom
|
8
|
+
exam_authorization_request_updated
|
9
|
+
exam_registration)
|
6
10
|
|
7
11
|
scope :notified_users_ids_for, ->(target, organization=Organization.current) do
|
8
12
|
where(target: target, organization: organization).pluck(:user_id)
|
@@ -11,4 +15,12 @@ class Notification < ApplicationRecord
|
|
11
15
|
def mark_as_read!
|
12
16
|
update read: true
|
13
17
|
end
|
18
|
+
|
19
|
+
def self.create_and_notify_via_email!(args)
|
20
|
+
create!(args).tap(&:notify_via_email!)
|
21
|
+
end
|
22
|
+
|
23
|
+
def notify_via_email!
|
24
|
+
user.notify_via_email! self
|
25
|
+
end
|
14
26
|
end
|
data/app/models/organization.rb
CHANGED
@@ -6,6 +6,7 @@ class Organization < ApplicationRecord
|
|
6
6
|
include Mumukit::Login::OrganizationHelpers
|
7
7
|
|
8
8
|
include WithTargetAudience
|
9
|
+
include WithOrganizationStatus
|
9
10
|
|
10
11
|
serialize :profile, Mumuki::Domain::Organization::Profile
|
11
12
|
serialize :settings, Mumuki::Domain::Organization::Settings
|
@@ -148,6 +149,10 @@ class Organization < ApplicationRecord
|
|
148
149
|
[default_date, in_preparation_until&.to_date].compact.max
|
149
150
|
end
|
150
151
|
|
152
|
+
def discussions
|
153
|
+
book.discussions_in_organization(self)
|
154
|
+
end
|
155
|
+
|
151
156
|
# ==============
|
152
157
|
# Display fields
|
153
158
|
# ==============
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class OrganizationAccessMode::Base
|
2
|
+
attr_reader :user, :organization
|
3
|
+
|
4
|
+
def initialize(user, organization)
|
5
|
+
@user = user
|
6
|
+
@organization = organization
|
7
|
+
end
|
8
|
+
|
9
|
+
def validate_active!
|
10
|
+
end
|
11
|
+
|
12
|
+
def faqs_here?
|
13
|
+
organization.faqs.present?
|
14
|
+
end
|
15
|
+
|
16
|
+
def submit_solutions_here?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
def resolve_discussions_here?
|
21
|
+
false
|
22
|
+
end
|
23
|
+
|
24
|
+
def discuss_here?
|
25
|
+
organization.forum_enabled? && user.discusser_of?(organization) &&
|
26
|
+
user.trusted_as_discusser_in?(organization) && !user.banned_from_forum?
|
27
|
+
end
|
28
|
+
|
29
|
+
def show_discussion_element?
|
30
|
+
false
|
31
|
+
end
|
32
|
+
|
33
|
+
def show_content_element?
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
def restore_indicators?(_content)
|
38
|
+
false
|
39
|
+
end
|
40
|
+
|
41
|
+
def read_only?
|
42
|
+
false
|
43
|
+
end
|
44
|
+
|
45
|
+
def validate_discuss_here!(_discussion)
|
46
|
+
raise Mumuki::Domain::ForbiddenError
|
47
|
+
end
|
48
|
+
|
49
|
+
def validate_content_here!(content)
|
50
|
+
raise Mumuki::Domain::ForbiddenError unless show_content?(content)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class OrganizationAccessMode::Forbidden < OrganizationAccessMode::Base
|
2
|
+
def validate_active!
|
3
|
+
raise Mumuki::Domain::ForbiddenError if organization.private? && user.present?
|
4
|
+
end
|
5
|
+
|
6
|
+
def faqs_here?
|
7
|
+
false
|
8
|
+
end
|
9
|
+
|
10
|
+
def profile_here?
|
11
|
+
false
|
12
|
+
end
|
13
|
+
|
14
|
+
def discuss_here?
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
def show_content?(_content)
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class OrganizationAccessMode::Full < OrganizationAccessMode::Base
|
2
|
+
def profile_here?
|
3
|
+
true
|
4
|
+
end
|
5
|
+
|
6
|
+
def submit_solutions_here?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
def show_discussion_element?
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def resolve_discussions_here?
|
15
|
+
discuss_here?
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate_discuss_here!(_discussion)
|
19
|
+
end
|
20
|
+
|
21
|
+
def show_content?(_content)
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def show_content_element?
|
26
|
+
true
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class OrganizationAccessMode::ReadOnly < OrganizationAccessMode::Base
|
2
|
+
def initialize(user, organization, *global_scopes, **specific_scopes)
|
3
|
+
super user, organization
|
4
|
+
@scopes = global_scopes.map { |scope| [scope, :all] }.to_h.merge specific_scopes
|
5
|
+
end
|
6
|
+
|
7
|
+
def faqs_here?
|
8
|
+
has_scope(:faqs) && super
|
9
|
+
end
|
10
|
+
|
11
|
+
def profile_here?
|
12
|
+
has_scope(:profile)
|
13
|
+
end
|
14
|
+
|
15
|
+
def discuss_here?
|
16
|
+
has_scope(:discussions) && super
|
17
|
+
end
|
18
|
+
|
19
|
+
def validate_discuss_here!(discussion)
|
20
|
+
super(discussion) unless discussion&.initiator == user
|
21
|
+
end
|
22
|
+
|
23
|
+
def show_content?(content)
|
24
|
+
has_scope(:exercises) ||
|
25
|
+
(has_scope(:exercises, :submitted) && content.has_progress_for?(user, organization))
|
26
|
+
end
|
27
|
+
|
28
|
+
def restore_indicators?(book)
|
29
|
+
!book.has_progress_for?(user, organization) && user.has_assignments_in_organization?(organization)
|
30
|
+
end
|
31
|
+
|
32
|
+
def read_only?
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def has_scope(key, value = :all)
|
39
|
+
@scopes[key] == value
|
40
|
+
end
|
41
|
+
end
|
data/app/models/user.rb
CHANGED
@@ -13,7 +13,7 @@ class User < ApplicationRecord
|
|
13
13
|
Mumuki::Domain::Helpers::User
|
14
14
|
|
15
15
|
serialize :permissions, Mumukit::Auth::Permissions
|
16
|
-
|
16
|
+
serialize :ignored_notifications, Array
|
17
17
|
|
18
18
|
has_many :notifications
|
19
19
|
has_many :assignments, foreign_key: :submitter_id
|
@@ -54,6 +54,8 @@ class User < ApplicationRecord
|
|
54
54
|
resource_fields :uid, :social_id, :email, :permissions, :verified_first_name, :verified_last_name, *profile_fields
|
55
55
|
with_temporary_token :delete_account_token
|
56
56
|
|
57
|
+
organic_on :notifications, :assignments
|
58
|
+
|
57
59
|
def last_lesson
|
58
60
|
last_guide.try(:lesson)
|
59
61
|
end
|
@@ -105,6 +107,16 @@ class User < ApplicationRecord
|
|
105
107
|
end
|
106
108
|
end
|
107
109
|
|
110
|
+
def restore_organization_progress!(organization)
|
111
|
+
assignments_in_organization(organization).each do |assignment|
|
112
|
+
assignment.tap(&:parent).save!
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def has_assignments_in_organization?(organization)
|
117
|
+
assignments_in_organization(organization).exists?
|
118
|
+
end
|
119
|
+
|
108
120
|
def accept_invitation!(invitation)
|
109
121
|
make_student_of! invitation.course_slug
|
110
122
|
end
|
@@ -195,7 +207,7 @@ class User < ApplicationRecord
|
|
195
207
|
# This is true only when this organization has the forum enabled and the user
|
196
208
|
# has the discusser pseudo-permission and the discusser is trusted
|
197
209
|
def can_discuss_in?(organization)
|
198
|
-
organization.
|
210
|
+
organization.access_mode(self).discuss_here?
|
199
211
|
end
|
200
212
|
|
201
213
|
def trusted_as_discusser_in?(organization)
|
@@ -277,6 +289,10 @@ class User < ApplicationRecord
|
|
277
289
|
}
|
278
290
|
end
|
279
291
|
|
292
|
+
def solved_any_exercises?(organization = Organization.current)
|
293
|
+
Assignment.exists?(organization: organization, submitter: self)
|
294
|
+
end
|
295
|
+
|
280
296
|
def save_and_notify!
|
281
297
|
save!
|
282
298
|
notify_permissions_changed!
|
@@ -300,7 +316,7 @@ class User < ApplicationRecord
|
|
300
316
|
def certificate_in(certificate_program, certificate_h)
|
301
317
|
return if certificated_in?(certificate_program)
|
302
318
|
certificate = certificates.create certificate_h.merge(certificate_program: certificate_program)
|
303
|
-
UserMailer.certificate(certificate).
|
319
|
+
UserMailer.certificate(certificate).post!
|
304
320
|
end
|
305
321
|
|
306
322
|
def clear_progress_for!(organization)
|
@@ -315,11 +331,19 @@ class User < ApplicationRecord
|
|
315
331
|
user_stats.where(location).delete_all
|
316
332
|
end
|
317
333
|
|
334
|
+
def notify_via_email!(notification)
|
335
|
+
UserMailer.notification(notification).post! unless ignores_notification? notification
|
336
|
+
end
|
337
|
+
|
338
|
+
def ignores_notification?(notification)
|
339
|
+
ignored_notifications.include? notification.subject
|
340
|
+
end
|
341
|
+
|
318
342
|
private
|
319
343
|
|
320
344
|
def welcome_to_new_organizations!
|
321
345
|
new_accessible_organizations.each do |organization|
|
322
|
-
UserMailer.welcome_email(self, organization).
|
346
|
+
UserMailer.welcome_email(self, organization).post! rescue nil if organization.greet_new_users?
|
323
347
|
end
|
324
348
|
end
|
325
349
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class AddNewFieldsToNotifications < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
add_column :notifications, :subject, :integer
|
4
|
+
add_column :notifications, :custom_title, :text
|
5
|
+
add_column :notifications, :custom_content_plain_text, :text
|
6
|
+
add_column :notifications, :custom_content_html, :text
|
7
|
+
end
|
8
|
+
end
|
@@ -52,11 +52,6 @@ module Mumuki::Domain::Helpers::Organization
|
|
52
52
|
Mumukit::Platform.application.organic_domain(name)
|
53
53
|
end
|
54
54
|
|
55
|
-
def validate_active!
|
56
|
-
raise Mumuki::Domain::DisabledOrganizationError if disabled?
|
57
|
-
raise Mumuki::Domain::UnpreparedOrganizationError if in_preparation?
|
58
|
-
end
|
59
|
-
|
60
55
|
## API Exposure
|
61
56
|
|
62
57
|
def to_param
|
@@ -16,6 +16,22 @@ module Mumuki::Domain
|
|
16
16
|
false
|
17
17
|
end
|
18
18
|
|
19
|
+
def ex_student_of?(*)
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
23
|
+
def ex_student_here?
|
24
|
+
false
|
25
|
+
end
|
26
|
+
|
27
|
+
def student_of?(*)
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
def student_here?
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
19
35
|
def teacher_here?
|
20
36
|
false
|
21
37
|
end
|
@@ -28,7 +28,7 @@ class Mumuki::Domain::Organization::Settings < Mumukit::Platform::Model
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def forum_discussions_minimal_role
|
31
|
-
(@forum_discussions_minimal_role || '
|
31
|
+
(@forum_discussions_minimal_role || 'ex_student').to_sym
|
32
32
|
end
|
33
33
|
|
34
34
|
def disabled_from=(disabled_from)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumuki-domain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franco Leonardo Bulgarelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '7.
|
33
|
+
version: '7.11'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '7.
|
40
|
+
version: '7.11'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mumukit-assistant
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.11'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.11'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mumukit-core
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -265,6 +265,10 @@ files:
|
|
265
265
|
- app/models/concerns/navigation/siblings_navigation.rb
|
266
266
|
- app/models/concerns/navigation/terminal_navigation.rb
|
267
267
|
- app/models/concerns/onomastic.rb
|
268
|
+
- app/models/concerns/organization/status/base.rb
|
269
|
+
- app/models/concerns/organization/status/disabled.rb
|
270
|
+
- app/models/concerns/organization/status/enabled.rb
|
271
|
+
- app/models/concerns/organization/status/in_preparation.rb
|
268
272
|
- app/models/concerns/submittable/confirmable.rb
|
269
273
|
- app/models/concerns/submittable/queriable.rb
|
270
274
|
- app/models/concerns/submittable/questionable.rb
|
@@ -292,6 +296,7 @@ files:
|
|
292
296
|
- app/models/concerns/with_name.rb
|
293
297
|
- app/models/concerns/with_notifications.rb
|
294
298
|
- app/models/concerns/with_number.rb
|
299
|
+
- app/models/concerns/with_organization_status.rb
|
295
300
|
- app/models/concerns/with_pg_lock.rb
|
296
301
|
- app/models/concerns/with_preferences.rb
|
297
302
|
- app/models/concerns/with_profile.rb
|
@@ -336,6 +341,13 @@ files:
|
|
336
341
|
- app/models/message.rb
|
337
342
|
- app/models/notification.rb
|
338
343
|
- app/models/organization.rb
|
344
|
+
- app/models/organization_access_mode.rb
|
345
|
+
- app/models/organization_access_mode/base.rb
|
346
|
+
- app/models/organization_access_mode/coming_soon.rb
|
347
|
+
- app/models/organization_access_mode/forbidden.rb
|
348
|
+
- app/models/organization_access_mode/full.rb
|
349
|
+
- app/models/organization_access_mode/gone.rb
|
350
|
+
- app/models/organization_access_mode/read_only.rb
|
339
351
|
- app/models/preferences.rb
|
340
352
|
- app/models/progress.rb
|
341
353
|
- app/models/stats.rb
|
@@ -672,6 +684,8 @@ files:
|
|
672
684
|
- db/migrate/20210512200453_add_processed_flag_to_exam_registration.rb
|
673
685
|
- db/migrate/20210518100153_rename_last_moderator_access.rb
|
674
686
|
- db/migrate/20210707143002_add_assignment_id_to_message.rb
|
687
|
+
- db/migrate/20210719145706_add_new_fields_to_notifications.rb
|
688
|
+
- db/migrate/20210803175124_add_ignored_notifications_to_users.rb
|
675
689
|
- lib/mumuki/domain.rb
|
676
690
|
- lib/mumuki/domain/area.rb
|
677
691
|
- lib/mumuki/domain/engine.rb
|