persist the course banner image across content migrations
test plan: 1. enable K5 mode 2. set a wide banner image on a course to a file from the course 3. copy the course 4. the image should follow 5. repeat steps 2-4 using an external URL instead of a course file 6. repeat steps 2-5 only export/import instead of course copy flag=none fixes LS-2881 Change-Id: I7184e8a6d77d5b793fbfe3d2a4582ab5df1b00f9 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/280538 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Ed Schiebel <eschiebel@instructure.com> QA-Review: Ed Schiebel <eschiebel@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
parent
ef7ed59301
commit
14417a91cb
|
@ -496,6 +496,14 @@ module Importers
|
|||
course.image_id = image_att.id
|
||||
course.image_url = nil
|
||||
end
|
||||
if (banner_image_url = settings[:banner_image_url])
|
||||
course.banner_image_url = banner_image_url
|
||||
course.banner_image_id = nil
|
||||
elsif (image_ref = settings[:banner_image_identifier_ref]) &&
|
||||
(image_att = course.attachments.where(migration_id: image_ref).active.first)
|
||||
course.banner_image_id = image_att.id
|
||||
course.banner_image_url = nil
|
||||
end
|
||||
if settings[:lock_all_announcements]
|
||||
Announcement.lock_from_course(course)
|
||||
end
|
||||
|
|
|
@ -163,6 +163,14 @@ module CC
|
|||
end
|
||||
end
|
||||
|
||||
if @course.banner_image_url.present?
|
||||
atts << :banner_image_url
|
||||
elsif @course.banner_image_id.present?
|
||||
if (image_att = @course.attachments.active.where(id: @course.banner_image_id).first)
|
||||
c.banner_image_identifier_ref(create_key(image_att))
|
||||
end
|
||||
end
|
||||
|
||||
@course.disable_setting_defaults do # so that we don't copy defaulted settings
|
||||
atts.uniq.each do |att|
|
||||
c.tag!(att, @course.send(att)) unless @course.send(att).nil? || @course.send(att) == ""
|
||||
|
|
|
@ -64,7 +64,8 @@ module CC::Importer::Canvas
|
|||
turnitin_comments default_view license locale
|
||||
group_weighting_scheme storage_quota grading_standard_identifier_ref
|
||||
overridden_course_visibility root_account_uuid
|
||||
image_url image_identifier_ref course_color alt_name].each do |string_type|
|
||||
image_url image_identifier_ref banner_image_url banner_image_identifier_ref
|
||||
course_color alt_name].each do |string_type|
|
||||
val = get_node_val(doc, string_type)
|
||||
course[string_type] = val unless val.nil?
|
||||
end
|
||||
|
|
|
@ -105,6 +105,8 @@
|
|||
<xs:element name="alt_name" type="xs:string" minOccurs="0"/>
|
||||
<xs:element name="image_url" type="xs:string" minOccurs="0"/>
|
||||
<xs:element name="image_identifier_ref" type="xs:string" minOccurs="0"/>
|
||||
<xs:element name="banner_image_url" type="xs:string" minOccurs="0"/>
|
||||
<xs:element name="banner_image_identifier_ref" type="xs:string" minOccurs="0"/>
|
||||
<xs:element name="default_view" minOccurs="0">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
|
|
|
@ -542,6 +542,28 @@ describe ContentMigration do
|
|||
expect(@copy_to.image_url).to eq example_url
|
||||
end
|
||||
|
||||
it "copies banner images" do
|
||||
att = attachment_model(context: @copy_from, uploaded_data: stub_png_data, filename: "homework.png")
|
||||
@copy_from.banner_image_id = att.id
|
||||
@copy_from.save!
|
||||
|
||||
run_course_copy
|
||||
|
||||
@copy_to.reload
|
||||
new_att = @copy_to.attachments.where(migration_id: mig_id(att)).first
|
||||
expect(@copy_to.banner_image_id.to_i).to eq new_att.id
|
||||
|
||||
example_url = "example.com"
|
||||
@copy_from.banner_image_url = example_url
|
||||
@copy_from.banner_image_id = nil
|
||||
@copy_from.save!
|
||||
|
||||
run_course_copy
|
||||
|
||||
@copy_to.reload
|
||||
expect(@copy_to.banner_image_url).to eq example_url
|
||||
end
|
||||
|
||||
it "converts domains in imported urls if specified in account settings" do
|
||||
account = @copy_to.root_account
|
||||
account.settings[:default_migration_settings] = { domain_substitution_map: { "http://derp.derp" => "https://derp.derp" } }
|
||||
|
|
Loading…
Reference in New Issue