diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index a0ef84798..ef11dc9da 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -28,6 +28,7 @@ class OrganizationsController < ApplicationController helper :project_score helper :issues include UsersHelper + include OrganizationsHelper before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers, :students, :projects, :courses] before_filter :allow_as_admin, :only => [:students, :teachers, :projects, :courses, :acts] layout 'base_org' @@ -77,8 +78,12 @@ class OrganizationsController < ApplicationController def show # 组织新类型 show_mode:判断标准 1为新类型,0为旧 - if @organization.switch_type && params[:org_subfield_id].nil? && params[:list] .nil? + if @organization.switch_type && params[:list] .nil? if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + unless params[:org_subfield_id].nil? + @org_subfield = OrgSubfield.where(:id => params[:org_subfield_id]).first + @subfield_acts = get_subfield_acts(@org_subfield) + end @subfield_content = @organization.org_subfields.order("priority") 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) diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index fa0d33f6e..c523ec287 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -115,6 +115,41 @@ module OrganizationsHelper end end + # 组织的栏目类型标题 + def subfield_title_type obj + case obj.org_act_type + when "OrgDocumentComment" + obj.org_act.title + when "Message" + obj.org_act.parent_id.nil? ? obj.org_act.subject : obj.org_act.parent.subject + when "News" + obj.org_act.title + end + end + + # 组织的栏目类型时间 + def subfield_time_type obj + case obj.org_act_type + when "OrgDocumentComment" + obj.org_act.updated_at + when "Message" + obj.org_act.updated_on + when "News" + obj.org_act.created_on + end + end + + def subfield_reply_count_type obj + case obj.org_act_type + when "OrgDocumentComment" + obj.org_act.children.count + when "Message" + obj.org_act.children.count + when "News" + obj.org_act.comments_count + end + end + #排列下拉框 def subfield_status_option type = [] @@ -186,9 +221,11 @@ module OrganizationsHelper end def get_subfield_acts field - org_subfield = OrgSubfield.find(field.id) - org_subfield_ids = org_subfield.org_document_comments.map(&:id) << 0 - org_acts = 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') + unless field.nil? + org_subfield = OrgSubfield.find(field.id) + org_subfield_ids = org_subfield.org_document_comments.map(&:id) << 0 + org_acts = 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') + end end def allow_to_create?(org, type) diff --git a/app/views/organizations/_show_custom_org_subfield.html.erb b/app/views/organizations/_show_custom_org_subfield.html.erb new file mode 100644 index 000000000..473a5757d --- /dev/null +++ b/app/views/organizations/_show_custom_org_subfield.html.erb @@ -0,0 +1,44 @@ +<% if @subfield_acts.blank? %> +<% else %> +