Skip to content

Commit

Permalink
fix(course duplication): fix logo not duplicated due to carrierwave u…
Browse files Browse the repository at this point in the history
…pgrade
  • Loading branch information
ekowidianto committed Nov 18, 2021
1 parent ff24266 commit 174c92e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion app/models/concerns/course/duplication_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def initialize_duplicate(duplicator, other)
self.title = duplicator.options[:new_title]
self.creator = duplicator.options[:current_user]
self.registration_key = nil
logo.duplicate_from(other.logo) if other.logo_url
material_folders << duplicator.duplicate(other.root_folder)
end

Expand Down
6 changes: 6 additions & 0 deletions app/services/course/duplication/course_duplication_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def duplicate_course(source_course)
raise ActiveRecord::Rollback unless update_course_settings(duplicator, new_course, source_course)
raise ActiveRecord::Rollback unless update_sidebar_settings(duplicator, new_course, source_course)

# As per carrierwave v2.1.0, carrierwave image mounter that retains uploaded file as a cache
# is reset upon reload (in our case it is new_course.reload).
# As a result, logo duplication needs to be done after course reload.
# https://github.com/carrierwaveuploader/carrierwave/issues/2482#issuecomment-762966926
new_course.logo.duplicate_from(source_course.logo) if source_course.logo_url

new_course
end
notify_duplication_complete(duplicated_course)
Expand Down

0 comments on commit 174c92e

Please sign in to comment.