From b563b170bda4c504483125130be1ad1c98c20004 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 23 Dec 2016 21:13:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E5=8A=A8=E6=80=81=E6=96=B0?= =?UTF-8?q?=E9=97=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/comments_controller.rb | 1 + app/controllers/contests_controller.rb | 2 + app/views/comments/create.js.erb | 2 + app/views/contests/_contest_activity.html.erb | 2 +- .../contests/contest_activities.html.erb | 2 +- app/views/users/_contest_news.html.erb | 77 +++++++++++++++++++ 6 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 app/views/users/_contest_news.html.erb diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 9226b904c..193dbd407 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -28,6 +28,7 @@ class CommentsController < ApplicationController if !@news.org_subfield_id.nil? @org_subfield = OrgSubfield.find(@news.org_subfield_id) end + @contest = Contest.find(@news.contest_id) if @news.contest_id @comment = Comment.new #@project ? @comment.comments = params[:comment][:comments] : @comment.comments = params[:comment] if params[:user_activity_id] diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index dfd7ca7be..5309a75ac 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -37,6 +37,8 @@ class ContestsController < ApplicationController @contest_activities = contest_activities.where("contest_act_type = 'Attachment'").order('updated_at desc') when "journalsForMessage" @contest_activities = contest_activities.where("contest_act_type = 'JournalsForMessage'").order('updated_at desc') + when "news" + @contest_activities = contest_activities.where("contest_act_type = 'News'").order('updated_at desc') else @contest_activities = contest_activities.order('updated_at desc') end diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index 970fded22..a58c1a7e4 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -2,6 +2,8 @@ $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); <% elsif @project %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'projects/project_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); +<% elsif @contest %> + $("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id => @user_activity_id}) %>"); <% else %> $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'organizations/course_news_post_reply', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); <% end %> diff --git a/app/views/contests/_contest_activity.html.erb b/app/views/contests/_contest_activity.html.erb index 8b7355138..f2e329403 100644 --- a/app/views/contests/_contest_activity.html.erb +++ b/app/views/contests/_contest_activity.html.erb @@ -41,7 +41,7 @@ <% when 'Work' %> <%= render :partial => 'users/contest_work', :locals => {:activity => act, :user_activity_id => activity.id, :hw_status => 2} %> <% when 'News' %> - <%#= render :partial => 'users/contest_news', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %> + <%= render :partial => 'users/contest_news', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %> <% when 'Message' %> <%#= render :partial => 'users/contest_message', :locals => {:activity => act, :user_activity_id => activity.id,:is_course=>1,:is_board=>0} %> <% when 'Poll' %> diff --git a/app/views/contests/contest_activities.html.erb b/app/views/contests/contest_activities.html.erb index f17bfb07d..564e54dfb 100644 --- a/app/views/contests/contest_activities.html.erb +++ b/app/views/contests/contest_activities.html.erb @@ -9,7 +9,7 @@