组织网站动态新页面

This commit is contained in:
huang 2016-06-08 09:40:05 +08:00
parent e4f48f046b
commit 67f0cad331
3 changed files with 41 additions and 13 deletions

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,4 @@
<% if @subfield_acts.blank? %>
<% if @org_acts.blank? %>
<p class="fontGrey2 f14 mt10 mb5">该模块暂时没有相关内容</p>
<% else %>
<div class="sn-inner-body">
@ -12,20 +12,27 @@
<div class="sn-inner-newslist mt15">
<h2 class="sn-inner-newsh2"><%= @org_subfield.name %></h2>
<ul>
<% @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) %>
<li>
<div class="sn-circle fl"></div>
<% 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 %>
<span class=" txt-grey fr"><%= format_date(time) %></span>
<span class="sn-newslist-reply fr mr10 txt-grey">回复(<%= reply_count %></span>
<div class="cl"></div>