组织首页

This commit is contained in:
huang 2016-03-29 11:31:58 +08:00
parent b8463fcca5
commit b80bc98fcb
11 changed files with 185 additions and 150 deletions

View File

@ -75,51 +75,76 @@ class OrganizationsController < ApplicationController
end
def show
@subfield_content = @organization.org_subfields.order("priority") if @organization.show_mode == 1
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@organization = Organization.find(params[:id])
# 统计访问量
@organization.update_attribute(:visits, @organization.visits.to_i + 1)
if params[:org_subfield_id]
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
@org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
else
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
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
case params[:type]
when nil
@org_activities = OrgActivity.where("(container_id =? and container_type =?) " +
"or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+
"or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))",
@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
when 'project_issue'
@org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'project_message'
@org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'org'
@org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_homework'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_news'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_message'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_poll'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
end
end
@page = params[:page] ? params[:page].to_i : 1
respond_to do |format|
format.html
format.js
end
# 组织新类型 show_mode判断标准 1为新类型0为旧
if @organization.show_mode == 1
@subfield_content = @organization.org_subfields.order("priority")
@project_acts = get_project_activities_org @organization
@course_acts_homework = get_course_homework_activities_org @organization
@course_acts_message = get_course_message_activities_org @organization
else
render_403
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@organization = Organization.find(params[:id])
# 统计访问量
@organization.update_attribute(:visits, @organization.visits.to_i + 1)
if params[:org_subfield_id]
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
@org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
else
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
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
case params[:type]
when nil
@org_activities = OrgActivity.where("(container_id =? and container_type =?) " +
"or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+
"or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))",
@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
when 'project_issue'
@org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'project_message'
@org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'org'
@org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_homework'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_news'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_message'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_poll'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
end
end
@page = params[:page] ? params[:page].to_i : 1
respond_to do |format|
format.html
format.js
end
else
render_403
end
end
end
def get_project_activities_org org
project_ids = org.projects.map{|project| project.id}.join(",")
project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' order by updated_at desc limit 3;")
end
def get_course_homework_activities_org org
course_ids = org.courses.map{|course| course.id}.join(",")
#project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' order by updated_at desc limit 5;")
project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'HomeworkCommon' order by updated_at desc limit 4;")
end
def get_course_message_activities_org org
course_ids = org.courses.map{|course| course.id}.join(",")
project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'Message' order by updated_at desc limit 4;")
end
def update

View File

@ -110,7 +110,7 @@
<div class="container">
<div class="header">
<div class="header-con">
<a href="index.html" class="fl"><img src="/images/org_new_style/logo.jpg" alt=""/></a>
<a href="index.html" class="fl"><%= image_tag(url_to_avatar(@organization),width:"60", height: "60", :id=>'nh_user_tx') %><img src="/images/org_new_style/logo.jpg" alt=""/></a>
<a href="register.html" class="register fr"></a>
<a href="login.html" class="login fr"></a>
</div>
@ -132,7 +132,7 @@
<% else %>
<% if field.field_type == "Post" %>
<%= link_to field.name, organization_path(@organization), :class => "fl" %>
<% else %>
<% elsif field.field_type == "Resource" %>
<%= link_to field.name, organization_path(@organization), :class => "fl" %>
<% end %>
<% end %>
@ -153,7 +153,7 @@
<div class="slider-sections sandbox">
<section class="first">
<div class="text">
<h2>课程动态<br />GNSS</h2>
<h2><%= @organization.name %><br /></h2>
<p class="copy">course activities</p>
<p class="button">
<a class="dimmed" href="#"> More</a>
@ -162,7 +162,7 @@
</section>
<section>
<div class="text">
<h2>中国北斗开源社区<br />GNSS</h2>
<h2><%= @organization.name %></h2>
<p class="copy">open laboratory of simulation and testing</p>
<p class="button">
<a class="dimmed" href="#">More</a>
@ -172,7 +172,7 @@
<section>
<div class="text">
<h2>中国北斗开源社区<br />GNSS</h2>
<h2><%= @organization.name %></h2>
<p class="copy">open laboratory of simulation and testing</p>
<p class="button">
<a class="dimmed" href="#"> More</a>
@ -186,36 +186,50 @@
</div><!--header-content end-->
<div class="cl"></div>
<!--模块-->
<% @subfield_content.each do |field| %>
<div class="box1">
<div class="content">
<div class="box-top"><h2 class="box-title">课程动态</h2><p class="box-title-p">open laboratory</p></div>
<div class="box-top"><h2 class="box-title">课程动态</h2><p class="box-title-p">course activities</p></div>
<div class="row ">
<div class="row-box1 mr40 fl">
<a href="#" target="_blank" class="row-img"><img src="/images/org_new_style/img1.jpg"></a>
<a href="#" target="_blank" class="row-con">
<span class="row-time">2016-03-22</span>
<h3 class="row-title ">首届卫星导航仿真与测试专题研讨会在...首届卫星导航仿真与测试专题研讨会在...</h3>
<div class="row-txt row-txt-line">10月15日由卫星导航仿真与测试开放实验室联盟主办的首次专题研讨会在西安国家民用航天产业基地隆重召开...</div>
</a>
<a href="#" target="_blank" class="row-con">
<span class="row-time">2016-03-22</span>
<h3 class="row-title">首届卫星导航仿真与测试专题研讨会在...首届卫星导航仿真与测试专题研讨会在...</h3>
<div class="row-txt row-txt-line">10月15日由卫星导航仿真与测试开放实验室联盟主办的首次专题研讨会在西安国家民用航天产业基地隆重召开...</div>
</a>
<% @course_acts_homework.each do |act| %>
<% if act.container_type == 'Course' %>
<% case act.org_act_type.to_s %>
<% when 'HomeworkCommon' %>
<%= render :partial => 'org_new_course_homework', :locals => {:activity => HomeworkCommon.find(act.org_act_id),:user_activity_id =>act.id,:course_activity => 0} %>
<% when 'News' %>
<%= render :partial => 'org_new_course_news', :locals => {:activity => News.find(act.org_act_id),:user_activity_id =>act.id} %>
<% when 'Message'%>
<%= render :partial => 'org_new_course_message', :locals => {:activity => Message.find(act.org_act_id),:user_activity_id =>act.id} %>
<% when 'Poll' %>
<%= render :partial => 'org_new_course_poll', :locals => {:activity => Poll.find(act.org_act_id), :user_activity_id => act.id} %>
<% when 'Course'%>
<%= render :partial => 'org_new_course_create', :locals => {:activity => Course.find(act.org_act_id), :user_activity_id => act.id} %>
<% end %>
<% end %>
<% end %>
<a href="#" target="_blank" class="btn-more">More</a>
</div><!--row-box1 end-->
<div class="row-box1 mr40 fl">
<a href="#" target="_blank" class="row-img"><img src="/images/org_new_style/img2.jpg"></a>
<a href="#" target="_blank" class="row-con">
<span class="row-time">2016-03-22</span>
<h3 class="row-title">首届卫星导航仿真与测试专题研讨会在...首届卫星导航仿真与测试专题研讨会在...</h3>
<div class="row-txt row-txt-line">10月15日由卫星导航仿真与测试开放实验室联盟主办的首次专题研讨会在西安国家民用航天产业基地隆重召开...</div>
</a>
<a href="#" target="_blank" class="row-con">
<span class="row-time">2016-03-22</span>
<h3 class="row-title">首届卫星导航仿真与测试专题研讨会在...首届卫星导航仿真与测试专题研讨会在...</h3>
<div class="row-txt row-txt-line">10月15日由卫星导航仿真与测试开放实验室联盟主办的首次专题研讨会在西安国家民用航天产业基地隆重召开...</div>
</a>
<% @course_acts_message.each do |act| %>
<% if act.container_type == 'Course' %>
<% case act.org_act_type.to_s %>
<% when 'HomeworkCommon' %>
<%= render :partial => 'org_new_course_homework', :locals => {:activity => HomeworkCommon.find(act.org_act_id),:user_activity_id =>act.id,:course_activity => 0} %>
<% when 'News' %>
<%= render :partial => 'org_new_course_news', :locals => {:activity => News.find(act.org_act_id),:user_activity_id =>act.id} %>
<% when 'Message'%>
<%= render :partial => 'org_new_course_message', :locals => {:activity => Message.find(act.org_act_id),:user_activity_id =>act.id} %>
<% when 'Poll' %>
<%= render :partial => 'org_new_course_poll', :locals => {:activity => Poll.find(act.org_act_id), :user_activity_id => act.id} %>
<% when 'Course'%>
<%= render :partial => 'org_new_course_create', :locals => {:activity => Course.find(act.org_act_id), :user_activity_id => act.id} %>
<% end %>
<% end %>
<% end %>
<a href="#" target="_blank" class="btn-more">More</a>
</div><!--row-box1 end-->
<div class="row-box2 fl ">
@ -252,9 +266,18 @@
<div class="container">
<div class="row ">
<div class=" slider2-left fl" >
<h3><span>2016.01.30环球网</span>卫星导航仿真与测试开放实验室落户泉州</h3>
<p>卫星导航仿真与测试开放实验室是国内首个GNSS仿真与测试开放共享平台北斗泉州实验室由国防科技大学泉州工业技术研究中心、福建省福信富通网络科技股份有限公司与开放实验室合作共建计划于2016年3月建成并投用将承建国内首个北斗海上数据应用中心利用开放实验室优势资源承担相关专业人才培训联合所属区域高校和企业开展船载导航终端北斗导航定位数据的采集、分析和应用服务于全国北斗终端测试检定和相关应用研究。
据介绍,实验室建成后,将为泉州以及周边县(市、区)的北斗产业应用发展提供相应支撑,并依托泉州的地理和政策优势,推动北斗向海上丝绸之路经济带沿线国家的推广应用。</p>
<% @project_acts.each do |act| %>
<% if act.container_type == 'Project' %>
<% case act.org_act_type.to_s %>
<% when 'Issue' %>
<%= render :partial => 'organizations/org_new_project_issues', :locals => {:activity => Issue.find(act.org_act_id)} %>
<% when 'Message' %>
<%= render :partial => 'organizations/org_new_project_message', :locals => {:activity => Message.find(act.org_act_id)} %>
<% when 'ProjectCreateInfo'%>
<%= render :partial => 'organizations/org_new_project_create', :locals => {:activity => act} %>
<% end %>
<% end %>
<% end %>
</div>
<div class=" slider2-right fl " >
<div class="slider2">
@ -297,7 +320,7 @@
</div><!--content end-->
</div><!--box2 end-->
<% if field.field_type == "Post" %>
<div class="box1">
<div class="content">
<div class="box-top"><h2 class="box-title">社区规则</h2><p class="box-title-p">open source</p></div>
@ -336,82 +359,7 @@
</div>
</div><!--content end-->
</div> <!--box1 end-->
<div class="box3">
<div class="content">
<div class="box-top">
<h2 class="box-title">北斗社区规则</h2><p class="box-title-p mb70">community rules</p>
<p class="box-title-p3">欢迎大家加入北斗社区卫星导航仿真与测试开放实验室是国内首个GNSS仿真与测试开放共享平台</p>
</div>
<div class="indexmaindiv" id="indexmaindiv">
<div class="indexmaindiv1 clearfix" >
<div class="stylesgoleft" id="goleft"></div>
<div class="maindiv1 " id="maindiv1">
<ul id="count1">
<li>
<a href="#" class="playerdetail">
<div class="detailimg"><img src="/images/org_new_style/detailimg1.jpg" /></div>
<div class="teanames">Mark</div>
<div class="teadetail">学生</div>
</a>
</li>
<li>
<a href="#" class="playerdetail">
<div class="detailimg"><img src="/images/org_new_style/detailimg2.jpg" /></div>
<div class="teanames">Mark</div>
<div class="teadetail">学生</div>
</a>
</li>
<li>
<a href="#" class="playerdetail">
<div class="detailimg"><img src="/images/org_new_style/detailimg3.jpg" /></div>
<div class="teanames">Mark</div>
<div class="teadetail">学生</div>
</a>
</li>
<li>
<a href="#" class="playerdetail">
<div class="detailimg"><img src="/images/org_new_style/detailimg4.jpg" /></div>
<div class="teanames">Mark</div>
<div class="teadetail">学生</div>
</a>
</li>
<li>
<a href="#" class="playerdetail">
<div class="detailimg"><img src="/images/org_new_style/detailimg1.jpg" /></div>
<div class="teanames">Mark</div>
<div class="teadetail">学生</div>
</a>
</li>
<li>
<a href="#" class="playerdetail">
<div class="detailimg"><img src="/images/org_new_style/detailimg2.jpg" /></div>
<div class="teanames">Mark</div>
<div class="teadetail">学生</div>
</a>
</li>
<li>
<a href="#" class="playerdetail">
<div class="detailimg"><img src="/images/org_new_style/detailimg3.jpg" /></div>
<div class="teanames">Mark</div>
<div class="teadetail">学生</div>
</a>
</li>
<li>
<a href="#" class="playerdetail">
<div class="detailimg"><img src="/images/org_new_style/detailimg4.jpg" /></div>
<div class="teanames">Mark</div>
<div class="teadetail">学生</div>
</a>
</li>
</ul>
</div>
<div class="stylesgoright" id="goright"></div>
</div>
</div><!---indexmaindiv-->
</div><!--content end-->
</div> <!--box3 end-->
<% end %>
<div class="box1">
<div class="content">
@ -450,6 +398,8 @@
</div><!--content end-->
<div class="cl"></div>
</div><!--box1 end-->
<% end %>
<div class="footer">
<div class="footer-con">

View File

@ -0,0 +1,5 @@
<a href="#" target="_blank" class="row-con">
<span class="row-time"><%= format_time(activity.updated_at) %></span>
<h3 class="row-title "><%= activity.title %></h3>
<div class="row-txt row-txt-line"><%= activity.description %></div>
</a>

View File

@ -0,0 +1,5 @@
<a href="#" target="_blank" class="row-con">
<span class="row-time"><%= format_time activity.updated_at %></span>
<h3 class="row-title "><%= activity.name %></h3>
<div class="row-txt row-txt-line"><%= activity.description.html_safe %></div>
</a>

View File

@ -0,0 +1,18 @@
<a href="#" target="_blank" class="row-con">
<span class="row-time"><%= format_time activity.updated_on %></span>
<h3 class="row-title ">
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :class=> "postGrey" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :class=> "postGrey" %>
<% end %>
</h3>
<div class="row-txt row-txt-line">
<% if activity.parent_id.nil? %>
<% content = activity.content %>
<% else %>
<% content = activity.parent.content %>
<% end %>
<%= content.to_s.html_safe %>
</div>
</a>

View File

@ -0,0 +1,5 @@
<a href="#" target="_blank" class="row-con">
<span class="row-time"><%= format_time activity.updated_at %></span>
<h3 class="row-title ">首届卫星导航仿真与测试专题研讨会在...首届卫星导航仿真与测试专题研讨会在...</h3>
<div class="row-txt row-txt-line">10月15日由卫星导航仿真与测试开放实验室联盟主办的首次专题研讨会在西安国家民用航天产业基地隆重召开...</div>
</a>

View File

@ -0,0 +1,5 @@
<a href="#" target="_blank" class="row-con">
<span class="row-time"><%= format_time activity.updated_at %></span>
<h3 class="row-title ">首届卫星导航仿真与测试专题研讨会在...首届卫星导航仿真与测试专题研讨会在...</h3>
<div class="row-txt row-txt-line">10月15日由卫星导航仿真与测试开放实验室联盟主办的首次专题研讨会在西安国家民用航天产业基地隆重召开...</div>
</a>

View File

@ -0,0 +1,3 @@
<% project = Project.find(activity.org_act_id) %>
<h3><span><%= format_time(project.updated_on) %>项目社区</span><%= project.name %></h3>
<p><%= project.description %></p>

View File

@ -0,0 +1,4 @@
<h3><span><%= format_time(activity.updated_on) %>项目社区</span>
<%= link_to activity.subject.to_s, issue_url_in_org(activity.id) %>
</h3>
<p><%= activity.description.html_safe %></p>

View File

@ -0,0 +1,15 @@
<h3><span><%= format_time(activity.updated_on) %>项目社区</span>
<% if activity.parent_id.nil? %>
<%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board.id,activity.id) %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board.id,activity.id) %>
<% end %>
</h3>
<p>
<% if activity.parent_id.nil? %>
<% content = activity.content%>
<% else %>
<% content = activity.parent.content%>
<% end %>
<%= content.to_s.html_safe %>
</p>

View File

@ -87,7 +87,7 @@ a:hover.search-icon{ background:url(../images/org_new_style/icons.png) -387px -8
.row-con:hover{ color:#29156f; }
.row-txt{line-height:2.4; padding-bottom:10px; margin-bottom:10px; color:#888;}
.row-txt:hover{color:#29156f;}
.row-txt-line{border-bottom:1px solid #cccccc; width:365px;}
.row-txt-line{border-bottom:1px solid #cccccc; width:365px; height:56px; overflow:hidden;}
a.btn-more{ display:block; font-size:14px; width:110px; height:40px;-moz-border-radius: 3px; -webkit-border-radius: 3px; background:#ffbd18; color:#fff; text-align:center; line-height:3.0;}
a:hover.btn-more{ background:#29156f;}
.row-box2{ width:388px; border:1px solid #ccc; border-bottom:none;}