From b80bc98fcb47b69f2546566ef73590bca659bb22 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 29 Mar 2016 11:31:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 109 +++++++----- app/views/layouts/base_org_newstyle.html.erb | 162 ++++++------------ .../_org_new_course_create.html.erb | 5 + .../_org_new_course_homework.html.erb | 5 + .../_org_new_course_message.html.erb | 18 ++ .../_org_new_course_news.html.erb | 5 + .../_org_new_course_poll.html.erb | 5 + .../_org_new_project_create.html.erb | 3 + .../_org_new_project_issues.html.erb | 4 + .../_org_new_project_message.html.erb | 15 ++ public/stylesheets/org_new_style.css | 2 +- 11 files changed, 184 insertions(+), 149 deletions(-) create mode 100644 app/views/organizations/_org_new_course_create.html.erb create mode 100644 app/views/organizations/_org_new_course_homework.html.erb create mode 100644 app/views/organizations/_org_new_course_message.html.erb create mode 100644 app/views/organizations/_org_new_course_news.html.erb create mode 100644 app/views/organizations/_org_new_course_poll.html.erb create mode 100644 app/views/organizations/_org_new_project_create.html.erb create mode 100644 app/views/organizations/_org_new_project_issues.html.erb create mode 100644 app/views/organizations/_org_new_project_message.html.erb diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 858952f0d..e649dffb5 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -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) + # 组织新类型 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 + 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 - @page = params[:page] ? params[:page].to_i : 1 - respond_to do |format| - format.html - format.js - end - else - render_403 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 diff --git a/app/views/layouts/base_org_newstyle.html.erb b/app/views/layouts/base_org_newstyle.html.erb index e52238503..1c30bc192 100644 --- a/app/views/layouts/base_org_newstyle.html.erb +++ b/app/views/layouts/base_org_newstyle.html.erb @@ -110,7 +110,7 @@
@@ -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 @@
-

课程动态
GNSS

+

<%= @organization.name %>

course activities

More @@ -162,7 +162,7 @@

-

中国北斗开源社区
GNSS

+

<%= @organization.name %>

open laboratory of simulation and testing

More @@ -172,7 +172,7 @@

-

中国北斗开源社区
GNSS

+

<%= @organization.name %>

open laboratory of simulation and testing

More @@ -186,36 +186,50 @@

+ +<% @subfield_content.each do |field| %>
-

课程动态

open laboratory

+

课程动态

course activities

- - 2016-03-22 -

首届卫星导航仿真与测试专题研讨会在...首届卫星导航仿真与测试专题研讨会在...

-
10月15日,由卫星导航仿真与测试开放实验室联盟主办的首次专题研讨会在西安国家民用航天产业基地隆重召开...
-
- - 2016-03-22 -

首届卫星导航仿真与测试专题研讨会在...首届卫星导航仿真与测试专题研讨会在...

-
10月15日,由卫星导航仿真与测试开放实验室联盟主办的首次专题研讨会在西安国家民用航天产业基地隆重召开...
-
+ <% @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 %> More
- - 2016-03-22 -

首届卫星导航仿真与测试专题研讨会在...首届卫星导航仿真与测试专题研讨会在...

-
10月15日,由卫星导航仿真与测试开放实验室联盟主办的首次专题研讨会在西安国家民用航天产业基地隆重召开...
-
- - 2016-03-22 -

首届卫星导航仿真与测试专题研讨会在...首届卫星导航仿真与测试专题研讨会在...

-
10月15日,由卫星导航仿真与测试开放实验室联盟主办的首次专题研讨会在西安国家民用航天产业基地隆重召开...
-
+ <% @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 %> More
@@ -252,9 +266,18 @@
-

2016.01.30环球网卫星导航仿真与测试开放实验室落户泉州

-

卫星导航仿真与测试开放实验室是国内首个GNSS仿真与测试开放共享平台,北斗泉州实验室由国防科技大学泉州工业技术研究中心、福建省福信富通网络科技股份有限公司与开放实验室合作共建,计划于2016年3月建成并投用,将承建国内首个北斗海上数据应用中心,利用开放实验室优势资源承担相关专业人才培训,联合所属区域高校和企业开展船载导航终端北斗导航定位数据的采集、分析和应用,服务于全国北斗终端测试检定和相关应用研究。 - 据介绍,实验室建成后,将为泉州以及周边县(市、区)的北斗产业应用发展提供相应支撑,并依托泉州的地理和政策优势,推动北斗向海上丝绸之路经济带沿线国家的推广应用。

+ <% @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 %>
@@ -297,7 +320,7 @@
- +<% if field.field_type == "Post" %>

社区规则

open source

@@ -336,82 +359,7 @@
- - -
-
-
-

北斗社区规则

community rules

-

欢迎大家加入北斗社区,卫星导航仿真与测试开放实验室是国内首个GNSS仿真与测试开放共享平台

-
- -
-
+<% end %>
@@ -450,6 +398,8 @@
+<% end %> +