Project

General

Profile

Patch #13468 » news.patch

C. X., 2013-03-13 18:52

View differences:

news_controller.rb (working copy)
24 24
  before_filter :authorize, :except => [:index]
25 25
  before_filter :find_optional_project, :only => :index
26 26
  accept_rss_auth :index
27
  accept_api_auth :index
27
  accept_api_auth :index, :create
28 28

  
29 29
  helper :watchers
30 30
  helper :attachments
......
67 67
  end
68 68

  
69 69
  def create
70
    Rails.logger.info("PARAMS: #{params.inspect}")
70 71
    @news = News.new(:project => @project, :author => User.current)
71 72
    @news.safe_attributes = params[:news]
72 73
    @news.save_attachments(params[:attachments])
74

  
73 75
    if @news.save
74
      render_attachment_warning_if_needed(@news)
75
      flash[:notice] = l(:notice_successful_create)
76
      redirect_to project_news_index_path(@project)
76
      respond_to do |format|
77
        format.html {
78
          render_attachment_warning_if_needed(@news)
79
          flash[:notice] = l(:notice_successful_create)
80
          redirect_to project_news_index_path(@project)
81
        }
82
        format.api  { render_api_ok }
83
      end
77 84
    else
78
      render :action => 'new'
85
      respond_to do |format|
86
        format.html { render :action => 'new' }
87
        format.api  { render_validation_errors(@news) }
88
      end
79 89
    end
80 90
  end
81 91

  
(1-1/6)