新模式有一

This commit is contained in:
huang 2016-06-02 13:17:38 +08:00
parent e5eeba90f6
commit 76732a3034
5 changed files with 94 additions and 90 deletions

View File

@ -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
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

View File

@ -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

View File

@ -1,6 +1,36 @@
<div class="por_news">
<h2 class="por_h2_index clear">最新动态<a href="javascript:void(0);" target="_blank" class="por_more_index fr">更多></a></h2>
<h2 class="por_h2_index clear"><%= field.name %></h2>
<% if @acts.blank? %>
<p class="fontGrey2 f14 mt10 mb5">该模块暂时没有相关内容</p>
<% else %>
<ul class="por_news_list clear">
<% @acts.each do |obj| %>
<% if obj.act_type = "Message" %>
<% user = org_user_by_type(obj) %>
<% title = org_title_by_type(obj) %>
<% content = org_content_by_type(obj) %>
<% message = obj.act %>
<% title = message.parent_id.nil? ? message.subject : message.parent.subject %>
<li>
<%= link_to image_tag(url_to_avatar(user),:width => "43", :height => "43", :class => "por_users_img"), user_path(user), :target => "_blank", :class => "fl" %>
<div class="por_news_txt fl">
<p class="por_news_p fl">
<%= link_to message.author.show_name, user_path(message.author), :class => "por_hot_name fl", :target => "_blank" %>
<span class="fl">&nbsp;:&nbsp;</span>
<%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => message.id, :content=> message.content, :maxheight => 40, :maxwordsnum => 28, :maxwidth => 0, :cl => ""} %>
</p>
<p><span class="por_time fl"><%= time_from_now(message.created_on) %> </span>
<!--<a href="javascript:void(0);" target="_blank" class="por_zan fr">50</a>-->
</p>
</div>
<div class="cl"></div>
</li>
<% elsif obj.act_type = "News" %>
<% elsif obj.act_type = "HomeworkCommon" %>
<% elsif obj.act_type = "Issue" %>
<% end %>
<% end %>
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_users_img"/></a>
<div class="por_news_txt fl">
@ -12,60 +42,7 @@
</div>
<div class="cl"></div>
</li>
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_users_img"/></a>
<div class="por_news_txt fl">
<p class="por_news_p fl">
<a href="javascript:void(0);" target="_blank" class=" por_hot_name fl"> 叮当叮当叮当叮当 </a><span class="fl">&nbsp;:&nbsp;</span>
Trustie社区新版上线了必须支持一下比以前好用很多了。Trustie社区新版上线了必须支持一下比以前好用很多了...
</p>
<p><span class="por_time fl">1分钟前 </span><a href="javascript:void(0);" target="_blank" class="por_zan fr">500</a></p>
</div>
<div class="cl"></div>
</li>
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_users_img"/></a>
<div class="por_news_txt fl">
<p class="por_news_p fl">
<a href="javascript:void(0);" target="_blank" class=" por_hot_name fl"> 叮当叮当叮当叮当 </a><span class="fl">&nbsp;:&nbsp;</span>
Trustie社区新版上线了必须支持一下比以前好用很多了。Trustie社区新版上线了必须支持一下比以前好用很多了...
</p>
<p><span class="por_time fl">1分钟前 </span><a href="javascript:void(0);" target="_blank" class="por_zan fr">500</a></p>
</div>
<div class="cl"></div>
</li>
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_users_img"/></a>
<div class="por_news_txt fl">
<p class="por_news_p fl">
<a href="javascript:void(0);" target="_blank" class=" por_hot_name fl"> 当叮当 </a><span class="fl">&nbsp;:&nbsp;</span>
Trustie社区新版上线了必须支持一下比以前好用很多了。Trustie社区新版上线了必须支持一下比以前好用很多了...
</p>
<p><span class="por_time fl">1分钟前 </span><a href="javascript:void(0);" target="_blank" class="por_zan fr">500</a></p>
</div>
<div class="cl"></div>
</li>
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_users_img"/></a>
<div class="por_news_txt fl">
<p class="por_news_p fl">
<a href="javascript:void(0);" target="_blank" class=" por_hot_name fl"> 叮当叮当叮当叮当 </a><span class="fl">&nbsp;:&nbsp;</span>
Trustie社区新版上线了必须支持一下很多了...
</p>
<p><span class="por_time fl">1分钟前 </span><a href="javascript:void(0);" target="_blank" class="por_zan fr">500</a></p>
</div>
<div class="cl"></div>
</li>
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_users_img"/></a>
<div class="por_news_txt fl">
<p class="por_news_p fl">
<a href="javascript:void(0);" target="_blank" class=" por_hot_name fl"> 叮当叮当叮当叮当 </a><span class="fl">&nbsp;:&nbsp;</span>
Trustie社区新版上线了必须支持一下比以前好用很多了。Trustie社区新版上线了必须支持一下比以前好用很多了...
</p>
<p><span class="por_time fl">1分钟前 </span><a href="javascript:void(0);" target="_blank" class="por_zan fr">500</a></p>
</div>
<div class="cl"></div>
</li>
</ul>
<% end %>
</div><!--por_news end-->

View File

@ -1,8 +1,16 @@
<p class="<%= cl %>" id="activity_description_<%= user_activity_id %>">
<% if cl.nil? %>
<span class="<%= cl %>" id="activity_description_<%= user_activity_id %>">
<span id="intro_content_<%= user_activity_id%>">
<%= content.to_s.html_safe%>
</span>
</p>
</span>
<% else %>
<p class="<%= cl %>" id="activity_description_<%= user_activity_id %>">
<span id="intro_content_<%= user_activity_id%>">
<%= content.to_s.html_safe%>
</span>
</p>
<% end %>
<script type="text/javascript">
$("#intro_content_<%= user_activity_id %>").hide();

View File

@ -54,7 +54,7 @@ a.por_hidden_w270{ display:block; width:280px; overflow:hidden; white-space: now
.por_news_list li{ padding:15px 0; border-bottom:1px dashed #e8e5e5;}
.por_users_img{ width:40px; height:40px; border:1px solid #e8e5e5;}
.por_news_txt{ width:245px; margin-left:10px;}
.por_news_p{ line-height:20px;max-height:40px;overflow:hidden;text-overflow:ellipsis; }
.por_news_p{ line-height:20px;max-height:40px;min-width:240px;overflow:hidden;text-overflow:ellipsis; }
a.por_zan{ background:url(../images/org_custom/icons_por.png) 0 -41px no-repeat; height:15px; width:20px; display:block; padding-left:15px; line-height:20px; color:#999;}
a.por_zan:hover{background:url(../images/org_custom/icons_por.png) -34px -42px no-repeat; color:#3b94d6; }
.por_hidden_w205{ font-size:14px; display:block; width:205px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;}