From 917288c84c85d713ef83ec64c390bb2100888f30 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 27 Jun 2014 15:58:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AF=BE=E7=A8=8B=E8=AE=A8?= =?UTF-8?q?=E8=AE=BA=E5=8C=BA=E3=80=81=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E7=AD=89=E5=88=9B=E5=BB=BA=E6=97=B6BUG=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 3 +++ app/controllers/news_controller.rb | 2 +- app/views/messages/new.html.erb | 6 +++++- app/views/news/_form.html.erb | 2 +- app/views/news/new.html.erb | 20 ++++++++++++++------ 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index c35edfa1..2a408788 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -68,6 +68,9 @@ class MessagesController < ApplicationController call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) render_attachment_warning_if_needed(@message) redirect_to board_message_path(@board, @message) + else + layout_file = @project ? 'base_projects' : 'base_courses' + render :action => 'new', :layout => layout_file end end end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index f91bc401..8bce84f9 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -116,7 +116,7 @@ class NewsController < ApplicationController flash[:notice] = l(:notice_successful_create) redirect_to project_news_index_path(@project) else - layout_file = (@project.project_type == 1) ? 'base_courses' : 'base_projects' + layout_file = @project ? 'base_projects' : 'base_courses' render :action => 'new', :layout => layout_file end elsif @course diff --git a/app/views/messages/new.html.erb b/app/views/messages/new.html.erb index f02af1da..20263423 100644 --- a/app/views/messages/new.html.erb +++ b/app/views/messages/new.html.erb @@ -1,4 +1,8 @@ -

<%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %>

+<% if @project %> +

<%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %>

+<% elsif @course %> +

<%= link_to h(@board.name), :controller => 'boards', :action => 'show', :course_id => @course, :id => @board %> » <%= l(:label_message_new) %>

+<% end %> <%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> diff --git a/app/views/news/_form.html.erb b/app/views/news/_form.html.erb index bfdfeaa3..0601ee25 100644 --- a/app/views/news/_form.html.erb +++ b/app/views/news/_form.html.erb @@ -1,6 +1,6 @@ <%= error_messages_for @news %>
- <% str = (@project.project_type == 1) ? l(:bale_news_notice) : l(:label_news_new) %> + <% str = @project ? l(:bale_news_notice) : l(:label_news_new) %> <%= str %>
diff --git a/app/views/news/new.html.erb b/app/views/news/new.html.erb index feaf7540..68fad17f 100644 --- a/app/views/news/new.html.erb +++ b/app/views/news/new.html.erb @@ -1,9 +1,17 @@ - -<%= labelled_form_for @news, :url => project_news_index_path(@project), - :html => { :id => 'news-form', :multipart => true } do |f| %> - <%= render :partial => 'news/form', :locals => { :f => f } %> - <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> - <%= preview_link preview_news_path(:project_id => @project), 'news-form' ,target='preview',{:class => 'whiteButton m3p10'}%> +<% if @project %> + <%= labelled_form_for @news, :url => project_news_index_path(@project), + :html => {:id => 'news-form', :multipart => true} do |f| %> + <%= render :partial => 'news/form', :locals => {:f => f} %> + <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> + <%= preview_link preview_news_path(:project_id => @project), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %> + <% end %> +<% elsif @course %> + <%= labelled_form_for @news, :url => course_news_index_path(@course), + :html => {:id => 'news-form', :multipart => true} do |f| %> + <%= render :partial => 'news/form', :locals => {:f => f} %> + <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> + <%= preview_link preview_news_path(:course_id => @course), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %> + <% end %> <% end %>