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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2dd0b17031481425109c6fbbf0fef025f7fff815143258f8e1b78ef4c2756910
4
- data.tar.gz: 82c30673baeb89cb25ad7ae603e181bab6ba13f9623b537f51a9c61d84217e55
3
+ metadata.gz: 2dc4b25b056ad48da30b2a2008ccd242e8585d0e7d41ecef6157eafb5ef10ad6
4
+ data.tar.gz: 741c3c4883cd6790f0cbe052282ccd85a54d0990beb58a8d4bc1d02a8397e62e
5
5
  SHA512:
6
- metadata.gz: 5afd2f5a051eb74b7fcee1fc858078125efb6191ea390918a5f246276a25c429f8c48f84dd02c2028a63938c6835b0ca7930f543a122f73ed9e44c01e2ba94b8
7
- data.tar.gz: 1bb1058a95394ae5a0ff3feb5f985e42fc0899305d2a354797debf3f9f15698be6f64a43c941883c1e65ce742cc4b82d1c8017c65a95bb3845455067592f6079
6
+ metadata.gz: f11f63a1716512dd667e9a184c2dc34ffaa1f72bb180d5f7a98e7be22e84320c797eef80ed272980274015b33388d02299d3f9a4e63e5d0102013740a3789440
7
+ data.tar.gz: e44584d34112d824cc584b14a266df1b55be8b40c774f9f482d1f12c6d93e501f3a323ce9b32fac043740c13bcfcbda861d6a720aef0f775de1fa2d80531472f
@@ -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 fork_to!(organization, syncer)
61
- rebased_dup(organization).tap do |dup|
62
- dup.chapters = chapters.map { |chapter| chapter.topic.fork_to!(organization, syncer).as_chapter_of(self) }
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
@@ -12,5 +12,15 @@ class Content < ApplicationRecord
12
12
  as_json(only: [:name, :slug, :description, :locale]).symbolize_keys
13
13
  end
14
14
 
15
- end
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
@@ -111,11 +111,9 @@ class Guide < Content
111
111
  usage_in_organization.resettable?
112
112
  end
113
113
 
114
- def fork_to!(organization, syncer)
115
- rebased_dup(organization).tap do |dup|
116
- dup.exercises = exercises.map(&:dup)
117
- dup.save!
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
@@ -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(item)
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
@@ -47,12 +47,8 @@ class Topic < Content
47
47
 
48
48
  ## Forking
49
49
 
50
- def fork_to!(organization, syncer)
51
- rebased_dup(organization).tap do |dup|
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
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '6.4.1'
3
+ VERSION = '6.4.2'
4
4
  end
5
5
  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.1
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-01-25 00:00:00.000000000 Z
11
+ date: 2019-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails