ignore drafts and ignore duplicate titles

This commit is contained in:
Ivan Storck 2011-06-02 16:05:16 -07:00
parent f254bb9216
commit 886b3d8bf9

View File

@ -36,28 +36,36 @@ module Refinery
unless user unless user
begin begin
is_draft = draft? ? "true" : false is_draft = draft? ? "true" : "false"
p "creating post " + title + " Draft status: " + is_draft if !draft?
post = ::BlogPost.create! :title => title, :body => content_formatted, :draft => draft?, p "creating post " + title + " Draft status: " + is_draft
:published_at => post_date, :created_at => post_date, :author => user, post = ::BlogPost.create! :title => title,
:tag_list => tag_list :body => content_formatted,
:draft => draft?,
:published_at => post_date,
:created_at => post_date,
:author => user,
:tag_list => tag_list
::BlogPost.transaction do
categories.each do |category|
post.categories << category.to_refinery
end
comments.each do |comment|
comment = comment.to_refinery
comment.post = post
comment.save
end
end
else
p "Skipping draft post"
end
rescue Exception => e rescue Exception => e
# if it's not an activerecord validation error about duplicate title then raise e # TODO if it's not an activerecord validation error about duplicate title then raise e
p e p e
end end
::BlogPost.transaction do
categories.each do |category|
post.categories << category.to_refinery
end
comments.each do |comment|
comment = comment.to_refinery
comment.post = post
comment.save
end
end
post post
end end
end end