Skip to content

Commit

Permalink
fixed problem with post states
Browse files Browse the repository at this point in the history
  • Loading branch information
molpe committed Jun 18, 2009
1 parent 244c2ce commit 5ad2aa0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Edge
* New installation template
* Fixed bug in archive listing
* Cascade delete for post when a blog is destroyed
* Fixed bug with post's state handling


0.5.0
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/member/conversatio/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def show
end

def new
@post = @blog.posts.new
@post = @blog.posts.new(:state => :draft)
end

def edit
Expand Down
11 changes: 11 additions & 0 deletions app/helpers/conversatio/posts_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Conversatio
module PostsHelper

def select_post_state_tag(post)
default_state = !post.new_record? && post.current_state == :published ? "publish" : "draft"
options = [[ "draft", "draft" ], [ "published", "publish" ]]
select_tag("state", options_for_select(options.uniq, default_state))
end

end
end
2 changes: 1 addition & 1 deletion app/views/member/conversatio/posts/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<legend><%= I18n.t('tog_conversatio.model.post.metadata')%></legend>
<div class="fields">
<p><label for="post_tag_list"><%= I18n.t('tog_conversatio.model.post.tags')%> <%= I18n.t('tog_conversatio.model.post.tags_explanation')%></label><%= f.text_field :tag_list, :class=>"fieldbox wide" -%></p>
<p><label for="post_state"><%= I18n.t('tog_conversatio.model.post.status')%></label><%= select_tag "state", options_for_select(Post.states, @post.new_record? ? :draft : @post.current_state) -%></p>
<p><label for="post_state"><%= I18n.t('tog_conversatio.model.post.status')%></label><%= select_post_state_tag(@post) -%></p>
<p><label for="update_published_at"><%= check_box_tag "update_published_at", "1", !@post.published_at.nil? %> <%= I18n.t('tog_conversatio.model.post.publish_at')%></label><%= f.datetime_select :published_at -%></p>
</div>
</fieldset>
Expand Down
2 changes: 1 addition & 1 deletion app/views/member/conversatio/posts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<tr<%= cycle(' class="pair"', '') -%>>
<td><%= link_to post.title, edit_member_conversatio_blog_post_path(@blog, post) %></td>
<td><%= post.state %></td>
<td><%= link_to "##{post.all_comments.size}", member_conversatio_blog_post_path(@blog, post) %></td>
<td><%= link_to "##{post.comments.size}", member_conversatio_blog_post_path(@blog, post) %></td>
<td><%= post.creation_date %></td>
</tr>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

Tog::Interface.sections(:member).add "Blogs", "/member/conversatio/blogs"

Tog::Plugins.helpers Conversatio::PostsHelper
Tog::Plugins.helpers Conversatio::BlogsHelper

Tog::Search.sources << "Post"
Expand Down

0 comments on commit 5ad2aa0

Please sign in to comment.