mercator_legacy_importer 0.0.1 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +22 -1
  3. data/app/models/mercator_legacy_importer/asset.rb +6 -3
  4. data/app/models/mercator_legacy_importer/attachable.rb +7 -4
  5. data/app/models/mercator_legacy_importer/category.rb +10 -7
  6. data/app/models/mercator_legacy_importer/category_translation.rb +9 -6
  7. data/app/models/mercator_legacy_importer/cms_node.rb +8 -5
  8. data/app/models/mercator_legacy_importer/cms_node_translation.rb +9 -6
  9. data/app/models/mercator_legacy_importer/connector.rb +8 -5
  10. data/app/models/mercator_legacy_importer/content.rb +7 -4
  11. data/app/models/mercator_legacy_importer/content_item.rb +7 -4
  12. data/app/models/mercator_legacy_importer/country.rb +6 -3
  13. data/app/models/mercator_legacy_importer/page_template.rb +9 -6
  14. data/app/models/mercator_legacy_importer/product.rb +12 -9
  15. data/app/models/mercator_legacy_importer/product_overview_property.rb +6 -3
  16. data/app/models/mercator_legacy_importer/product_property.rb +8 -5
  17. data/app/models/mercator_legacy_importer/product_relation.rb +6 -3
  18. data/app/models/mercator_legacy_importer/product_supply.rb +6 -3
  19. data/app/models/mercator_legacy_importer/product_translation.rb +10 -7
  20. data/app/models/mercator_legacy_importer/property.rb +12 -9
  21. data/app/models/mercator_legacy_importer/property_translation.rb +9 -6
  22. data/app/models/mercator_legacy_importer/recommendation.rb +9 -7
  23. data/app/models/mercator_legacy_importer/recommendation_translation.rb +10 -7
  24. data/app/models/mercator_legacy_importer/user.rb +6 -3
  25. data/app/views/layouts/mercator_legacy_importer/application.html.erb +10 -11
  26. data/db/migrate/20131202162757_add_legacy_ids.rb +10 -6
  27. data/lib/mercator_legacy_importer/version.rb +2 -2
  28. data/lib/tasks/categories.rake +43 -0
  29. data/lib/tasks/categorizations.rake +43 -0
  30. data/lib/tasks/category_images.rake +42 -34
  31. data/lib/tasks/cms_node_images.rake +91 -81
  32. data/lib/tasks/content_elements.rake +66 -44
  33. data/lib/tasks/countries.rake +16 -10
  34. data/lib/tasks/features.rake +25 -17
  35. data/lib/tasks/page_template.rake +16 -9
  36. data/lib/tasks/product_images.rake +25 -8
  37. data/lib/tasks/product_relations.rake +21 -13
  38. data/lib/tasks/products.rake +52 -39
  39. data/lib/tasks/properties.rake +45 -36
  40. data/lib/tasks/recommendations.rake +30 -19
  41. data/lib/tasks/remaining_assets.rake +34 -26
  42. data/lib/tasks/remaining_images.rake +34 -26
  43. data/lib/tasks/supply_relations.rake +23 -13
  44. data/lib/tasks/unlinked_content_items.rake +24 -18
  45. data/lib/tasks/users.rake +43 -10
  46. data/lib/tasks/webpages.rake +34 -0
  47. metadata +30 -39
  48. data/app/helpers/mercator_legacy_importer/application_helper.rb +0 -4
  49. data/config/database.yml +0 -13
  50. data/db/migrate/20131202164442_products_add_legacy_id.rb +0 -9
  51. data/db/migrate/20140103154252_add_legacy_id_to_page.rb +0 -9
  52. data/db/migrate/20140103161205_add_legacy_id_to_page_template.rb +0 -9
  53. data/db/migrate/20140104094617_add_legacy_id_to_feature.rb +0 -9
  54. data/db/migrate/20140107090420_add_legacy_id_to_content_elements.rb +0 -9
  55. data/lib/tasks/categories.rb +0 -32
  56. data/lib/tasks/categorizations.rb +0 -35
  57. data/lib/tasks/mercator_legacy_importer_tasks.rake +0 -34
  58. data/lib/tasks/pages.rake +0 -27
  59. data/lib/tasks/unlinked_content_elements.rake +0 -60
@@ -1,4 +0,0 @@
1
- module MercatorLegacyImporter
2
- module ApplicationHelper
3
- end
4
- end
data/config/database.yml DELETED
@@ -1,13 +0,0 @@
1
- import_development:
2
- adapter: mysql2
3
- host: localhost
4
- database: ivellio_vellin_development
5
- username: <%= CONFIG[:legacy_database_user] %>
6
- password: <%= CONFIG[:legacy_database_password] %>
7
-
8
- import_production:
9
- adapter: mysql2
10
- host: localhost
11
- database: ivellio_vellin_production
12
- username: <%= CONFIG[:legacy_database_user] %>
13
- password: <%= CONFIG[:legacy_database_password] %>
@@ -1,9 +0,0 @@
1
- class ProductsAddLegacyId < ActiveRecord::Migration
2
- def self.up
3
- add_column :products, :legacy_id, :integer
4
- end
5
-
6
- def self.down
7
- remove_column :products, :legacy_id
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class AddLegacyIdToPage < ActiveRecord::Migration
2
- def self.up
3
- add_column :pages, :legacy_id, :integer
4
- end
5
-
6
- def self.down
7
- remove_column :pages, :legacy_id
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class AddLegacyIdToPageTemplate < ActiveRecord::Migration
2
- def self.up
3
- add_column :page_templates, :legacy_id, :integer
4
- end
5
-
6
- def self.down
7
- remove_column :page_templates, :legacy_id
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class AddLegacyIdToFeature < ActiveRecord::Migration
2
- def self.up
3
- add_column :features, :legacy_id, :integer
4
- end
5
-
6
- def self.down
7
- remove_column :features, :legacy_id
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class AddLegacyIdToContentElements < ActiveRecord::Migration
2
- def self.up
3
- add_column :content_elements, :legacy_id, :integer
4
- end
5
-
6
- def self.down
7
- remove_column :content_elements, :legacy_id
8
- end
9
- end
@@ -1,32 +0,0 @@
1
- def import_categories
2
- puts "\n\nCategories:"
3
- Category.all.each do |category|
4
- category.delete
5
- end
6
- print "Categories deleted."
7
-
8
- Legacy::Category.all.each do |legacy_category|
9
- legacy_category_de = legacy_category.category_translations.german.first
10
- legacy_category_en = legacy_category.category_translations.english.first
11
-
12
- category = Category.create(name_de: legacy_category_de.title && legacy_category.name)
13
- parent = Category.find_by_legacy_id(legacy_category.parent_id)
14
- if category.update_attributes(name_en: legacy_category_en.title,
15
- description_de: legacy_category_de.short_description,
16
- description_en: legacy_category_en.short_description,
17
- long_description_de: legacy_category_de.long_description,
18
- long_description_en: legacy_category_en.long_description,
19
- position: legacy_category.position,
20
- parent: ( parent if parent ) ,
21
- legacy_id: legacy_category.id)
22
- category.state = "active" if legacy_category.active == true
23
- if category.save
24
- print "C"
25
- else
26
- puts "\nFAILURE: Category " + category.errors.first.to_s
27
- end
28
- else
29
- puts "\nFAILURE: Category " + category.errors.first.to_s
30
- end
31
- end
32
- end
@@ -1,35 +0,0 @@
1
- def import_categorizations
2
- puts "\n\nCategorizations:"
3
- Legacy::Product.all.each do |legacy_product|
4
-
5
- unless product = Product.find_by_legacy_id(legacy_product.id) then
6
- puts "\nFAILURE: Product " + legacy_product.id.to_s + " not found."
7
- next
8
- end
9
-
10
- if legacy_product.article_group && legacy_product.article_group.length == 11
11
- legacy_product.article_group = "00" + legacy_product.article_group[0..3] +
12
- "00" + legacy_product.article_group[4..7] +
13
- "00" + legacy_product.article_group[8..10] +
14
- "-00000-00000"
15
- end
16
-
17
- unless legacy_category = Legacy::Category.find_by_category_product_group(legacy_product.article_group) then
18
- puts "\nFAILURE: Legacy Category " + legacy_product.article_group.to_s + " not found."
19
- next
20
- end
21
-
22
- unless category = Category.find_by_legacy_id(legacy_category.id) then
23
- puts "\nFAILURE: Category " + legacy_category.id.to_s + " not found."
24
- next
25
- end
26
-
27
- categorization = Categorization.find_or_initialize_by_product_id_and_category_id(product.id, category.id)
28
- unless categorization.update_attributes(position: 1) then
29
- puts "\nFAILURE: Categorization " + categorization.errors.first.to_s
30
- next
31
- end
32
-
33
- print "…"
34
- end
35
- end
@@ -1,34 +0,0 @@
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
data/lib/tasks/pages.rake DELETED
@@ -1,27 +0,0 @@
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
@@ -1,60 +0,0 @@
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