fix date shifting for re-imported items

(also keep track of other imported items as well)

test plan:
* import a canvas export package (such as the one
referenced in the ticket) with assignments and graded
discussions
* import them into a course
* delete the assignments, etc. from the course
* re-import the package, while shifting the dates
* the re-imported (i.e. undeleted) assignments should
 have their dates shifted

fixes #CNVS-13252

Change-Id: I396059cdcf58fe3386f21cc7cffe62ac8951cd05
Reviewed-on: https://gerrit.instructure.com/36743
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
This commit is contained in:
James Williams 2014-06-23 13:12:00 -06:00
parent 10268ebff0
commit 924a4cf832
10 changed files with 11 additions and 11 deletions

View File

@ -39,7 +39,7 @@ module Importers
item ||= AssignmentGroup.find_by_context_id_and_context_type_and_id(context.id, context.class.to_s, hash[:id])
item ||= AssignmentGroup.find_by_context_id_and_context_type_and_migration_id(context.id, context.class.to_s, hash[:migration_id]) if hash[:migration_id]
item ||= context.assignment_groups.new
migration.add_imported_item(item) if migration && item.new_record?
migration.add_imported_item(item) if migration
item.migration_id = hash[:migration_id]
item.workflow_state = 'available' if item.deleted?
item.name = hash[:title]

View File

@ -149,7 +149,7 @@ module Importers
item.send("#{prop}=", hash[prop]) unless hash[prop].nil?
end
migration.add_imported_item(item) if migration && new_record
migration.add_imported_item(item) if migration
item.save_without_broadcasting!
if migration

View File

@ -26,7 +26,7 @@ module Importers
item ||= ContextModule.find_by_context_type_and_context_id_and_id(context.class.to_s, context.id, hash[:id])
item ||= ContextModule.find_by_context_type_and_context_id_and_migration_id(context.class.to_s, context.id, hash[:migration_id]) if hash[:migration_id]
item ||= ContextModule.new(:context => context)
migration.add_imported_item(item) if migration && item.new_record?
migration.add_imported_item(item) if migration
item.name = hash[:title] || hash[:description]
item.migration_id = hash[:migration_id]
if hash[:workflow_state] == 'unpublished'
@ -99,7 +99,7 @@ module Importers
else
existing_item.workflow_state = 'active'
end
migration.add_imported_item(existing_item) if migration && existing_item.new_record?
migration.add_imported_item(existing_item) if migration
existing_item.migration_id = hash[:migration_id]
hash[:indent] = [hash[:indent] || 0, level].max
if hash[:linked_resource_type] =~ /wiki_type|wikipage/i

View File

@ -31,7 +31,7 @@ module Importers
item.header_match = hash[:header_match] unless hash[:header_match].blank?
item.save!
migration.add_imported_item(item) if migration && item.new_record?
migration.add_imported_item(item) if migration
item
end
end

View File

@ -31,7 +31,7 @@ module Importers
end
item.save!
migration.add_imported_item(item) if migration && item.new_record?
migration.add_imported_item(item) if migration
item
end
end

View File

@ -22,7 +22,7 @@ module Importers
item ||= Group.find_by_context_id_and_context_type_and_id(context.id, context.class.to_s, hash[:id])
item ||= Group.find_by_context_id_and_context_type_and_migration_id(context.id, context.class.to_s, hash[:migration_id]) if hash[:migration_id]
item ||= context.groups.new
migration.add_imported_item(item) if migration && item.new_record?
migration.add_imported_item(item) if migration
item.migration_id = hash[:migration_id]
item.name = hash[:title]
item.group_category = hash[:group_category].present? ?

View File

@ -36,7 +36,7 @@ module Importers
root_outcome_group.adopt_outcome_group(item)
end
migration.add_imported_item(item) if migration && item.new_record?
migration.add_imported_item(item) if migration
if hash[:outcomes]
hash[:outcomes].each do |child|

View File

@ -77,7 +77,7 @@ module Importers
item.save!
migration.add_imported_item(item) if migration && item.new_record?
migration.add_imported_item(item) if migration
else
item = outcome
end

View File

@ -60,7 +60,7 @@ module Importers
end
end
migration.add_imported_item(item) if migration && item.new_record?
migration.add_imported_item(item) if migration
item.save!
end

View File

@ -63,7 +63,7 @@ module Importers
end
item.set_as_front_page! if !!hash[:front_page] && context.wiki.has_no_front_page
migration.add_imported_item(item) if migration && item.new_record?
migration.add_imported_item(item) if migration
item.migration_id = hash[:migration_id]
(hash[:contents] || []).each do |sub_item|