Skip to content

Commit

Permalink
Blog Manage Controller Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cykod committed May 18, 2010
1 parent 699b6fc commit 1884b7c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def post
when 'publish_now' # if we want to publish the article now
@entry.publish_now
when 'post_date'
@entry.publish(params[:entry_update][:published_at].blank? ? Time.now : (params[:entry_update][:published_at]))
@entry.publish(params[:entry][:published_at].blank? ? Time.now : (params[:entry][:published_at]))
end

if @entry.save
Expand All @@ -169,8 +169,6 @@ def post
redirect_to :action => 'index', :path => @blog.id
return
end
raise @entry.errors.full_messages.inspect

end

@categories = @blog.blog_categories
Expand Down
7 changes: 7 additions & 0 deletions vendor/modules/blog/app/models/blog/blog_post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ class Blog::BlogPost < DomainModel
# Add cached content support, but make sure we update the blog cache element

has_content_tags


def validate
if self.status == 'published' && !self.published_at.is_a?(Time)
self.errors.add(:published_at,'is invalid')
end
end

content_node :container_type => :content_node_container_type, :container_field => Proc.new { |post| post.content_node_container_id },
:preview_feature => '/blog/page_feature/blog_post_preview'
Expand Down
5 changes: 4 additions & 1 deletion vendor/modules/blog/app/views/blog/manage/post.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},

updateStatus: function() {
$('entry_update_published_at').disabled = !$('entry_status_post_date').checked;
$('entry_published_at').disabled = !$('entry_status_post_date').checked;
},

selectTags: function() {
Expand Down Expand Up @@ -120,6 +120,9 @@
<label for='entry_status_draft'><input onclick='PostEditor.updateStatus();' id='entry_status_draft' name='update_entry[status]' value='draft' <%= "checked='checked'" if @entry.status == 'draft' %> type='radio'><%= "Draft".t %><br/>
<label for='entry_status_published'><input onclick='PostEditor.updateStatus();' id='entry_status_published' name='update_entry[status]' value='publish_now' <%= "checked='checked'" if @entry.status == 'published' && @entry.published_at && @entry.published_at < Time.now %> type='radio'><%= "Published".t %><br/>
<label for='entry_status_post_date'><input onclick='PostEditor.updateStatus();' id='entry_status_post_date' name='update_entry[status]' value='post_date' type='radio' <%= "checked='checked'" if @entry.status == 'published' && ( !@entry.published_at || @entry.published_at > Time.now ) %> type='radio'><%= "Post Date".t %><br/>
<% if @entry.errors.on(:published_at) %>
<div class='error'>Invalid Date</div>
<% end -%>
<%= f.datetime_field :published_at, :label => '',:unstyled => true, :blank => true, :disabled => !(@entry.status == 'published' && ( !@entry.published_at || @entry.published_at > Time.now ) ) %>
</div>
<div align='center'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
published_at = 1.hour.ago

assert_difference 'Blog::BlogPost.count', 1 do
post 'post', :path => [@blog.id], :entry => {:title => 'New Blog Title', :body => 'New Blog Body'}, :update_entry => {:status => 'post_date'}, :entry_update => {:published_at => published_at}
post 'post', :path => [@blog.id], :entry => {:title => 'New Blog Title', :body => 'New Blog Body', :published_at => published_at}, :update_entry => {:status => 'post_date'}
end

response.should redirect_to(:action => 'index', :path => @blog.id)
Expand Down

0 comments on commit 1884b7c

Please sign in to comment.