diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index bc1a6a003..f7adb13dc 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -70,11 +70,16 @@ class OrganizationsController < ApplicationController def show # 组织新类型 show_mode:判断标准 1为新类型,0为旧 - if @organization.show_mode == 1 && params[:org_subfield_id].nil? + if @organization.show_mode == 1 && params[:org_subfield_id].nil? && params[:type] .nil? @subfield_content = @organization.org_subfields.order("priority") - @project_acts = get_project_activities_org @organization + # 项目两种动态 + @project_issue_acts = get_project_issue_activities_org @organization + @project_message_acts = get_project_message_activities_org @organization + # 磕碜动态 + #@project_acts_issues = get_project_activities_org @organization @course_acts_homework = get_course_homework_activities_org @organization @course_acts_message = get_course_message_activities_org @organization + @course_acts_news = get_course_news_activities_org @organization render :layout => 'base_org_newstyle' else if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @@ -125,20 +130,30 @@ class OrganizationsController < ApplicationController end - def get_project_activities_org org + def get_project_message_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;") + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'Message' order by updated_at desc limit 2;") + end + + def get_project_issue_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' and org_act_type = 'issue' order by updated_at desc limit 4;") 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;") + 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 1;") 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;") + 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 1;") + end + + def get_course_news_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 = 'News' order by updated_at desc limit 1;") end def update diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 4834cdb9b..19ae17015 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -30,7 +30,12 @@ module OrganizationsHelper end def get_message_org(org_id, field_id) - OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and org_subfield_id = #{field_id} order by updated_at desc limit 3;") + OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and org_subfield_id = #{field_id} and parent_id is null order by updated_at desc limit 2;") + end + + def get_message_reply_org(org_id, ids) + # OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id is not null order by updated_at desc limit 1;") + OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id in (#{ids}) order by updated_at desc limit 1;") end def get_attach_org(field_id) diff --git a/app/views/layouts/base_org_newstyle.html.erb b/app/views/layouts/base_org_newstyle.html.erb index 315d53e9d..c796934df 100644 --- a/app/views/layouts/base_org_newstyle.html.erb +++ b/app/views/layouts/base_org_newstyle.html.erb @@ -27,242 +27,227 @@ tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} }); +
-
-
- - <%# 登录 %> - <%= render :partial => 'organizations/org_logined_header' %> +
+
+ + <%# 登录 %> + <%= render :partial => 'organizations/org_logined_header' %> +
+
+
+ + + + +
-
- - - - -
- - -<% @subfield_content.each do |field| %> - <% if is_default_field?(field) %> - <% case field.name %> - <% when 'course' %> -
-
-

课程动态

course activities

-
-
- - <% @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 %> + + <% @subfield_content.each do |field| %> + <% if is_default_field?(field) %> + <% case field.name %> + <% when 'course' %> +
+
+

课程动态

course activities

+
+
    +
  • + <% @course_acts_homework.each do |act| %> + <%= render :partial => 'org_new_course_homework', :locals => {:activity => HomeworkCommon.find(act.org_act_id),:user_activity_id =>act.id, :course_activity => 0} %> <% end %> - <% end %> - More -
-
- - <% @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 %> + +
  • + <% @course_acts_message.each do |act| %> + <%= render :partial => 'org_new_course_message', :locals => {:activity => Message.find(act.org_act_id), :user_activity_id =>act.id} %> <% end %> - <% end %> - More -
  • - -
    -
    -
    -
    - <% when 'project' %> -
    -
    -

    项目动态

    project activities

    - -
    -
    -
    -
    - <% @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 %> + +
  • + <% @course_acts_news.each do |act| %> + <%= render :partial => 'org_new_course_news', :locals => {:activity => News.find(act.org_act_id), :user_activity_id =>act.id} %> <% end %> -
  • -
    -
    -
    -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    -
    -
    -
    +
    - - -
    +
    -
    - -
    -
    - <% end %> -<% else %> - <% if field.field_type == "Post" %> <%# 讨论类型 %> - <% message_ats = get_message_org(@organization.id, field.id) %> -
    -
    -

    <%= field.name %>

    discussion zone

    -
    - <%= render :partial => 'organizations/org_new_forum', :locals => {:message_ats => message_ats, :field => field, :organization => @organization} %> -
    -
    -
    -
    - <% elsif field.field_type == "Resource" %> - <% org_attachs = get_attach_org2(field) %> -
    -
    -

    <%= field.name %>

    resource dwonload

    -
    + +
    +
    + <% when 'project' %> +
    +
    +

    项目动态

    project activities

    +
    +
    + + +
    + + + +
    + + <% @project_message_acts.each do |act| %> + <%= render :partial => 'organizations/org_new_project_message', :locals => {:activity => Message.find(act.org_act_id)} %> + <% end %> + <%= link_to "More", organization_path(@organization, :type => 1), :class => "more-btn mt30 fr", :target => "_blank" %> +
    +
    + +
    + <% @project_issue_acts.each do |act| %> + <%= render :partial => 'organizations/org_new_project_issues', :locals => {:activity => Issue.find(act.org_act_id)} %> + <% end %> + <%= link_to "More", organization_path(@organization, :type => 1), :class => "more-btn mt30 fr", :target => "_blank" %> +
    +
    + +
    +
    +
    +
    + <% end %> + <% else %> + <% if field.field_type == "Post" %> <%# 讨论类型 %> + <% message_ats = get_message_org(@organization.id, field.id) %> + <% ids = field.org_document_comments.map{|o| o.id}.join(",") %> +
    +
    +

    <%= field.name %><%= field.id %>

    discussion zone

    +
    +
    + <% message_ats.each do |act| %> + <%= render :partial => 'organizations/org_new_forum', :locals => {:activity => act, :field => field, :organization => @organization} %> + <% end %> + <%#= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn mt30 fr", :target => "_blank" %> +
    +
    + <% unless ids.blank? %> + <% message_reply_ats = get_message_reply_org(@organization.id, ids) %> +
    + <% message_reply_ats.each do |act| %> + <%= render :partial => 'organizations/org_new_forum_reply', :locals => {:activity => act, :field => field, :organization => @organization} %> + <% end %> +
    +
    + + <% end %> +
    +
    +
    + <%= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> +
    +
    + <% elsif field.field_type == "Resource" %> + <% org_attachs = get_attach_org2(field) %> +
    +
    +

    <%= field.name %><%= field.id %>

    resource dwonload

    +
    <%= render :partial => 'organizations/org_new_resource', :locals => {:org_attachs => org_attachs} %>
    + +
    + <%= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %>
    -
    - <% end %> - <% end %> -<% end %> +
    + <% end %> + <% end %> + <% end %> - +
    - -
    - + +
    + - + - + diff --git a/app/views/organizations/_org_logined_header.html.erb b/app/views/organizations/_org_logined_header.html.erb index d2cf5d753..fa4c228a1 100644 --- a/app/views/organizations/_org_logined_header.html.erb +++ b/app/views/organizations/_org_logined_header.html.erb @@ -23,8 +23,10 @@
    <% else %> - - + <% end %>