From 76732a3034b4ea0b17cf80dfb317986f97f479c3 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 2 Jun 2016 13:17:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E6=A8=A1=E5=BC=8F=E6=9C=89=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 33 +++-- app/helpers/organizations_helper.rb | 16 ++- .../organizations/_org_custom_right1.html.erb | 115 +++++++----------- .../_organization_content_extension.html.erb | 18 ++- public/stylesheets/org_custom.css | 2 +- 5 files changed, 94 insertions(+), 90 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index c63cf8c7f..4021560bf 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -79,19 +79,28 @@ class OrganizationsController < ApplicationController # 组织新类型 show_mode:判断标准 1为新类型,0为旧 if @organization.switch_type && params[:org_subfield_id].nil? && params[:list] .nil? if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) - # REDO:时间紧,暂时先这样 - @org_logo_attchment = Attachment.find_by_sql("SELECT * from attachments WHERE container_id = #{@organization.id} and container_type = 'Organization' and attachtype = 0 and filename REGEXP '(.jpg|.png|.bmp|.gif|.jpeg)' ORDER BY created_on desc limit 1").first - @org_banner_attchment = Attachment.find_by_sql("SELECT * from attachments WHERE container_id = #{@organization.id} and container_type = 'Organization' and attachtype = 1 and filename REGEXP '(.jpg|.png|.bmp|.gif|.jpeg)' ORDER BY created_on desc limit 1").first - @subfield_content = @organization.org_subfields.order("priority") - @organization = Organization.find(params[:id]) - 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')" - @project_acts = get_project_activities_org @organization, project_ids - @course_acts = get_course_activities_org @organization, course_ids + 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')" + @project_acts = get_project_activities_org @organization, project_ids + @course_acts = get_course_activities_org @organization, course_ids + # 精品课程, 不符合条件的组织则不查询 + if @organization.org_subfields.where(:field_type => "Compcou", :hide => 0).count > 0 + @excellent_courses = Course.where(:is_public => true, :is_delete => false, :is_excellent => true) + end + # 热门项目 + if @organization.org_subfields.where(:field_type => "Comppro", :hide => 0).count > 0 + @excellent_courses = Course.where(:is_public => true, :status => true) + end + # 最新动态, 来自我关联的项目和课程 + if @organization.org_subfields.where(:field_type => "Compact", :hide => 0).count > 0 + @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 created_at desc limit 6;") + end render :layout => 'base_org_custom' else render_403 diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 8e75ec5d1..4c6089b51 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -63,6 +63,16 @@ module OrganizationsHelper end end + def org_user_by_type obj + case obj.act_type + when "Message" + when "News" + when "HomeworkCommon" + when "Issue" + end + + end + #排列下拉框 def subfield_status_option type = [] @@ -176,9 +186,9 @@ module OrganizationsHelper end # 获取最新动态 - def get_latest_acts - acts = UserActivity.find_by_sql("SELECT * FROM `user_activities` where act_type in ('HomeworkCommon', 'news', 'message', 'Issue') and (container_type = 'Course' or container_type = 'Project') order by created_at limit 10;") - end + # def get_latest_acts + # acts = UserActivity.find_by_sql("SELECT * FROM `user_activities` where act_type in ('HomeworkCommon', 'news', 'message', 'Issue') and (container_type = 'Course' or container_type = 'Project') order by created_at limit 10;") + # end def org_teacher_resource_count user results = Attachment.find_by_sql("SELECT * FROM attachments where author_id = #{user.id};").count diff --git a/app/views/organizations/_org_custom_right1.html.erb b/app/views/organizations/_org_custom_right1.html.erb index 6fc24555f..4fed81a6b 100644 --- a/app/views/organizations/_org_custom_right1.html.erb +++ b/app/views/organizations/_org_custom_right1.html.erb @@ -1,71 +1,48 @@
-

最新动态更多>

- +

<%= field.name %>

+ <% if @acts.blank? %> +

该模块暂时没有相关内容

+ <% else %> + + <% end %>
\ No newline at end of file diff --git a/app/views/organizations/_organization_content_extension.html.erb b/app/views/organizations/_organization_content_extension.html.erb index a486edd65..be5343d61 100644 --- a/app/views/organizations/_organization_content_extension.html.erb +++ b/app/views/organizations/_organization_content_extension.html.erb @@ -1,8 +1,16 @@ -

- - <%= content.to_s.html_safe%> - -

+<% if cl.nil? %> + + + <%= content.to_s.html_safe%> + + +<% else %> +

+ + <%= content.to_s.html_safe%> + +

+<% end %>