From 67f0cad331227dd5d3fe05718ec92553ea915d85 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 8 Jun 2016 09:40:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=BD=91=E7=AB=99=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=96=B0=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 8 +++++- app/helpers/organizations_helper.rb | 15 ++++++++++ app/views/organizations/acts.html.erb | 31 +++++++++++++-------- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 098cefceb..97fd65aa7 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -267,7 +267,13 @@ class OrganizationsController < ApplicationController def acts @subfield_content = @organization.org_subfields.order("priority") @org_subfield = OrgSubfield.where(:id => params[:org_subfield_id]).first - @subfield_acts = get_subfield_acts(@org_subfield) + shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id) + shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id) + project_ids = (@organization.projects.map(&:id) - shield_project_ids) << 0 + course_ids = (@organization.courses.map(&:id) - shield_course_ids) << 0 + @org_acts = UserActivity.find_by_sql("SELECT * FROM `user_activities` where act_type in ('HomeworkCommon', 'News', 'Message', 'Issue') and + ((container_type = 'Course' and container_id in (#{course_ids.join(',')})) or (container_type = 'Project' and container_id in (#{project_ids.join(',')}))) + order by updated_at desc limit 6;") respond_to do |format| format.html{render :layout => 'base_org_custom'} format.js diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 60714f597..4099ea451 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -115,6 +115,19 @@ module OrganizationsHelper end end + def org_reply_count_type obj + case obj.act_type + when "HomeworkCommon" + obj.act.journals_for_messages.count + when "Issue" + obj.act.journals.count + when "Message" + obj.act.children.count + when "News" + obj.act.comments_count + end + end + # 组织的栏目类型标题 def subfield_title_type obj case obj.org_act_type @@ -124,6 +137,8 @@ module OrganizationsHelper obj.org_act.parent_id.nil? ? obj.org_act.subject : obj.org_act.parent.subject when "News" obj.org_act.title + when "Issue" + obj.org_act.subject end end diff --git a/app/views/organizations/acts.html.erb b/app/views/organizations/acts.html.erb index da6b79ee6..8bd664711 100644 --- a/app/views/organizations/acts.html.erb +++ b/app/views/organizations/acts.html.erb @@ -1,4 +1,4 @@ -<% if @subfield_acts.blank? %> +<% if @org_acts.blank? %>

该模块暂时没有相关内容

<% else %>
@@ -12,20 +12,27 @@

<%= @org_subfield.name %>

    - <% @subfield_acts.each do |act| %> - <% title = subfield_title_type(act) %> - <% time = subfield_time_type(act) %> - <% reply_count = subfield_reply_count_type(act) %> - <% document = act.org_act %> + <% @org_acts.each do |obj| %> + <% user = org_user_by_type(obj) %> + <% title = org_title_by_type(obj) %> + <% content = org_content_by_type(obj) %> + <% time = org_time_by_type(obj) %> + <% reply_count = org_reply_count_type(obj) %>
  • - <% if act.org_act_type == "OrgDocumentComment" %> - <%=link_to title, org_document_comment_path(act.org_act, :organization_id => @organization.id), :class => "sn-newslist-titile fl", :target => "_blank" %> - <% elsif act.org_act_type == "News" %> - <%=link_to title, news_path(act.org_act), :class => "sn-newslist-titile fl", :target => "_blank" %> - <% elsif act.org_act_type == "Message" %> - <%=link_to title, board_message_path(act.org_act.board.id, act.org_act.id), :class => "sn-newslist-titile fl", :target => "_blank" %> + <% if obj.act_type == "Message" %> + <%= link_to title, board_message_path(obj.act.board.id, obj.act.id), :class => "sn-newslist-titile fl", :target => "_blank" %> + <% elsif obj.act_type == "News" %> + <%= link_to title, news_path(obj.act.id), :class => "sn-newslist-titile fl", :target => "_blank" %> + <% elsif obj.act_type == "HomeworkCommon" %> + <%= link_to title, student_work_index_url_in_org(obj.act.id), :class => "sn-newslist-titile fl", :target => "_blank" %> + <% elsif obj.act_type == "Issue" %> + <%= link_to title, issue_path(obj.act.id), :class => "sn-newslist-titile fl", :target => "_blank" %> <% end %> + + + + <%= format_date(time) %> 回复(<%= reply_count %>)