Updated Import data without page method

This commit is contained in:
saurabhbhatia 2013-11-22 10:30:45 +08:00 committed by Manson Wang
parent f4e88616c7
commit b7142c884b
1 changed files with 63 additions and 63 deletions

View File

@ -4,8 +4,8 @@ require 'net/http'
require 'open-uri' require 'open-uri'
class Admin::ImportDataController < OrbitBackendController class Admin::ImportDataController < OrbitBackendController
helper Admin::PagePartsHelper # helper Admin::PagePartsHelper
include Admin::FrontendWidgetInterface # include Admin::FrontendWidgetInterface
def get_teacher_data def get_teacher_data
uri = URI("https://localhost:8000/teachers.xml") uri = URI("https://localhost:8000/teachers.xml")
@ -693,72 +693,72 @@ end
end end
end end
def get_page_data # def get_page_data
f = File.open("/home/rwub/orbit-db/ntu_mb/pages/management_pages.xml") # f = File.open("/home/rwub/orbit-db/ntu_mb/pages/management_pages.xml")
page_xml = Nokogiri::XML(f) # page_xml = Nokogiri::XML(f)
#open("http://versatile.management.ntu.edu.tw/publication1/conference/#{ntuseq}.xml")) # #open("http://versatile.management.ntu.edu.tw/publication1/conference/#{ntuseq}.xml"))
@pages = page_xml.xpath("//management-page").map do |cp_node| # @pages = page_xml.xpath("//management-page").map do |cp_node|
{ # {
menu_title: (cp_node>"menu-title").text, # menu_title: (cp_node>"menu-title").text,
content: (cp_node>"content").text # content: (cp_node>"content").text
} # }
end # end
if @pages.present? # if @pages.present?
@i=0 # @i=0
@pages.each do |b| # @pages.each do |b|
get_variables_for_new # get_variables_for_new
@page = Page.new # @page = Page.new
@page.parent = "4f45f3b9e9d02c5db900005d" # @page.parent = "4f45f3b9e9d02c5db900005d"
@page.design = "50ac424983e75219d2000021" # @page.design = "50ac424983e75219d2000021"
@page.theme_id = "50ac424a83e75219d2000025" # @page.theme_id = "50ac424a83e75219d2000025"
@page.menu_enabled_for= ["en", "zh_tw", ""] # @page.menu_enabled_for= ["en", "zh_tw", ""]
@page.enabled_for= ["en", "zh_tw", ""] # @page.enabled_for= ["en", "zh_tw", ""]
@page.is_published = false # @page.is_published = false
if b[:menu_title].blank? # if b[:menu_title].blank?
@page.title = 'No Title Present' # @page.title = 'No Title Present'
@i += 1 # @i += 1
@page.name = "#{@i}Page" # @page.name = "#{@i}Page"
else # else
@i += 1 # @i += 1
@page.title = b[:menu_title] # @page.title = b[:menu_title]
@page.name = "#{@i}Page" # @page.name = "#{@i}Page"
end # end
if b[:content].blank? # if b[:content].blank?
@page.content = "No Content Present" # @page.content = "No Content Present"
else # else
@page.content = b[:content] # @page.content = b[:content]
end # end
@page.save! # @page.save!
end # end
else # else
puts "No Page Data" # puts "No Page Data"
end # end
end # end
def get_variables_for_new # def get_variables_for_new
@designs = Design.all.entries # @designs = Design.all.entries
@themes = Design.first.themes # @themes = Design.first.themes
@module_apps = ModuleApp.for_frontend_select # @module_apps = ModuleApp.for_frontend_select
@app_frontend_urls = nil # @app_frontend_urls = nil
@categories = nil # @categories = nil
@tags = nil # @tags = nil
@page_frontend_data_counts = nil # @page_frontend_data_counts = nil
@frontend_styles = nil # @frontend_styles = nil
@selected={ # @selected={
:design => @designs.first, # :design => @designs.first,
:theme=> @themes.first, # :theme=> @themes.first,
:module_app=>nil,#@module_apps.first # :module_app=>nil,#@module_apps.first
:app_frontend_url=> nil, #@module_apps.first # :app_frontend_url=> nil, #@module_apps.first
:category=>nil, # :category=>nil,
:tag=>nil, # :tag=>nil,
:page_frontend_data_count=>nil, # :page_frontend_data_count=>nil,
:frontend_style => nil # :frontend_style => nil
} # }
end # end
end end