From 43bb3fe4eb2916825898af6904f96850f3aa959e Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 23 Dec 2016 19:35:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=AB=9E=E8=B5=9B=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=20=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/news_controller.rb | 2 +- app/models/news.rb | 2 + app/views/news/_contest_news.html.erb | 2 +- app/views/news/index.js.erb | 2 - app/views/users/_contest_newslist.html.erb | 67 ++++++++++++++++++++++ app/views/users/_course_newslist.html.erb | 2 +- 6 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 app/views/users/_contest_newslist.html.erb diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index c68b9bd00..45cdc49cb 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -88,7 +88,7 @@ class NewsController < ApplicationController #scope = News.find_by_sql("select a.*,b.updated_at from news a, course_activities b where a.course_id = 532 and a.course_id = b.course_id and b.course_act_id = a.id ) ") - scope = @contest ? @contest.news.visible : News.visible + scope = @contest.news if @contest # @newss = scope.all(:include => [:author, :contest], :order => "#{News.table_name}.created_on DESC") # # @page = params[:page] ? params[:page].to_i + 1 : 0 diff --git a/app/models/news.rb b/app/models/news.rb index de37154d2..f79768b88 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -165,6 +165,8 @@ class News < ActiveRecord::Base def act_as_course_activity if self.course self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.course_id) + elsif self.contest + self.contest_acts << ContestActivity.new(:user_id => self.author_id,:contest_id => self.contest_id) end end diff --git a/app/views/news/_contest_news.html.erb b/app/views/news/_contest_news.html.erb index 7b01b4e16..56bcff846 100644 --- a/app/views/news/_contest_news.html.erb +++ b/app/views/news/_contest_news.html.erb @@ -30,5 +30,5 @@ <%= render :partial => 'contest_news_new', :locals => {:f => f, :news => @news, :edit_mode => false, :contest => @contest} %> <% end %> <% end %> - <%= render :partial=> 'course_news_detail',:locals =>{:newss => @newss, :page => 0} %> + <%= render :partial=> 'contest_news_detail', :locals =>{:newss => @newss, :page => 0} %> \ No newline at end of file diff --git a/app/views/news/index.js.erb b/app/views/news/index.js.erb index bf57563e6..c5d5c84aa 100644 --- a/app/views/news/index.js.erb +++ b/app/views/news/index.js.erb @@ -1,7 +1,5 @@ <% if @project %> $("#show_more_project_news").replaceWith("<%= escape_javascript(render :partial => 'project_news_detail', :locals=>{ :all_news=>@newss,:page => @page})%>"); -<% elsif @course %> - $("#course-newslist").replaceWith('<%= escape_javascript( render :partial => 'users/course_newslist', :locals => {:topics => @newss}) %>'); <% else %> $("#course-newslist").replaceWith('<%= escape_javascript( render :partial => 'users/course_newslist', :locals => {:topics => @newss}) %>'); <% end %> \ No newline at end of file diff --git a/app/views/users/_contest_newslist.html.erb b/app/views/users/_contest_newslist.html.erb new file mode 100644 index 000000000..4c9d7377c --- /dev/null +++ b/app/views/users/_contest_newslist.html.erb @@ -0,0 +1,67 @@ +
+
+
+

通知列表

+
+ 排序: + <%= link_to "时间", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %> + <% if @type.to_i == 1 %> + <%= link_to "", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> + <% end %> + <%= link_to "人气", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %> + <% if @type.to_i == 2 %> + <%= link_to "", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 2 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> + <% end %> +
+
+
+ <% if topics.any? %> + <% topics.each do |activity| %> +
+
+ <%= link_to activity.title.to_s, User.current.logged? ? news_path(activity) : signin_url_without_domain, :class => "list-title-normal fl" %> + <% if activity.sticky == 1 %> + + <% end%> + <% u = User.where("id=?",activity.author_id).first%> +
+
+ + + +
+ + 发布者:<%= link_to activity.author.show_name, user_path(activity.author), :class => "link-blue" %> + + 更新:<%= format_time(activity.course_acts.first.try(:updated_at)) %> + <% count=0 %> + <% count=activity.comments.count %> +

<%= count>0 ? "#{count}" : "0" %>回复|<%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %>

+
+
+
+ <% end %> +
+
    + <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %> +
+
+
+ <% else %> +

<%= l(:label_no_data) %>

+ <% end %> +
+
+
+ \ No newline at end of file diff --git a/app/views/users/_course_newslist.html.erb b/app/views/users/_course_newslist.html.erb index 65f9572d6..bc06023fa 100644 --- a/app/views/users/_course_newslist.html.erb +++ b/app/views/users/_course_newslist.html.erb @@ -33,7 +33,7 @@ 发布者:<%= link_to activity.author.show_name, user_path(activity.author), :class => "link-blue" %> - 更新:<%= format_time(activity.course_acts.first.try(:updated_at)) %> + 更新:<%= format_time(@course ? activity.course_acts.first.try(:updated_at) : activity.contest_acts.first.try(:updated_at)) %> <% count=0 %> <% count=activity.comments.count %>

<%= count>0 ? "#{count}" : "0" %>回复|<%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %>