新建组织为空的情况

This commit is contained in:
huang 2016-03-30 19:17:29 +08:00
parent b64e8a5f9e
commit 8f43341f81
2 changed files with 38 additions and 8 deletions

View File

@ -132,28 +132,51 @@ class OrganizationsController < ApplicationController
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' and org_act_type = 'Message' order by updated_at desc limit 2;")
unless project_ids.blank?
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;")
else
project_acts = nil
end
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;")
unless project_ids.blank?
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;")
else
project_acts = nil
end
#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(",")
unless course_ids.blank?
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;")
else
project_acts = nil
end
#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 1;")
#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 1;")
unless course_ids.blank?
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;")
else
project_acts = nil
end
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;")
unless course_ids.blank?
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;")
else
project_acts = nil
end
#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

View File

@ -112,21 +112,27 @@
<div class="box-top" id="course_<%= field.id %>"><h2 class="box-title">课程动态</h2><p class="box-title-p">course activities</p></div>
<div class="course-list">
<ul class="clearfix">
<% unless @course_acts_homework.nil? %>
<li >
<% @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 %>
</li>
<% end %>
<% unless @course_acts_message.nil? %>
<li >
<% @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 %>
</li>
<% end %>
<% unless @course_acts_news.nil? %>
<li >
<% @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 %>
</li>
<% end %>
<div class="cl"></div>
</ul>
</div>
@ -139,10 +145,8 @@
<div class="content">
<div class="box-top" id="project_<%= field.id %>"><h2 class="box-title">项目动态</h2><p class="box-title-p">project activities</p></div>
<div class="row">
<% unless @project_message_acts.nil? %>
<div class="row-l fl">
<!-- img -->
<!-- text -->
<% @project_message_acts.each do |act| %>
<%= render :partial => 'organizations/org_new_project_message', :locals => {:activity => Message.find(act.org_act_id)} %>
@ -150,7 +154,9 @@
<%= link_to "More", organization_path(@organization, :type => 1), :class => "more-btn mt30 fr", :target => "_blank" %>
<div class="cl"></div>
</div>
<% end %>
<!-- row-l end -->
<% unless @project_issue_acts.nil? %>
<div class="row-r fr">
<% @project_issue_acts.each do |act| %>
<%= render :partial => 'organizations/org_new_project_issues', :locals => {:activity => Issue.find(act.org_act_id)} %>
@ -158,6 +164,7 @@
<%= link_to "More", organization_path(@organization, :type => 1), :class => "more-btn mt30 fr", :target => "_blank" %>
<div class="cl"></div>
</div>
<% end %>
<!-- article-rwrap end -->
</div>
<div class="cl"></div>