diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
index b75742164..6a1030adc 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/organizations_controller.rb
@@ -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
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 273d48ccf..776e6b7d5 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -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
diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb
index c4f13c6d0..8a94f1019 100644
--- a/app/models/forge_activity.rb
+++ b/app/models/forge_activity.rb
@@ -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
diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb
new file mode 100644
index 000000000..cb69738b6
--- /dev/null
+++ b/app/views/organizations/_org_activities.html.erb
@@ -0,0 +1,56 @@
+<% unless org_activities.nil? %>
+ <% org_activities.each do |act| %>
+ <% if act.container_type == 'Organization' %>
+ <% if act.org_act_type == 'CreateOrganization' %>
+
+ <% end %>
+ <% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %>
+
+ <%= 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 %>
+
+ <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
+
+<% end %>
+
+<% if org_act_count == 10 %>
+ 展开更多<%=link_to "", organization_path(org,:page => page.to_i + 1),:id => "more_org_activities_link",:remote => "true",:class => "none" %>
+ <%#= link_to "点击展开更多",user_activities_path(@user.id,:type => type,:page => page),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%>
+<% end%>
+
+
\ No newline at end of file
diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb
index 0b624d479..a85ffa687 100644
--- a/app/views/organizations/show.html.erb
+++ b/app/views/organizations/show.html.erb
@@ -30,49 +30,15 @@
init_activity_KindEditor_data(<%= @organization.home_id%>, null, "87%");
});
-
<%= 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' %>
-
- <% end %>
- <% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %>
-
- <%= render :partial => 'show_org_document', :locals => {:document => act.org_act} %>
- <% end %>
- <% end %>
-
- <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
-
- <% end %>
+<%= render :partial => 'organizations/org_activities',
+ :locals => {:org_activities =>@org_activities,
+ :page=>@page,
+ :org => @organization,
+ :org_act_count=>@org_activities.count}%>
- <%# @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 %>
diff --git a/app/views/organizations/show.js.erb b/app/views/organizations/show.js.erb
index b0a447910..ee405d73c 100644
--- a/app/views/organizations/show.js.erb
+++ b/app/views/organizations/show.js.erb
@@ -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} )%>");
diff --git a/app/views/users/_show_user_org.html.erb b/app/views/users/_show_user_org.html.erb
new file mode 100644
index 000000000..e753092fa
--- /dev/null
+++ b/app/views/users/_show_user_org.html.erb
@@ -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' %>
+
+
+
+
+
组织列表
+
+ <%= 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 %>
+
+
+
+
搜索
+ <% end %>
+
+
+
+ <% orgs.each do |org| %>
+
+
+ <%= link_to image_tag(url_to_avatar(org), :width => '78', :height => '78', :alt => '组织logo'), organization_path(org), :class => "linkGrey2" %>
+
+
+
+ <%= link_to org.name, organization_path(org), :class => 'f16 linkBlue' %>
+
+
<%= org.description %>
+
创建者:<%= link_to User.find(org.creator_id), user_path(org.creator_id), :class => 'linkGrey2', :target => '_blank' %>
+
创建时间:<%= format_activity_day(org.created_at) %> <%= format_time(org.created_at, false) %>
+
您的身份:<%= User.current.admin_of_org?(org) ? "组织管理员" : "组织成员" %>
+
+
+
+
+ <% end %>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/users/search_user_orgs.html.erb b/app/views/users/search_user_orgs.html.erb
new file mode 100644
index 000000000..1a921d38e
--- /dev/null
+++ b/app/views/users/search_user_orgs.html.erb
@@ -0,0 +1 @@
+<%= render :partial => 'show_user_org', :locals => {:orgs => @orgs} %>
\ No newline at end of file
diff --git a/app/views/users/search_user_orgs.js.erb b/app/views/users/search_user_orgs.js.erb
new file mode 100644
index 000000000..7184a29c5
--- /dev/null
+++ b/app/views/users/search_user_orgs.js.erb
@@ -0,0 +1,2 @@
+
+//$("#org_list").replaceWith("<%#= escape_javascript(render :partial => 'show_user_org', :locals => {:orgs => @orgs}) %>")
\ No newline at end of file
diff --git a/app/views/users/user_organizations.html.erb b/app/views/users/user_organizations.html.erb
index 50fa03bbe..e2a24b2aa 100644
--- a/app/views/users/user_organizations.html.erb
+++ b/app/views/users/user_organizations.html.erb
@@ -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' %>
@@ -6,30 +6,34 @@
组织列表
-
-
-
-
+ <%= 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 %>
+
+
+
+
搜索
+ <% end %>
- <% @orgs.each do |org| %>
-
-
- <%= link_to image_tag(url_to_avatar(org), :width => '78', :height => '78', :alt => '组织logo'), organization_path(org), :class => "linkGrey2" %>
-
-
-
- <%= link_to org.name, organization_path(org), :class => 'f16 linkBlue' %>
+
+ <% @orgs.each do |org| %>
+
+
+ <%= link_to image_tag(url_to_avatar(org), :width => '78', :height => '78', :alt => '组织logo'), organization_path(org), :class => "linkGrey2" %>
-
<%= org.description %>
-
创建者:<%= link_to User.find(org.creator_id), user_path(org.creator_id), :class => 'linkGrey2', :target => '_blank' %>
-
创建时间:<%= format_activity_day(org.created_at) %> <%= format_time(org.created_at, false) %>
-
您的身份:<%= User.current.admin_of_org?(org) ? "组织管理员" : "组织成员" %>
+
+
+ <%= link_to org.name, organization_path(org), :class => 'f16 linkBlue' %>
+
+
<%= org.description %>
+
创建者:<%= link_to User.find(org.creator_id), user_path(org.creator_id), :class => 'linkGrey2', :target => '_blank' %>
+
创建时间:<%= format_activity_day(org.created_at) %> <%= format_time(org.created_at, false) %>
+
您的身份:<%= User.current.admin_of_org?(org) ? "组织管理员" : "组织成员" %>
+
+
+
-
-
-
- <% end %>
+ <% end %>
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 0f05c3521..69134e666 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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
diff --git a/db/migrate/20151116020842_copy_forge_activities_to_org_activities.rb b/db/migrate/20151116020842_copy_forge_activities_to_org_activities.rb
new file mode 100644
index 000000000..95c4ed5bf
--- /dev/null
+++ b/db/migrate/20151116020842_copy_forge_activities_to_org_activities.rb
@@ -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