mumuki-domain 6.4.1 → 6.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/book.rb +4 -7
- data/app/models/content.rb +11 -1
- data/app/models/guide.rb +4 -6
- data/app/models/organization.rb +7 -5
- data/app/models/topic.rb +2 -6
- data/lib/mumuki/domain/factories/chapter_factory.rb +2 -1
- data/lib/mumuki/domain/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dc4b25b056ad48da30b2a2008ccd242e8585d0e7d41ecef6157eafb5ef10ad6
|
4
|
+
data.tar.gz: 741c3c4883cd6790f0cbe052282ccd85a54d0990beb58a8d4bc1d02a8397e62e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f11f63a1716512dd667e9a184c2dc34ffaa1f72bb180d5f7a98e7be22e84320c797eef80ed272980274015b33388d02299d3f9a4e63e5d0102013740a3789440
|
7
|
+
data.tar.gz: e44584d34112d824cc584b14a266df1b55be8b40c774f9f482d1f12c6d93e501f3a323ce9b32fac043740c13bcfcbda861d6a720aef0f775de1fa2d80531472f
|
data/app/models/book.rb
CHANGED
@@ -48,6 +48,7 @@ class Book < Content
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def index_usage!(organization)
|
51
|
+
organization.index_usage_of! self, self
|
51
52
|
[chapters, complements].flatten.each { |item| item.index_usage! organization }
|
52
53
|
end
|
53
54
|
|
@@ -57,12 +58,8 @@ class Book < Content
|
|
57
58
|
|
58
59
|
## Forking
|
59
60
|
|
60
|
-
def
|
61
|
-
|
62
|
-
|
63
|
-
dup.complements = complements.map { |complement| complement.guide.fork_to!(organization, syncer).as_complement_of(self) }
|
64
|
-
dup.save!
|
65
|
-
syncer.export! dup
|
66
|
-
end
|
61
|
+
def fork_children_into!(dup, organization, syncer)
|
62
|
+
dup.chapters = chapters.map { |chapter| chapter.topic.fork_to!(organization, syncer, quiet: true).as_chapter_of(dup) }
|
63
|
+
dup.complements = complements.map { |complement| complement.guide.fork_to!(organization, syncer, quiet: true).as_complement_of(dup) }
|
67
64
|
end
|
68
65
|
end
|
data/app/models/content.rb
CHANGED
@@ -12,5 +12,15 @@ class Content < ApplicationRecord
|
|
12
12
|
as_json(only: [:name, :slug, :description, :locale]).symbolize_keys
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
def fork_to!(organization, syncer, quiet: false)
|
16
|
+
rebased_dup(organization).tap do |dup|
|
17
|
+
self.class.find_by(slug: dup.slug).try { |it| return it } if quiet
|
18
|
+
|
19
|
+
dup.validate!
|
20
|
+
fork_children_into! dup, organization, syncer
|
21
|
+
dup.save validate: false
|
16
22
|
|
23
|
+
syncer.export! dup
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/app/models/guide.rb
CHANGED
@@ -111,11 +111,9 @@ class Guide < Content
|
|
111
111
|
usage_in_organization.resettable?
|
112
112
|
end
|
113
113
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
syncer.export! dup
|
119
|
-
end
|
114
|
+
## Forking
|
115
|
+
|
116
|
+
def fork_children_into!(dup, _organization, _syncer)
|
117
|
+
dup.exercises = exercises.map(&:dup)
|
120
118
|
end
|
121
119
|
end
|
data/app/models/organization.rb
CHANGED
@@ -6,6 +6,8 @@ class Organization < ApplicationRecord
|
|
6
6
|
serialize :settings, Mumukit::Platform::Organization::Settings
|
7
7
|
serialize :theme, Mumukit::Platform::Organization::Theme
|
8
8
|
|
9
|
+
markdown_on :description
|
10
|
+
|
9
11
|
validate :ensure_consistent_public_login
|
10
12
|
|
11
13
|
belongs_to :book
|
@@ -133,12 +135,12 @@ class Organization < ApplicationRecord
|
|
133
135
|
# Answers organizations that have the given item
|
134
136
|
# in their paths.
|
135
137
|
#
|
138
|
+
# Warning: unlike `in_path?`, this method does only work with
|
139
|
+
# content - child - items instead of both kind of items - content and content containers.
|
140
|
+
#
|
136
141
|
# See `Organization#in_path?`
|
137
|
-
def in_path(
|
138
|
-
joins(:usages)
|
139
|
-
.select('organizations.*, usages.item_id')
|
140
|
-
.where('usages.item_id = ?', item.id)
|
141
|
-
.distinct()
|
142
|
+
def in_path(content)
|
143
|
+
joins(:usages).where('usages.item': content).distinct
|
142
144
|
end
|
143
145
|
end
|
144
146
|
end
|
data/app/models/topic.rb
CHANGED
@@ -47,12 +47,8 @@ class Topic < Content
|
|
47
47
|
|
48
48
|
## Forking
|
49
49
|
|
50
|
-
def
|
51
|
-
|
52
|
-
dup.lessons = lessons.map { |lesson| lesson.guide.fork_to!(organization, syncer).as_lesson_of(self) }
|
53
|
-
dup.save!
|
54
|
-
syncer.export! dup
|
55
|
-
end
|
50
|
+
def fork_children_into!(dup, organization, syncer)
|
51
|
+
dup.lessons = lessons.map { |lesson| lesson.guide.fork_to!(organization, syncer, quiet: true).as_lesson_of(dup) }
|
56
52
|
end
|
57
53
|
|
58
54
|
private
|
@@ -7,10 +7,11 @@ FactoryBot.define do
|
|
7
7
|
transient do
|
8
8
|
lessons { [] }
|
9
9
|
name { Faker::Lorem.sentence(3) }
|
10
|
+
slug { "mumuki/mumuki-test-topic-#{SecureRandom.uuid}" }
|
10
11
|
end
|
11
12
|
|
12
13
|
after(:build) do |chapter, evaluator|
|
13
|
-
chapter.topic = build(:topic, name: evaluator.name, lessons: evaluator.lessons) unless evaluator.topic
|
14
|
+
chapter.topic = build(:topic, name: evaluator.name, slug: evaluator.slug, lessons: evaluator.lessons) unless evaluator.topic
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
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.
|
4
|
+
version: 6.4.2
|
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-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|