Project

General

Profile

Defect #3615 ยป empty_news_comments_fix.patch

Redmine 0.8.4.devel.2815 - Chris Grieger, 2009-07-15 22:00

View differences:

app/controllers/news_controller.rb (working copy)
24 24
  
25 25
  def index
26 26
    @news_pages, @newss = paginate :news,
27
                                   :per_page => 10,
28
                                   :conditions => (@project ? {:project_id => @project.id} : Project.visible_by(User.current)),
29
                                   :include => [:author, :project],
30
                                   :order => "#{News.table_name}.created_on DESC"    
27
      :per_page => 10,
28
      :conditions => (@project ? {:project_id => @project.id} : Project.visible_by(User.current)),
29
      :include => [:author, :project],
30
      :order => "#{News.table_name}.created_on DESC"
31 31
    respond_to do |format|
32 32
      format.html { render :layout => false if request.xhr? }
33 33
      format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
......
58 58
  end
59 59
  
60 60
  def add_comment
61
    @comment = Comment.new(params[:comment])
62
    @comment.author = User.current
63
    if @news.comments << @comment
64
      flash[:notice] = l(:label_comment_added)
65
      redirect_to :action => 'show', :id => @news
61

  
62

  
63
    if(!params[:comment]['comments'].empty?)
64
      @comment = Comment.new(params[:comment])
65
      @comment.author = User.current
66
      if @news.comments << @comment
67
        flash[:notice] = l(:label_comment_added)
68
        redirect_to :action => 'show', :id => @news
69
      else
70
        render :action => 'show'
71
      end
66 72
    else
67
      render :action => 'show'
73
     
74
    redirect_to :controller => 'news', :action => 'show', :id => @news
68 75
    end
69 76
  end
70 77

  
......
83 90
    render :partial => 'common/preview'
84 91
  end
85 92
  
86
private
93
  private
87 94
  def find_news
88 95
    @news = News.find(params[:id])
89 96
    @project = @news.project
    (1-1/1)