mumuki-domain 8.5.0 → 8.6.0
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.
- checksums.yaml +4 -4
- data/app/models/application_record.rb +6 -0
- data/app/models/concerns/with_notifications.rb +17 -0
- data/app/models/discussion.rb +4 -0
- data/app/models/exam_authorization_request.rb +7 -0
- data/app/models/exam_registration.rb +9 -1
- data/app/models/message.rb +4 -0
- data/app/models/notification.rb +4 -0
- data/app/models/user.rb +1 -4
- data/lib/mumuki/domain/factories.rb +1 -0
- data/lib/mumuki/domain/factories/notification_factory.rb +5 -0
- data/lib/mumuki/domain/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0fc67d5d416345806e5d570dae375114d9bd32e3be5af26485a926c9957d10f2
|
|
4
|
+
data.tar.gz: cb223b383c8f176ac852091b8cf79ed2f496404bc75d1d7dcc3ccfbde70e49f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3a891889e37c9fd9a55c383f2ffe6aa2f9368193bb7550ba34d9253fb8fbab3534be85ac6acc8a162f02907059acc57da14658ee6df7ad19ad93523ee1ef998d
|
|
7
|
+
data.tar.gz: e830934dd132b0bada6f45348249f06d170438c98fbb07528fa1e608397b40945485adeb4a79e732d701371e4196a9fae22c5e4ba68ef983a71dc7ae40236704
|
|
@@ -129,6 +129,12 @@ class ApplicationRecord < ActiveRecord::Base
|
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
+
def self.enum_prefixed_translations_for(selector)
|
|
133
|
+
send(selector.to_s.pluralize).map do |key, _|
|
|
134
|
+
[I18n.t("#{selector}_#{key}", default: key.to_sym), key]
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
132
138
|
private
|
|
133
139
|
|
|
134
140
|
def raise_foreign_key_error!
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module WithNotifications
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
def unread_messages
|
|
5
|
+
messages.where read: false
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def unread_notifications
|
|
9
|
+
# TODO: message and discussion should trigger a notification instead of being one
|
|
10
|
+
all = notifications.where(read: false) + unread_messages + unread_discussions
|
|
11
|
+
all.sort_by(&:created_at).reverse
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def read_notification!(target)
|
|
15
|
+
notifications.find_by(target: target)&.mark_as_read!
|
|
16
|
+
end
|
|
17
|
+
end
|
data/app/models/discussion.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
class ExamAuthorizationRequest < ApplicationRecord
|
|
2
|
+
include TerminalNavigation
|
|
3
|
+
|
|
2
4
|
belongs_to :exam
|
|
3
5
|
belongs_to :user
|
|
4
6
|
belongs_to :organization
|
|
7
|
+
belongs_to :exam_registration
|
|
5
8
|
|
|
6
9
|
enum status: %i(pending approved rejected)
|
|
7
10
|
|
|
@@ -11,6 +14,10 @@ class ExamAuthorizationRequest < ApplicationRecord
|
|
|
11
14
|
exam.authorize! user if approved?
|
|
12
15
|
end
|
|
13
16
|
|
|
17
|
+
def name
|
|
18
|
+
exam_registration.description
|
|
19
|
+
end
|
|
20
|
+
|
|
14
21
|
private
|
|
15
22
|
|
|
16
23
|
def notify_user!
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
class ExamRegistration < ApplicationRecord
|
|
2
2
|
include WithTimedEnablement
|
|
3
|
+
include TerminalNavigation
|
|
3
4
|
|
|
4
5
|
belongs_to :organization
|
|
5
6
|
has_and_belongs_to_many :exams
|
|
6
|
-
has_many :authorization_requests, class_name: 'ExamAuthorizationRequest'
|
|
7
|
+
has_many :authorization_requests, class_name: 'ExamAuthorizationRequest'
|
|
7
8
|
|
|
8
9
|
enum authorization_criterion_type: %i(none passed_exercises), _prefix: :authorization_criterion
|
|
9
10
|
|
|
@@ -11,6 +12,8 @@ class ExamRegistration < ApplicationRecord
|
|
|
11
12
|
|
|
12
13
|
delegate :meets_authorization_criteria?, :process_request!, to: :authorization_criterion
|
|
13
14
|
|
|
15
|
+
alias_attribute :name, :description
|
|
16
|
+
|
|
14
17
|
def authorization_criterion
|
|
15
18
|
@authorization_criterion ||= ExamRegistration::AuthorizationCriterion.parse(authorization_criterion_type, authorization_criterion_value)
|
|
16
19
|
end
|
|
@@ -30,6 +33,11 @@ class ExamRegistration < ApplicationRecord
|
|
|
30
33
|
end
|
|
31
34
|
end
|
|
32
35
|
|
|
36
|
+
def authorization_request_for(user)
|
|
37
|
+
authorization_requests.find_by(user: user) ||
|
|
38
|
+
ExamAuthorizationRequest.new(exam_registration: self, organization: organization)
|
|
39
|
+
end
|
|
40
|
+
|
|
33
41
|
private
|
|
34
42
|
|
|
35
43
|
def notify_user!(user)
|
data/app/models/message.rb
CHANGED
data/app/models/notification.rb
CHANGED
data/app/models/user.rb
CHANGED
|
@@ -3,6 +3,7 @@ class User < ApplicationRecord
|
|
|
3
3
|
include WithProfile,
|
|
4
4
|
WithUserNavigation,
|
|
5
5
|
WithReminders,
|
|
6
|
+
WithNotifications,
|
|
6
7
|
WithDiscussionCreation,
|
|
7
8
|
Awardee,
|
|
8
9
|
Disabling,
|
|
@@ -75,10 +76,6 @@ class User < ApplicationRecord
|
|
|
75
76
|
assignments.where(status: Mumuki::Domain::Status::Submission::Passed.to_i)
|
|
76
77
|
end
|
|
77
78
|
|
|
78
|
-
def unread_messages
|
|
79
|
-
messages.where read: false
|
|
80
|
-
end
|
|
81
|
-
|
|
82
79
|
def visit!(organization)
|
|
83
80
|
update!(last_organization: organization) if organization != last_organization
|
|
84
81
|
end
|
|
@@ -16,6 +16,7 @@ require_relative './factories/lesson_factory'
|
|
|
16
16
|
require_relative './factories/login_settings_factory'
|
|
17
17
|
require_relative './factories/medal_factory'
|
|
18
18
|
require_relative './factories/message_factory'
|
|
19
|
+
require_relative './factories/notification_factory'
|
|
19
20
|
require_relative './factories/organization_factory'
|
|
20
21
|
require_relative './factories/term_factory'
|
|
21
22
|
require_relative './factories/topic_factory'
|
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: 8.
|
|
4
|
+
version: 8.6.0
|
|
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-02-
|
|
11
|
+
date: 2021-02-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -286,6 +286,7 @@ files:
|
|
|
286
286
|
- app/models/concerns/with_medal.rb
|
|
287
287
|
- app/models/concerns/with_messages.rb
|
|
288
288
|
- app/models/concerns/with_name.rb
|
|
289
|
+
- app/models/concerns/with_notifications.rb
|
|
289
290
|
- app/models/concerns/with_number.rb
|
|
290
291
|
- app/models/concerns/with_preferences.rb
|
|
291
292
|
- app/models/concerns/with_profile.rb
|
|
@@ -693,6 +694,7 @@ files:
|
|
|
693
694
|
- lib/mumuki/domain/factories/login_settings_factory.rb
|
|
694
695
|
- lib/mumuki/domain/factories/medal_factory.rb
|
|
695
696
|
- lib/mumuki/domain/factories/message_factory.rb
|
|
697
|
+
- lib/mumuki/domain/factories/notification_factory.rb
|
|
696
698
|
- lib/mumuki/domain/factories/organization_factory.rb
|
|
697
699
|
- lib/mumuki/domain/factories/term_factory.rb
|
|
698
700
|
- lib/mumuki/domain/factories/topic_factory.rb
|