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 c3ece3b7af
commit 56ad1ddd91
1 changed files with 63 additions and 63 deletions

View File

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