Skip to content

Instantly share code, notes, and snippets.

@rafapolo
Created June 2, 2015 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafapolo/8aba2462d0b60fce5fe0 to your computer and use it in GitHub Desktop.
Save rafapolo/8aba2462d0b60fce5fe0 to your computer and use it in GitHub Desktop.
Get body content from django_CMS Page model
def db # connects to old database
Mysql2::Client.new(host: 'localhost', username: 'root', database: 'eti')
end
def select(from)
puts '='*20
exec = "SELECT * from #{from}"
puts exec
puts '='*20
db.query(exec)
end
def get_content_from_page(id)
placeholder = []
select("cms_page_placeholders where page_id=#{id}").each do |row|
placeholder << row['placeholder_id']
end
placeholder.sort!
first = placeholder.first
last = placeholder.last
texts = []
select("cms_cmsplugin where placeholder_id between #{first} and #{last}").each do |row|
texts << row['id']
end
texts.sort!
first = texts.first
last = texts.last
row = select("cmsplugin_text where cmsplugin_ptr_id between #{first} and #{last}").first
row['body']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment