mercator_legacy_importer 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +674 -0
- data/README.rdoc +6 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/mercator_legacy_importer/application.js +13 -0
- data/app/assets/stylesheets/mercator_legacy_importer/application.css +13 -0
- data/app/controllers/mercator_legacy_importer/application_controller.rb +4 -0
- data/app/helpers/mercator_legacy_importer/application_helper.rb +4 -0
- data/app/models/mercator_legacy_importer/asset.rb +4 -0
- data/app/models/mercator_legacy_importer/attachable.rb +6 -0
- data/app/models/mercator_legacy_importer/category.rb +10 -0
- data/app/models/mercator_legacy_importer/category_translation.rb +8 -0
- data/app/models/mercator_legacy_importer/cms_node.rb +7 -0
- data/app/models/mercator_legacy_importer/cms_node_translation.rb +8 -0
- data/app/models/mercator_legacy_importer/connector.rb +7 -0
- data/app/models/mercator_legacy_importer/content.rb +6 -0
- data/app/models/mercator_legacy_importer/content_item.rb +6 -0
- data/app/models/mercator_legacy_importer/country.rb +4 -0
- data/app/models/mercator_legacy_importer/page_template.rb +8 -0
- data/app/models/mercator_legacy_importer/product.rb +12 -0
- data/app/models/mercator_legacy_importer/product_overview_property.rb +4 -0
- data/app/models/mercator_legacy_importer/product_property.rb +7 -0
- data/app/models/mercator_legacy_importer/product_relation.rb +4 -0
- data/app/models/mercator_legacy_importer/product_supply.rb +4 -0
- data/app/models/mercator_legacy_importer/product_translation.rb +8 -0
- data/app/models/mercator_legacy_importer/property.rb +13 -0
- data/app/models/mercator_legacy_importer/property_translation.rb +8 -0
- data/app/models/mercator_legacy_importer/recommendation.rb +10 -0
- data/app/models/mercator_legacy_importer/recommendation_translation.rb +8 -0
- data/app/models/mercator_legacy_importer/user.rb +4 -0
- data/app/views/layouts/mercator_legacy_importer/application.html.erb +14 -0
- data/config/database.yml +13 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20131202162757_add_legacy_ids.rb +21 -0
- data/db/migrate/20131202164442_products_add_legacy_id.rb +9 -0
- data/db/migrate/20140103154252_add_legacy_id_to_page.rb +9 -0
- data/db/migrate/20140103161205_add_legacy_id_to_page_template.rb +9 -0
- data/db/migrate/20140104094617_add_legacy_id_to_feature.rb +9 -0
- data/db/migrate/20140107090420_add_legacy_id_to_content_elements.rb +9 -0
- data/lib/mercator_legacy_importer/engine.rb +5 -0
- data/lib/mercator_legacy_importer/version.rb +3 -0
- data/lib/mercator_legacy_importer.rb +4 -0
- data/lib/tasks/categories.rb +32 -0
- data/lib/tasks/categorizations.rb +35 -0
- data/lib/tasks/category_images.rake +49 -0
- data/lib/tasks/cms_node_images.rake +91 -0
- data/lib/tasks/content_elements.rake +64 -0
- data/lib/tasks/countries.rake +14 -0
- data/lib/tasks/features.rake +21 -0
- data/lib/tasks/mercator_legacy_importer_tasks.rake +34 -0
- data/lib/tasks/page_template.rake +13 -0
- data/lib/tasks/pages.rake +27 -0
- data/lib/tasks/product_images.rake +26 -0
- data/lib/tasks/product_relations.rake +21 -0
- data/lib/tasks/products.rake +48 -0
- data/lib/tasks/properties.rake +45 -0
- data/lib/tasks/recommendations.rake +28 -0
- data/lib/tasks/remaining_assets.rake +37 -0
- data/lib/tasks/remaining_images.rake +38 -0
- data/lib/tasks/supply_relations.rake +21 -0
- data/lib/tasks/unlinked_content_elements.rake +60 -0
- data/lib/tasks/unlinked_content_items.rake +26 -0
- data/lib/tasks/users.rake +13 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/mercator_legacy_importer_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +201 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
def import_content_elements
|
2
|
+
puts "\n\nContent Elements:"
|
3
|
+
|
4
|
+
@legacy_contents = []
|
5
|
+
|
6
|
+
# Legacy::CmsNode.where(name: "main").each do |legacy_cms_node|
|
7
|
+
# Legacy::CmsNode.where(name: "overview").each do |legacy_cms_node|
|
8
|
+
Legacy::CmsNode.where(name: "slogan").each do |legacy_cms_node|
|
9
|
+
|
10
|
+
page = Page.where(legacy_id: legacy_cms_node.parent_id).first
|
11
|
+
|
12
|
+
legacy_cms_node.connectors.each do |legacy_connector|
|
13
|
+
if legacy_connector.position != 1
|
14
|
+
@used_as = legacy_cms_node.name + legacy_connector.position.to_s
|
15
|
+
else
|
16
|
+
@used_as = legacy_cms_node.name
|
17
|
+
end
|
18
|
+
|
19
|
+
@locale = legacy_connector.locale
|
20
|
+
|
21
|
+
legacy_content = legacy_connector.content
|
22
|
+
|
23
|
+
legacy_id = legacy_cms_node.id
|
24
|
+
|
25
|
+
content_element = ContentElement.find_or_initialize_by(legacy_id: legacy_id)
|
26
|
+
content_element.markup = "html"
|
27
|
+
content_element.name_de = legacy_content.name if @locale == "de"
|
28
|
+
content_element.name_en = legacy_content.name if @locale == "en"
|
29
|
+
|
30
|
+
Legacy::ContentItem.where(content_id: legacy_content.id).each do |legacy_content_item|
|
31
|
+
|
32
|
+
debugger unless ["text", "slogan", "content"].include?(legacy_content_item.key)
|
33
|
+
|
34
|
+
content_element.content_de = legacy_content_item.value if @locale == "de"
|
35
|
+
content_element.content_en = legacy_content_item.value if @locale == "en"
|
36
|
+
legacy_content_item.delete()
|
37
|
+
end
|
38
|
+
|
39
|
+
if content_element.save
|
40
|
+
print "C"
|
41
|
+
else
|
42
|
+
puts "\nFAILURE: ContentElement: " + content_element.errors.first.to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
pcea = PageContentElementAssignment.find_or_initialize_by(used_as: @used_as,
|
46
|
+
page_id: page.id,
|
47
|
+
content_element_id: content_element.id)
|
48
|
+
if pcea.save
|
49
|
+
print "A"
|
50
|
+
else
|
51
|
+
puts "\nFAILURE: PageContentElementAssignment: " + pcea.errors.first.to_s
|
52
|
+
end
|
53
|
+
|
54
|
+
@legacy_contents << legacy_content
|
55
|
+
legacy_connector.delete()
|
56
|
+
end
|
57
|
+
legacy_cms_node.delete()
|
58
|
+
end
|
59
|
+
|
60
|
+
@legacy_contents.each do |legacy_content|
|
61
|
+
legacy_content.delete()
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
def import_countries
|
2
|
+
puts "\n\nCountries:"
|
3
|
+
|
4
|
+
Legacy::Country.all.each do |legacy_country|
|
5
|
+
country = Country.find_or_initialize_by_name_de(legacy_country.country_name)
|
6
|
+
if country.update_attributes(name_en: legacy_country.country_name,
|
7
|
+
code: legacy_country.country_a2,
|
8
|
+
legacy_id: legacy_country.id)
|
9
|
+
print "C"
|
10
|
+
else
|
11
|
+
puts "\nFAILURE: Country: " + country.errors.first.to_s
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
def import_features
|
2
|
+
puts "\n\nFeatures:"
|
3
|
+
|
4
|
+
n=1
|
5
|
+
Legacy::ProductOverviewProperty.all.each do |legacy_product_overview_property|
|
6
|
+
legacy_product = Product.find_by_legacy_id(legacy_product_overview_property.product_id)
|
7
|
+
unless legacy_product
|
8
|
+
puts "\nFAILURE: Product not found: " + legacy_product_overview_property.product_id.to_s
|
9
|
+
next
|
10
|
+
end
|
11
|
+
feature = Feature.create(text_de: legacy_product_overview_property.description,
|
12
|
+
position: ( legacy_product_overview_property.order || n = n + 1 ),
|
13
|
+
product_id: legacy_product.id,
|
14
|
+
legacy_id: legacy_product_overview_property.id)
|
15
|
+
if feature.save
|
16
|
+
print "F"
|
17
|
+
else
|
18
|
+
puts "\nFAILURE: Feature: " + feature.errors.first.to_s
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'faker'
|
3
|
+
require 'require_all'
|
4
|
+
$stdout.sync = true
|
5
|
+
|
6
|
+
namespace :import do
|
7
|
+
# starten als: 'bundle exec rake import:legacy
|
8
|
+
# in Produktivumgebungen: 'bundle exec rake import:legacy RAILS_ENV=production'
|
9
|
+
desc "Import from legacy webshop"
|
10
|
+
task :legacy => :environment do
|
11
|
+
|
12
|
+
require_rel "import"
|
13
|
+
# import_users()
|
14
|
+
# import_countries()
|
15
|
+
# import_categories()
|
16
|
+
# import_products()
|
17
|
+
# import_properties()
|
18
|
+
# import_features()
|
19
|
+
# import_categorizations()
|
20
|
+
# import_product_images()
|
21
|
+
# import_product_relations()
|
22
|
+
# import_supply_relations()
|
23
|
+
# import_recommendations()
|
24
|
+
# import_page_templates()
|
25
|
+
# import_pages()
|
26
|
+
# import_content_elements()
|
27
|
+
# import_category_images()
|
28
|
+
# import_cms_node_images()
|
29
|
+
# import_unlinked_content_items()
|
30
|
+
# import_remaining_images()
|
31
|
+
# import_remaining_assets()
|
32
|
+
puts
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
def import_page_templates
|
2
|
+
puts "\n\nPage Templates:"
|
3
|
+
|
4
|
+
Legacy::PageTemplate.all.each do |legacy_page_template|
|
5
|
+
if page_template = PageTemplate.create(name: legacy_page_template.name,
|
6
|
+
content: legacy_page_template.content,
|
7
|
+
legacy_id: legacy_page_template.id)
|
8
|
+
print "T"
|
9
|
+
else
|
10
|
+
puts "\nFAILURE: PageTemplate: " + page_template.errors.first.to_s
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
def import_pages
|
2
|
+
puts "\n\nPages:"
|
3
|
+
|
4
|
+
Legacy::CmsNode.where(typus: "Page").each do |legacy_cms_node|
|
5
|
+
legacy_cms_node_de = legacy_cms_node.cms_node_translations.german.first
|
6
|
+
legacy_cms_node_en = legacy_cms_node.cms_node_translations.english.first
|
7
|
+
|
8
|
+
page_template = PageTemplate.where(legacy_id: legacy_cms_node.page_template_id).first
|
9
|
+
parent = Page.where(legacy_id: legacy_cms_node.parent_id).first
|
10
|
+
|
11
|
+
status = legacy_cms_node.state
|
12
|
+
status = "published_but_hidden" if legacy_cms_node.hide_from_menu? && legacy_cms_node.state == "published"
|
13
|
+
page = Page.new(title_de: ( legacy_cms_node_de.title.present? ? legacy_cms_node_de.title : legacy_cms_node.name ),
|
14
|
+
title_en: legacy_cms_node_en.title,
|
15
|
+
url: legacy_cms_node.url,
|
16
|
+
position: legacy_cms_node.position,
|
17
|
+
parent_id: ( parent.id if parent ),
|
18
|
+
page_template_id: page_template.id,
|
19
|
+
legacy_id: legacy_cms_node.id)
|
20
|
+
page.state = status
|
21
|
+
if page.save
|
22
|
+
print "P"
|
23
|
+
else
|
24
|
+
puts "\nFAILURE: Page: " + page.errors.first.to_s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
def import_product_images
|
2
|
+
require 'net/http'
|
3
|
+
puts "\n\nProduct Images:"
|
4
|
+
|
5
|
+
Net::HTTP.start("www.iv-shop.at") do |http|
|
6
|
+
Legacy::Product.all.each do |legacy_product|
|
7
|
+
if legacy_product.image_file_name || legacy_product.overview_file_name
|
8
|
+
product = Product.find_by_legacy_id(legacy_product.id)
|
9
|
+
filename = "/system/images/" + legacy_product.id.to_s +
|
10
|
+
"/original/" + legacy_product.image_file_name.presence ||
|
11
|
+
legacy_product.overview_file_name
|
12
|
+
data = StringIO.new(http.get(filename).body)
|
13
|
+
data.class.class_eval { attr_accessor :original_filename }
|
14
|
+
data.original_filename = legacy_product.image_file_name.presence || legacy_product.overview_file_name
|
15
|
+
product.photo = data
|
16
|
+
if product.save
|
17
|
+
print "P"
|
18
|
+
else
|
19
|
+
puts "\nFAILURE: Image: " + product.errors.first.to_s
|
20
|
+
end
|
21
|
+
else
|
22
|
+
print "."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
def import_product_relations
|
2
|
+
puts "\n\nProductRelations:"
|
3
|
+
|
4
|
+
Legacy::ProductRelation.all.each do |legacy_product_relation|
|
5
|
+
if product = Product.find_by(legacy_id: legacy_product_relation.product_id)
|
6
|
+
if related_product = Product.find_by(legacy_id: legacy_product_relation.related_product_id)
|
7
|
+
|
8
|
+
if productrelation = Productrelation.create(product_id: product.id,
|
9
|
+
related_product_id: related_product.id)
|
10
|
+
print "P"
|
11
|
+
else
|
12
|
+
puts "\nFAILURE: Productrelation: " + productrelation.errors.first.to_s
|
13
|
+
end
|
14
|
+
else
|
15
|
+
puts "\n FAIILURE: Product not found"
|
16
|
+
end
|
17
|
+
else
|
18
|
+
puts "\n FAIILURE: RelatedProduct not found"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
def import_products
|
2
|
+
puts "\n\nProducts:"
|
3
|
+
Product.all.each do |product|
|
4
|
+
product.delete
|
5
|
+
end
|
6
|
+
print "Products deleted."
|
7
|
+
|
8
|
+
Legacy::Product.all.each do |legacy_product|
|
9
|
+
legacy_product_de = legacy_product.product_translations.german.first
|
10
|
+
legacy_product_en = legacy_product.product_translations.english.first
|
11
|
+
|
12
|
+
if legacy_product_de && legacy_product_de.title.present?
|
13
|
+
name_de = legacy_product_de.title
|
14
|
+
else
|
15
|
+
name_de = legacy_product.name
|
16
|
+
end
|
17
|
+
|
18
|
+
if legacy_product_de && legacy_product_de.long_description.present?
|
19
|
+
description_de = legacy_product_de.long_description
|
20
|
+
else
|
21
|
+
description_de = "fehlt"
|
22
|
+
end
|
23
|
+
|
24
|
+
if legacy_product_en && legacy_product_en.title.present?
|
25
|
+
name_en = legacy_product_en.title
|
26
|
+
else
|
27
|
+
name_en = legacy_product.name
|
28
|
+
end
|
29
|
+
|
30
|
+
if legacy_product_en && legacy_product_en.long_description.present?
|
31
|
+
description_en = legacy_product_en.long_description
|
32
|
+
else
|
33
|
+
description_en = "missing"
|
34
|
+
end
|
35
|
+
|
36
|
+
product = Product.create(number: legacy_product.article_number,
|
37
|
+
name_de: name_de,
|
38
|
+
name_en: name_en,
|
39
|
+
description_de: description_de,
|
40
|
+
description_en: description_en,
|
41
|
+
legacy_id: legacy_product.id)
|
42
|
+
if product.save
|
43
|
+
print "P"
|
44
|
+
else
|
45
|
+
puts "\nFAILURE: Product: " + product.errors.first.to_s
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
def import_properties
|
2
|
+
# puts "\n\nProperty Groups and Properties:"
|
3
|
+
# Property.all.each do |property|
|
4
|
+
# property.delete
|
5
|
+
# end
|
6
|
+
# print "Properties deleted."
|
7
|
+
# PropertyGroup.all.each do |property_group|
|
8
|
+
# property_group.delete
|
9
|
+
# end
|
10
|
+
# print "Property Groups deleted."
|
11
|
+
|
12
|
+
Legacy::Product.all.each do |legacy_product|
|
13
|
+
product = Product.find_by_legacy_id(legacy_product.id)
|
14
|
+
legacy_product.properties.each do |legacy_property|
|
15
|
+
# next if legacy_property.id < 21050
|
16
|
+
legacy_property_de = legacy_property.property_translations.german.first
|
17
|
+
legacy_property_en = legacy_property.property_translations.english.first
|
18
|
+
|
19
|
+
property_group =
|
20
|
+
PropertyGroup.find_or_initialize_by_name_de_and_product_id(
|
21
|
+
legacy_property_de.group.presence || legacy_property_de.name,
|
22
|
+
product.id)
|
23
|
+
if property_group.update_attributes(name_en: legacy_property_en.group.presence ||
|
24
|
+
legacy_property_en.name,
|
25
|
+
position: 1)
|
26
|
+
print "G"
|
27
|
+
|
28
|
+
property = Property.create(name_de: legacy_property_de.name,
|
29
|
+
property_group_id: property_group.id,
|
30
|
+
name_en: legacy_property_en.name,
|
31
|
+
description_de: legacy_property.presentation_value,
|
32
|
+
description_en: legacy_property.presentation_value,
|
33
|
+
position: 1,
|
34
|
+
legacy_id: legacy_property.id)
|
35
|
+
if property.save
|
36
|
+
print "p"
|
37
|
+
else
|
38
|
+
puts "\nFAILURE: Property: " + property.errors.first.to_s
|
39
|
+
end
|
40
|
+
else
|
41
|
+
puts "\nFAILURE: PropertyGroup: " + property_group.errors.first.to_s
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
def import_recommendations
|
2
|
+
puts "\n\nRecommendations:"
|
3
|
+
|
4
|
+
Legacy::Recommendation.all.each do |legacy_recommendation|
|
5
|
+
legacy_reason_de = legacy_recommendation.recommendation_translations.german.first
|
6
|
+
legacy_reason_en = legacy_recommendation.recommendation_translations.english.first
|
7
|
+
|
8
|
+
next if legacy_recommendation.from_product_id.nil?
|
9
|
+
if product = Product.find_by(legacy_id: legacy_recommendation.from_product_id)
|
10
|
+
next if legacy_recommendation.for_product_id.blank?
|
11
|
+
if recommendation = Product.find_by(number: legacy_recommendation.for_product_id)
|
12
|
+
|
13
|
+
if recommendation = Recommendation.create(product_id: product.id,
|
14
|
+
recommended_product_id: recommendation.id,
|
15
|
+
reason_de: legacy_reason_de.description,
|
16
|
+
reason_en: legacy_reason_en.description)
|
17
|
+
print "R"
|
18
|
+
else
|
19
|
+
puts "\nFAILURE: Recommendation: " + recommendation.errors.first.to_s
|
20
|
+
end
|
21
|
+
else
|
22
|
+
puts "\n FAIILURE: Recommended product not found: " + legacy_recommendation.for_product_id
|
23
|
+
end
|
24
|
+
else
|
25
|
+
puts "\n FAIILURE: Product not found: " + legacy_recommendation.from_product_id.to_s
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
def import_remaining_assets
|
2
|
+
require 'net/http'
|
3
|
+
puts "\n\nCMS Assets:"
|
4
|
+
|
5
|
+
Net::HTTP.start("www.iv-shop.at") do |http|
|
6
|
+
Legacy::Asset.where(data_content_type: "application/pdf").each do |legacy_asset|
|
7
|
+
|
8
|
+
if ContentElement.find_by(name_de: legacy_asset.data_file_name, markup: "html")
|
9
|
+
puts "\nFAILURE: Image exists " + legacy_asset.data_file_name
|
10
|
+
legacy_asset.delete()
|
11
|
+
next
|
12
|
+
end
|
13
|
+
|
14
|
+
content_element = ContentElement.new(name_de: legacy_asset.data_file_name, markup: "html")
|
15
|
+
|
16
|
+
filename = "/system/datas/" + legacy_asset.id.to_s + "/original/" + legacy_asset.data_file_name
|
17
|
+
data = StringIO.new(http.get(filename).body)
|
18
|
+
unless data
|
19
|
+
puts "\nFAILURE: Image not found " + filename
|
20
|
+
next
|
21
|
+
end
|
22
|
+
|
23
|
+
data.class.class_eval { attr_accessor :original_filename }
|
24
|
+
data.original_filename = legacy_asset.data_file_name
|
25
|
+
|
26
|
+
content_element.document = data
|
27
|
+
|
28
|
+
if content_element.save
|
29
|
+
print "C"
|
30
|
+
else
|
31
|
+
puts "\nFAILURE: ContentElement: " + content_element.errors.first.to_s
|
32
|
+
end
|
33
|
+
|
34
|
+
legacy_asset.delete()
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
def import_remaining_images
|
2
|
+
require 'net/http'
|
3
|
+
puts "\n\nCMS Images:"
|
4
|
+
|
5
|
+
Net::HTTP.start("www.iv-shop.at") do |http|
|
6
|
+
Legacy::Content.where(typus: "ImageContent").each do |legacy_content|
|
7
|
+
|
8
|
+
content_element = ContentElement.new(name_de: legacy_content.name, markup: "html")
|
9
|
+
|
10
|
+
legacy_attachable = Legacy::Attachable.where(attachable_type: "Content", attachable_id: legacy_content.id).first
|
11
|
+
unless legacy_attachable
|
12
|
+
puts "\nFAILURE: Attachable not found " + legacy_content.id.to_s
|
13
|
+
next
|
14
|
+
end
|
15
|
+
|
16
|
+
filename = "/system/datas/" + legacy_attachable.asset_id.to_s + "/original/" + legacy_content.name
|
17
|
+
data = StringIO.new(http.get(filename).body)
|
18
|
+
unless data
|
19
|
+
puts "\nFAILURE: Image not found " + filename
|
20
|
+
next
|
21
|
+
end
|
22
|
+
|
23
|
+
data.class.class_eval { attr_accessor :original_filename }
|
24
|
+
data.original_filename = legacy_content.name
|
25
|
+
|
26
|
+
content_element.photo = data
|
27
|
+
|
28
|
+
if content_element.save
|
29
|
+
print "C"
|
30
|
+
else
|
31
|
+
puts "\nFAILURE: ContentElement: " + content_element.errors.first.to_s
|
32
|
+
end
|
33
|
+
|
34
|
+
legacy_content.delete()
|
35
|
+
legacy_attachable.delete()
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
def import_supply_relations
|
2
|
+
puts "\n\nSupplyRelations:"
|
3
|
+
|
4
|
+
Legacy::ProductSupply.all.each do |legacy_product_supply|
|
5
|
+
if product = Product.find_by(legacy_id: legacy_product_supply.product_id)
|
6
|
+
if supply = Product.find_by(legacy_id: legacy_product_supply.supply_id)
|
7
|
+
|
8
|
+
if supplyrelation = Supplyrelation.create(product_id: product.id,
|
9
|
+
supply_id: supply.id)
|
10
|
+
print "S"
|
11
|
+
else
|
12
|
+
puts "\nFAILURE: Supplyrelation: " + supplyrelation.errors.first.to_s
|
13
|
+
end
|
14
|
+
else
|
15
|
+
puts "\n FAIILURE: Product not found"
|
16
|
+
end
|
17
|
+
else
|
18
|
+
puts "\n FAIILURE: Supply not found"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
def import_content_items
|
2
|
+
puts "\n\nUnlinked Content Elements:"
|
3
|
+
|
4
|
+
Legacy::content_itemsCmsNode.where(name: "slogan").each do |legacy_cms_node|
|
5
|
+
|
6
|
+
page = Page.where(legacy_id: legacy_cms_node.parent_id).first
|
7
|
+
|
8
|
+
legacy_cms_node.connectors.each do |legacy_connector|
|
9
|
+
if legacy_connector.position != 1
|
10
|
+
@used_as = legacy_cms_node.name + legacy_connector.position.to_s
|
11
|
+
else
|
12
|
+
@used_as = legacy_cms_node.name
|
13
|
+
end
|
14
|
+
|
15
|
+
@locale = legacy_connector.locale
|
16
|
+
|
17
|
+
legacy_content = legacy_connector.content
|
18
|
+
|
19
|
+
legacy_id = legacy_cms_node.id
|
20
|
+
|
21
|
+
content_element = ContentElement.find_or_initialize_by(legacy_id: legacy_id)
|
22
|
+
content_element.markup = "html"
|
23
|
+
content_element.name_de = legacy_content.name if @locale == "de"
|
24
|
+
content_element.name_en = legacy_content.name if @locale == "en"
|
25
|
+
|
26
|
+
Legacy::ContentItem.where(content_id: legacy_content.id).each do |legacy_content_item|
|
27
|
+
|
28
|
+
debugger unless ["text", "slogan", "content"].include?(legacy_content_item.key)
|
29
|
+
|
30
|
+
content_element.content_de = legacy_content_item.value if @locale == "de"
|
31
|
+
content_element.content_en = legacy_content_item.value if @locale == "en"
|
32
|
+
legacy_content_item.delete()
|
33
|
+
end
|
34
|
+
|
35
|
+
if content_element.save
|
36
|
+
print "C"
|
37
|
+
else
|
38
|
+
puts "\nFAILURE: ContentElement: " + content_element.errors.first.to_s
|
39
|
+
end
|
40
|
+
|
41
|
+
pcea = PageContentElementAssignment.find_or_initialize_by(used_as: @used_as,
|
42
|
+
page_id: page.id,
|
43
|
+
content_element_id: content_element.id)
|
44
|
+
if pcea.save
|
45
|
+
print "A"
|
46
|
+
else
|
47
|
+
puts "\nFAILURE: PageContentElementAssignment: " + pcea.errors.first.to_s
|
48
|
+
end
|
49
|
+
|
50
|
+
@legacy_contents << legacy_content
|
51
|
+
legacy_connector.delete()
|
52
|
+
end
|
53
|
+
legacy_cms_node.delete()
|
54
|
+
end
|
55
|
+
|
56
|
+
@legacy_contents.each do |legacy_content|
|
57
|
+
legacy_content.delete()
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
def import_unlinked_content_items
|
2
|
+
puts "\n\nUnlinked Content Elements:"
|
3
|
+
|
4
|
+
Legacy::ContentItem.where(typ: "text").each do |legacy_content_item|
|
5
|
+
|
6
|
+
content_element = ContentElement.find_or_initialize_by(content_de: legacy_content_item.value)
|
7
|
+
|
8
|
+
if legacy_content_item.content
|
9
|
+
name = legacy_content_item.content.name
|
10
|
+
else
|
11
|
+
name = "unbekannt"
|
12
|
+
end
|
13
|
+
content_element.name_de = name
|
14
|
+
|
15
|
+
content_element.markup = "html"
|
16
|
+
|
17
|
+
if content_element.save
|
18
|
+
print "C"
|
19
|
+
legacy_content_item.content.delete() if legacy_content_item.content
|
20
|
+
legacy_content_item.delete()
|
21
|
+
else
|
22
|
+
puts "\nFAILURE: ContentElement: " + content_element.errors.first.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
def import_users
|
2
|
+
puts "\nUsers:"
|
3
|
+
|
4
|
+
Legacy::User.all.each do |legacy_user|
|
5
|
+
user = User.find_or_initialize_by_name(legacy_user.name)
|
6
|
+
if user.update_attributes(email_address: legacy_user.email,
|
7
|
+
legacy_id: legacy_user.id)
|
8
|
+
print "U"
|
9
|
+
else
|
10
|
+
puts "\nFAILURE: User: " + user.errors.first.to_s
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
6
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/test/dummy/bin/rake
ADDED