Created
June 2, 2015 12:23
-
-
Save rafapolo/8aba2462d0b60fce5fe0 to your computer and use it in GitHub Desktop.
Get body content from django_CMS Page model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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