1.将项目动态数据迁移至组织动态;

2.在组织动态中,按时间倒排显示组织动态;
3.增加我的组织中搜索功能。
This commit is contained in:
ouyangxuhua 2015-11-16 15:02:57 +08:00
parent f5460d1126
commit de32745eef
12 changed files with 184 additions and 76 deletions

View File

@ -55,22 +55,22 @@ class OrganizationsController < ApplicationController
def show
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@organization = Organization.find(params[:id])
@org_activities = OrgActivity.where('container_id =? and container_type =? ',
@organization.id, 'Organization ').order('updated_at desc').page(params[:page]).per(10)
@org_activities_count = OrgActivity.where('container_id =? and container_type =? ',
@organization.id, 'Organization ').order('updated_at desc').count
project_ids = @organization.projects.map(&:id) << 0
@org_project_activties = ForgeActivity.where("project_id in (#{project_ids.join(',')}) and forge_act_type in('Issue','Message','ProjectCreateInfo')").order("updated_at desc").page(params[:page] || 1).per(10)
@org_project_activties_count = ForgeActivity.where('project_id in (?)',project_ids.join(',')).count
@org_activities = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and container_id in (#{project_ids.join(',')}))",
@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
@org_activities_count = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and container_id in (#{project_ids.join(',')}))" ,
@organization.id, 'Organization ').count
# @org_project_activties = ForgeActivity.where("project_id in (#{project_ids.join(',')}) and forge_act_type in('Issue','Message','ProjectCreateInfo')").order("updated_at desc").page(params[:page] || 1).per(10)
# @org_project_activties_count = ForgeActivity.where('project_id in (?)',project_ids.join(',')).count
#@org_activities = paginateHelper @org_activities, 10
@page = params[:page]
respond_to do |format|
format.html
format.js
end
else
render_403
end
respond_to do |format|
format.html
format.js
end
end
def update

View File

@ -1918,6 +1918,20 @@ class UsersController < ApplicationController
end
end
def search_user_orgs
name=""
if !params[:search_orgs].nil?
name = params[:search_orgs].strip
end
name = "%"+name+"%"
@orgs = User.current.organizations.where("name like ?", name)
@user = User.current
respond_to do |format|
format.html {render :layout => 'static_base'}
format.js
end
end
private
def find_user

View File

@ -20,7 +20,7 @@ class ForgeActivity < ActiveRecord::Base
validates :forge_act_id,presence: true
validates :forge_act_type, presence: true
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
after_save :add_user_activity
after_save :add_user_activity, :add_org_activity
before_destroy :destroy_user_activity
#在个人动态里面增加当前动态
@ -45,6 +45,16 @@ class ForgeActivity < ActiveRecord::Base
end
end
def add_org_activity
OrgActivity.create(:user_id => self.user_id,
:org_act_id => self.forge_act_id,
:org_act_type => self.forge_act_type,
:container_id => self.project_id,
:container_type => 'Project',
:created_at => self.created_at,
:updated_at => self.updated_at)
end
def destroy_user_activity
user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'")
user_activity.destroy_all

View File

@ -0,0 +1,56 @@
<% unless org_activities.nil? %>
<% org_activities.each do |act| %>
<% if act.container_type == 'Organization' %>
<% if act.org_act_type == 'CreateOrganization' %>
<div class="resources mt10">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<a href="javascript:void(0);"><%= image_tag(url_to_avatar(User.find(act.user_id)), :width => "45", :height => "45") %></a>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo"><%= link_to User.find(act.user_id), user_path(act.user_id) %>&nbsp;&nbsp;创建了 <a href="<%= organization_path(@organization)%>" class="newsBlue ml10"><%= Organization.find(act.org_act_id).name %>
| 组织</a></div>
<div class="homepagePostDate"> 创建时间:<%= format_activity_day(act.created_at) %> <%= format_time(act.created_at, false) %> </div>
</div>
<div class="cl"></div>
</div>
</div>
<% end %>
<% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %>
<script>
$(function() {
init_activity_KindEditor_data(<%= act.org_act.id%>, null, "87%");
});
</script>
<%= render :partial => 'show_org_document', :locals => {:document => act.org_act} %>
<% end %>
<% end %>
<% if act.container_type == 'Project' %>
<% case act.org_act_type.to_s %>
<% when 'Issue' %>
<%= render :partial => 'organizations/org_project_issue', :locals => {:activity => Issue.find(act.org_act_id),:user_activity_id =>act.id} %>
<% when 'Message' %>
<%= render :partial => 'organizations/project_message', :locals => {:activity => Message.find(act.org_act_id),:user_activity_id =>act.id} %>
<%# when 'ProjectCreateInfo'%>
<%#= render :partial => 'organizations/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %>
<% end %>
<% end %>
<% end %>
<!--<ul class="wlist" style=" border:none; padding-top: 15px;">-->
<%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
<!--</ul>-->
<% end %>
<% if org_act_count == 10 %>
<div id="show_more_activities" class="loadMore mt10 f_grey">展开更多<%=link_to "", organization_path(org,:page => page.to_i + 1),:id => "more_org_activities_link",:remote => "true",:class => "none" %></div>
<%#= link_to "点击展开更多",user_activities_path(@user.id,:type => type,:page => page),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%>
<% end%>
<script>
$(function(){
$("#show_more_activities").mouseover(function(){
$("#more_org_activities_link").click();
})
})
</script>

View File

@ -30,49 +30,15 @@
init_activity_KindEditor_data(<%= @organization.home_id%>, null, "87%");
});
</script>
<%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id} %>
<% end %>
<% unless @org_activities.nil? %>
<% @org_activities.each do |act| %>
<% if act.org_act_type == 'CreateOrganization' %>
<div class="resources mt10">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<a href="javascript:void(0);"><%= image_tag(url_to_avatar(User.find(act.user_id)), :width => "45", :height => "45") %></a>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo"><%= link_to User.find(act.user_id), user_path(act.user_id) %>&nbsp;&nbsp;创建了 <a href="<%= organization_path(@organization)%>" class="newsBlue ml10"><%= Organization.find(act.org_act_id).name %>
| 组织</a></div>
<div class="homepagePostDate"> 创建时间:<%= format_activity_day(act.created_at) %> <%= format_time(act.created_at, false) %> </div>
</div>
<div class="cl"></div>
</div>
</div>
<% end %>
<% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %>
<script>
$(function() {
init_activity_KindEditor_data(<%= act.org_act.id%>, null, "87%");
});
</script>
<%= render :partial => 'show_org_document', :locals => {:document => act.org_act} %>
<% end %>
<% end %>
<!--<ul class="wlist" style=" border:none; padding-top: 15px;">-->
<%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
<!--</ul>-->
<% end %>
<%# @org_project_activties.each do |org_act|%>
<%= render :partial => 'organizations/org_project_activities',
:locals => {:org_project_activties =>@org_project_activties,
:page=>@page,
:org => @organization,
:org_act_count=>@org_activities.count,
:pro_act_count=>@org_project_activties.count}%>
<%# end %>
<%= render :partial => 'organizations/org_activities',
:locals => {:org_activities =>@org_activities,
:page=>@page,
:org => @organization,
:org_act_count=>@org_activities.count}%>

View File

@ -1,7 +1,6 @@
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'organizations/org_project_activities',
:locals => {:org_project_activties =>@org_project_activties,
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'organizations/org_activities',
:locals => {:org_activities =>@org_activities,
:page=>@page,
:org => @organization,
:org_act_count=>@org_activities.count,
:pro_act_count=>@org_project_activties.count} )%>");
:org_act_count=>@org_activities.count} )%>");

View File

@ -0,0 +1,39 @@
<%= stylesheet_link_tag 'pleft','header','new_user','repository','org', 'project' %>
<%#= stylesheet_link_tag 'pleft','prettify','jquery/jquery-ui-1.9.2','header','new_user','repository','org' %>
<div class="homepageContentContainer">
<div class="homepageContent">
<div class="postContainer">
<div class="postBanner" style="padding-bottom:5px;">
<span class="linkGrey2 f16">组织列表</span>
<%= form_tag url_for(:controller => 'users', :action => 'search_user_orgs', :id => User.current.id), :method => 'get', :id => "search_org_form", :class=>"resourcesSearchloadBox", :style=>"float:right; margin-top:-5px;" do %>
<input type="text" name="search_orgs" placeholder="输入关键词进行搜索" class="problem_search_input fl"/>
<!--<a href="javascript:void(0);" class="homepageSearchIcon" onclick="$('#search_org_form').submit();"></a>-->
<a href="javascript:void(0);" class="problem_search_btn fl" onclick="$('#search_org_form').submit();">搜索</a>
<% end %>
<div class="cl"></div>
</div>
<div id="org_list">
<% orgs.each do |org| %>
<div class="postRow">
<div class="postPortrait">
<%= link_to image_tag(url_to_avatar(org), :width => '78', :height => '78', :alt => '组织logo'), organization_path(org), :class => "linkGrey2" %>
</div>
<div class="orgWrap">
<div class="orgTitle">
<%= link_to org.name, organization_path(org), :class => 'f16 linkBlue' %>
</div>
<div class="orgIntro"><%= org.description %></div>
<div class="postCreater">创建者:<%= link_to User.find(org.creator_id), user_path(org.creator_id), :class => 'linkGrey2', :target => '_blank' %></div>
<div class="postDate fl mr40">创建时间:<%= format_activity_day(org.created_at) %> <%= format_time(org.created_at, false) %></div>
<div class="postCreater">您的身份:<%= User.current.admin_of_org?(org) ? "组织管理员" : "组织成员" %></div>
</div>
<!--<div class="mt28 fr"><a href="javascript:void(0);" class="linkGrey5">申请加入</a></div>-->
<div class="cl"></div>
</div>
<% end %>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1 @@
<%= render :partial => 'show_user_org', :locals => {:orgs => @orgs} %>

View File

@ -0,0 +1,2 @@
//$("#org_list").replaceWith("<%#= escape_javascript(render :partial => 'show_user_org', :locals => {:orgs => @orgs}) %>")

View File

@ -1,4 +1,4 @@
<%= stylesheet_link_tag 'pleft','header','new_user','repository','org' %>
<%= stylesheet_link_tag 'pleft','header','new_user','repository','org', 'project' %>
<%#= stylesheet_link_tag 'pleft','prettify','jquery/jquery-ui-1.9.2','header','new_user','repository','org' %>
<div class="homepageContentContainer">
<div class="homepageContent">
@ -6,30 +6,34 @@
<div class="postBanner" style="padding-bottom:5px;">
<span class="linkGrey2 f16">组织列表</span>
<!--<form class="resourcesSearchloadBox" style="float:right; margin-top:-5px;">-->
<!--<input type="text" name="serach" placeholder="输入关键词进行搜索" class="searchResource"/>-->
<!--<a href="javascript:void(0);" class="homepageSearchIcon"></a>-->
<!--</form>-->
<%= form_tag url_for(:controller => 'users', :action => 'search_user_orgs', :id => User.current.id), :method => 'get', :id => "search_org_form", :class=>"resourcesSearchloadBox", :style=>"float:right; margin-top:-5px;" do %>
<input type="text" name="search_orgs" placeholder="输入关键词进行搜索" class="problem_search_input fl"/>
<!--<a href="javascript:void(0);" class="homepageSearchIcon" onclick="$('#search_org_form').submit();"></a>-->
<a href="javascript:void(0);" class="problem_search_btn fl" onclick="$('#search_org_form').submit();">搜索</a>
<% end %>
<div class="cl"></div>
</div>
<% @orgs.each do |org| %>
<div class="postRow">
<div class="postPortrait">
<%= link_to image_tag(url_to_avatar(org), :width => '78', :height => '78', :alt => '组织logo'), organization_path(org), :class => "linkGrey2" %>
</div>
<div class="orgWrap">
<div class="orgTitle">
<%= link_to org.name, organization_path(org), :class => 'f16 linkBlue' %>
<div id="org_list">
<% @orgs.each do |org| %>
<div class="postRow">
<div class="postPortrait">
<%= link_to image_tag(url_to_avatar(org), :width => '78', :height => '78', :alt => '组织logo'), organization_path(org), :class => "linkGrey2" %>
</div>
<div class="orgIntro"><%= org.description %></div>
<div class="postCreater">创建者:<%= link_to User.find(org.creator_id), user_path(org.creator_id), :class => 'linkGrey2', :target => '_blank' %></div>
<div class="postDate fl mr40">创建时间:<%= format_activity_day(org.created_at) %> <%= format_time(org.created_at, false) %></div>
<div class="postCreater">您的身份:<%= User.current.admin_of_org?(org) ? "组织管理员" : "组织成员" %></div>
<div class="orgWrap">
<div class="orgTitle">
<%= link_to org.name, organization_path(org), :class => 'f16 linkBlue' %>
</div>
<div class="orgIntro"><%= org.description %></div>
<div class="postCreater">创建者:<%= link_to User.find(org.creator_id), user_path(org.creator_id), :class => 'linkGrey2', :target => '_blank' %></div>
<div class="postDate fl mr40">创建时间:<%= format_activity_day(org.created_at) %> <%= format_time(org.created_at, false) %></div>
<div class="postCreater">您的身份:<%= User.current.admin_of_org?(org) ? "组织管理员" : "组织成员" %></div>
</div>
<!--<div class="mt28 fr"><a href="javascript:void(0);" class="linkGrey5">申请加入</a></div>-->
<div class="cl"></div>
</div>
<!--<div class="mt28 fr"><a href="javascript:void(0);" class="linkGrey5">申请加入</a></div>-->
<div class="cl"></div>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
</div>

View File

@ -444,6 +444,7 @@ RedmineApp::Application.routes.draw do
get 'dealwith_apply_request'
get 'store_selected_resource'
get 'user_organizations'
get 'search_user_orgs'
# end
end
#resources :blogs

View File

@ -0,0 +1,16 @@
class CopyForgeActivitiesToOrgActivities < ActiveRecord::Migration
def up
ForgeActivity.all.each do |forge_act|
OrgActivity.create(:user_id => forge_act.user_id,
:org_act_id => forge_act.forge_act_id,
:org_act_type => forge_act.forge_act_type,
:container_id => forge_act.project_id,
:container_type => 'Project',
:created_at => forge_act.created_at,
:updated_at => forge_act.updated_at)
end
end
def down
end
end