mumuki-domain 6.4.3 → 6.5.0
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 +21 -0
- data/app/models/assignment.rb +11 -2
- data/app/models/book.rb +2 -2
- data/app/models/concerns/with_discussions.rb +1 -1
- data/app/models/concerns/with_usages.rb +10 -0
- data/app/models/discussion.rb +1 -1
- data/app/models/exam.rb +1 -1
- data/app/models/guide.rb +1 -1
- data/db/migrate/20190312152901_add_content_fk.rb +9 -0
- data/lib/mumuki/domain/factories/organization_factory.rb +1 -0
- data/lib/mumuki/domain/locales/activerecord.en.yml +8 -0
- data/lib/mumuki/domain/locales/activerecord.es.yml +8 -0
- data/lib/mumuki/domain/locales/activerecord.pt.yml +29 -0
- data/lib/mumuki/domain/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b741c1390b0cbdc4c23449c5a9fe3218796032ad1c42dadaac9275d5d39f128
|
4
|
+
data.tar.gz: c63ff4139ffb2d3edad703fa1ea9d9db5f0b57ecc4d3a849556b59d8e238a07d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f24047fb8f927deb09a72bfbf278bce2647e42216bc2766a2be6130f53725f1ad29b0c9a1268fb913be96a8c9e2f7bf8fe943f6176243e0768e83008198bfd6
|
7
|
+
data.tar.gz: aacc1f68926c6e1758612c949da65c85287c516e6b9e70a1be81f2389d1c4454dd38b35617eba95566331802f9b673f73bedcb76d5e72abf519e9b13d75dcae4
|
@@ -38,6 +38,21 @@ class ApplicationRecord < ActiveRecord::Base
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def destroy!
|
42
|
+
super
|
43
|
+
rescue ActiveRecord::RecordNotDestroyed => e
|
44
|
+
errors[:base].last.try { |it| raise ActiveRecord::RecordNotDestroyed.new it }
|
45
|
+
raise e
|
46
|
+
rescue ActiveRecord::InvalidForeignKey => e
|
47
|
+
raise_foreign_key_error!
|
48
|
+
end
|
49
|
+
|
50
|
+
def delete
|
51
|
+
super
|
52
|
+
rescue ActiveRecord::InvalidForeignKey => e
|
53
|
+
raise_foreign_key_error!
|
54
|
+
end
|
55
|
+
|
41
56
|
def save_and_notify!
|
42
57
|
save!
|
43
58
|
notify!
|
@@ -85,4 +100,10 @@ class ApplicationRecord < ActiveRecord::Base
|
|
85
100
|
attributes += reflections.keys if options[:relations]
|
86
101
|
a_hash.with_indifferent_access.slice(*attributes).except(*options[:except])
|
87
102
|
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def raise_foreign_key_error!
|
107
|
+
raise ActiveRecord::InvalidForeignKey.new "#{model_name} is still referenced"
|
108
|
+
end
|
88
109
|
end
|
data/app/models/assignment.rb
CHANGED
@@ -6,7 +6,11 @@ class Assignment < ApplicationRecord
|
|
6
6
|
|
7
7
|
belongs_to :exercise
|
8
8
|
has_one :guide, through: :exercise
|
9
|
-
has_many :messages,
|
9
|
+
has_many :messages,
|
10
|
+
-> { where.not(submission_id: nil).order(date: :desc) },
|
11
|
+
foreign_key: :submission_id,
|
12
|
+
primary_key: :submission_id,
|
13
|
+
dependent: :destroy
|
10
14
|
|
11
15
|
belongs_to :submitter, class_name: 'User'
|
12
16
|
|
@@ -53,7 +57,12 @@ class Assignment < ApplicationRecord
|
|
53
57
|
end
|
54
58
|
|
55
59
|
def notify_to_accessible_organizations!
|
56
|
-
|
60
|
+
warn "Don't use notify_to_accessible_organizations!. Use notify_to_granted_organizations! instead"
|
61
|
+
notify_to_granted_organizations!
|
62
|
+
end
|
63
|
+
|
64
|
+
def notify_to_granted_organizations!
|
65
|
+
submitter.student_granted_organizations.each do |organization|
|
57
66
|
organization.switch!
|
58
67
|
notify!
|
59
68
|
end
|
data/app/models/book.rb
CHANGED
@@ -2,8 +2,8 @@ class Book < Content
|
|
2
2
|
numbered :chapters
|
3
3
|
aggregate_of :chapters
|
4
4
|
|
5
|
-
has_many :chapters, -> { order(number: :asc) }, dependent: :
|
6
|
-
has_many :complements, dependent: :
|
5
|
+
has_many :chapters, -> { order(number: :asc) }, dependent: :destroy
|
6
|
+
has_many :complements, dependent: :destroy
|
7
7
|
|
8
8
|
has_many :exercises, through: :chapters
|
9
9
|
has_many :discussions, through: :exercises
|
@@ -3,6 +3,7 @@ module WithUsages
|
|
3
3
|
|
4
4
|
included do
|
5
5
|
has_many :usages, as: :item
|
6
|
+
before_destroy :ensure_unused!
|
6
7
|
end
|
7
8
|
|
8
9
|
def usage_in_organization(organization = Organization.current)
|
@@ -13,4 +14,13 @@ module WithUsages
|
|
13
14
|
item = usage_in_organization(organization)
|
14
15
|
item.is_a?(type) ? item : nil
|
15
16
|
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def ensure_unused!
|
21
|
+
if usages.present?
|
22
|
+
errors.add :base, :in_use, organization: usages.first.organization.name
|
23
|
+
throw :abort
|
24
|
+
end
|
25
|
+
end
|
16
26
|
end
|
data/app/models/discussion.rb
CHANGED
@@ -2,7 +2,7 @@ class Discussion < ApplicationRecord
|
|
2
2
|
include WithDiscussionStatus, ParentNavigation, WithScopedQueries, Contextualization
|
3
3
|
|
4
4
|
belongs_to :item, polymorphic: true
|
5
|
-
has_many :messages, -> { order(:created_at) }, dependent: :
|
5
|
+
has_many :messages, -> { order(:created_at) }, dependent: :destroy
|
6
6
|
belongs_to :initiator, class_name: 'User'
|
7
7
|
belongs_to :exercise, foreign_type: :exercise, foreign_key: 'item_id'
|
8
8
|
has_many :subscriptions
|
data/app/models/exam.rb
CHANGED
@@ -7,7 +7,7 @@ class Exam < ApplicationRecord
|
|
7
7
|
belongs_to :guide
|
8
8
|
belongs_to :organization
|
9
9
|
|
10
|
-
has_many :authorizations, class_name: 'ExamAuthorization', dependent: :
|
10
|
+
has_many :authorizations, class_name: 'ExamAuthorization', dependent: :destroy
|
11
11
|
has_many :users, through: :authorizations
|
12
12
|
|
13
13
|
after_destroy { |record| Usage.destroy_usages_for record }
|
data/app/models/guide.rb
CHANGED
@@ -6,7 +6,7 @@ class Guide < Content
|
|
6
6
|
markdown_on :corollary, :sources, :learn_more, :teacher_info
|
7
7
|
|
8
8
|
numbered :exercises
|
9
|
-
has_many :exercises, -> { order(number: :asc) }, dependent:
|
9
|
+
has_many :exercises, -> { order(number: :asc) }, dependent: :destroy
|
10
10
|
|
11
11
|
self.inheritance_column = nil
|
12
12
|
|
@@ -3,6 +3,14 @@ en:
|
|
3
3
|
activerecord:
|
4
4
|
errors:
|
5
5
|
models:
|
6
|
+
guide:
|
7
|
+
attributes:
|
8
|
+
base:
|
9
|
+
in_use: 'Guide is still in use in organization %{organization}'
|
10
|
+
topic:
|
11
|
+
attributes:
|
12
|
+
base:
|
13
|
+
in_use: 'Topic is still in use in organization %{organization}'
|
6
14
|
exercise:
|
7
15
|
attributes:
|
8
16
|
randomizations:
|
@@ -20,6 +20,14 @@ es:
|
|
20
20
|
content: Contenido
|
21
21
|
errors:
|
22
22
|
models:
|
23
|
+
guide:
|
24
|
+
attributes:
|
25
|
+
base:
|
26
|
+
in_use: 'La guía aún están siendo utilizada en la organización %{organization}'
|
27
|
+
topic:
|
28
|
+
attributes:
|
29
|
+
base:
|
30
|
+
in_use: 'El tema aún está siendo utilizado en la organización %{organization}'
|
23
31
|
exercise:
|
24
32
|
attributes:
|
25
33
|
randomizations:
|
@@ -0,0 +1,29 @@
|
|
1
|
+
---
|
2
|
+
pt:
|
3
|
+
activerecord:
|
4
|
+
errors:
|
5
|
+
models:
|
6
|
+
guide:
|
7
|
+
attributes:
|
8
|
+
base:
|
9
|
+
in_use: 'O guia ainda está em uso na organização da %{organization}'
|
10
|
+
topic:
|
11
|
+
attributes:
|
12
|
+
base:
|
13
|
+
in_use: 'O tópico ainda está em uso na organização da %{organization}'
|
14
|
+
exercise:
|
15
|
+
attributes:
|
16
|
+
randomizations:
|
17
|
+
invalid_format: 'o formato é inválido'
|
18
|
+
own_expectations:
|
19
|
+
invalid_format: 'o formato é inválido'
|
20
|
+
assistance_rules:
|
21
|
+
invalid_format: 'o formato é inválido'
|
22
|
+
name:
|
23
|
+
invalid_format: 'must not contain /'
|
24
|
+
base:
|
25
|
+
evaluation_criteria_required: 'Você precisa fornecer testes e/ou expectativas'
|
26
|
+
organization:
|
27
|
+
attributes:
|
28
|
+
base:
|
29
|
+
consistent_public_login: 'Uma organização pública não pode restringir métodos de login'
|
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: 6.
|
4
|
+
version: 6.5.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: 2019-
|
11
|
+
date: 2019-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -534,6 +534,7 @@ files:
|
|
534
534
|
- db/migrate/20181210131824_convert_course_invitation_into_fk.rb
|
535
535
|
- db/migrate/20190123180139_add_sources_section.rb
|
536
536
|
- db/migrate/20190123180147_add_learn_more_section.rb
|
537
|
+
- db/migrate/20190312152901_add_content_fk.rb
|
537
538
|
- lib/mumuki/domain.rb
|
538
539
|
- lib/mumuki/domain/engine.rb
|
539
540
|
- lib/mumuki/domain/evaluation.rb
|
@@ -570,6 +571,7 @@ files:
|
|
570
571
|
- lib/mumuki/domain/file.rb
|
571
572
|
- lib/mumuki/domain/locales/activerecord.en.yml
|
572
573
|
- lib/mumuki/domain/locales/activerecord.es.yml
|
574
|
+
- lib/mumuki/domain/locales/activerecord.pt.yml
|
573
575
|
- lib/mumuki/domain/locales/narrator.en.yml
|
574
576
|
- lib/mumuki/domain/locales/narrator.es.yml
|
575
577
|
- lib/mumuki/domain/locales/narrator.pt.yml
|
@@ -621,7 +623,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
621
623
|
- !ruby/object:Gem::Version
|
622
624
|
version: '0'
|
623
625
|
requirements: []
|
624
|
-
rubygems_version: 3.0.
|
626
|
+
rubygems_version: 3.0.3
|
625
627
|
signing_key:
|
626
628
|
specification_version: 4
|
627
629
|
summary: Mumuki Platform's Domain Model
|