Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(course duplication): fix logo not duplicated due to carrierwave upgrade #4179

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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