File tree 1 file changed +15
-0
lines changed
lib/concepts/lesson/operations 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,28 @@ def call(lesson:, lesson_params:)
8
8
response [ :lesson ] = lesson
9
9
response [ :lesson ] . assign_attributes ( lesson_params )
10
10
response [ :lesson ] . save!
11
+ if lesson_params [ :name ] . present?
12
+ rename_lesson_project ( lesson : response [ :lesson ] , name : lesson_params [ :name ] )
13
+ rename_lesson_remixes ( lesson : response [ :lesson ] , name : lesson_params [ :name ] )
14
+ end
11
15
response
12
16
rescue StandardError => e
13
17
Sentry . capture_exception ( e )
14
18
errors = response [ :lesson ] . errors . full_messages . join ( ',' )
15
19
response [ :error ] = "Error updating lesson: #{ errors } "
16
20
response
17
21
end
22
+
23
+ def rename_lesson_project ( lesson :, name :)
24
+ lesson . project . update! ( name : name )
25
+ end
26
+
27
+ def rename_lesson_remixes ( lesson :, name :)
28
+ lesson_remixes = Project . where ( remixed_from_id : lesson . project . id )
29
+ lesson_remixes . each do |remix |
30
+ remix . update! ( name : name )
31
+ end
32
+ end
18
33
end
19
34
end
20
35
end
You can’t perform that action at this time.
0 commit comments