Structure page with json

This commit is contained in:
chris committed 2013-10-23 18:39:35 +08:00
1 parent 6d5f1a2f12
commit a4d1c68299
15 files changed
+470 -144

No files matched your search

+26
View File
@@ -26,6 +26,7 @@ namespace :new_ui do
migrate_ad_images_dates
migrate_ad_banners
save_pages
menu_enabled_for_to_hash
end
# :category_name is optional, depends on the naming of the category model: if no conventional, specify it
@@ -53,6 +54,10 @@ namespace :new_ui do
save_pages
end
task :menu_enabled_for_to_hash => :environment do
menu_enabled_for_to_hash
end
def migrate_categories(args = nil)
if args && args[:app_key] && args[:model_name]
migrate_category(args[:app_key], args[:model_name], args[:category_name])
@@ -244,4 +249,25 @@ namespace :new_ui do
end
end
def menu_enabled_for_to_hash
@db ||= Mongoid.database
collection_item = @db['items']
items = collection_item.find()
items.each do |item|
item['menu_enabled_for'] = \
if item['menu_enabled_for'].present?
VALID_LOCALES.inject({}) do |enable, locale|
enable[locale] = Array(item['menu_enabled_for']).include?(locale)
enable
end
else
VALID_LOCALES.inject({}) do |enable, locale|
enable[locale] = false
enable
end
end
collection_item.save(item)
end
end
end