Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into sw_new_course
This commit is contained in:
commit
167d001b3f
|
@ -16,7 +16,7 @@ class OrgMemberController < ApplicationController
|
||||||
member_ids = params[:membership][:user_ids]
|
member_ids = params[:membership][:user_ids]
|
||||||
role_id = params[:orgRole]
|
role_id = params[:orgRole]
|
||||||
member_ids.each do |user_id|
|
member_ids.each do |user_id|
|
||||||
member = OrgMember.create(:user_id=>user_id)
|
member = OrgMember.create(:user_id=>user_id, :created_at => Time.now)
|
||||||
@org.org_members << member
|
@org.org_members << member
|
||||||
OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id)
|
OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,22 +55,22 @@ class OrganizationsController < ApplicationController
|
||||||
def show
|
def show
|
||||||
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
|
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
|
||||||
@organization = Organization.find(params[:id])
|
@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
|
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_activities = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and container_id in (#{project_ids.join(',')}))",
|
||||||
@org_project_activties_count = ForgeActivity.where('project_id in (?)',project_ids.join(',')).count
|
@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
|
#@org_activities = paginateHelper @org_activities, 10
|
||||||
@page = params[:page]
|
@page = params[:page]
|
||||||
else
|
|
||||||
render_403
|
|
||||||
end
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
render_403
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
|
@ -1918,6 +1918,20 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
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
|
private
|
||||||
|
|
||||||
def find_user
|
def find_user
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ForgeActivity < ActiveRecord::Base
|
||||||
validates :forge_act_id,presence: true
|
validates :forge_act_id,presence: true
|
||||||
validates :forge_act_type, presence: true
|
validates :forge_act_type, presence: true
|
||||||
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
|
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
|
before_destroy :destroy_user_activity
|
||||||
|
|
||||||
#在个人动态里面增加当前动态
|
#在个人动态里面增加当前动态
|
||||||
|
@ -45,6 +45,16 @@ class ForgeActivity < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
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
|
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 = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'")
|
||||||
user_activity.destroy_all
|
user_activity.destroy_all
|
||||||
|
|
|
@ -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) %> 创建了 <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>
|
|
@ -5,7 +5,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="st_list" style="width: 720px;">
|
<div class="st_list" style="width: 720px;">
|
||||||
<div class="st_box">
|
<div class="st_box">
|
||||||
<!--<span class="fr fb fontGrey3">加入时间</span>-->
|
<span class="fr fb fontGrey3">加入时间</span>
|
||||||
<div class="cl"></div><!--st_box_top end-->
|
<div class="cl"></div><!--st_box_top end-->
|
||||||
|
|
||||||
<% members.each do |member| %>
|
<% members.each do |member| %>
|
||||||
|
@ -16,6 +16,9 @@
|
||||||
<span class="fl ml10 c_grey"><%= l(:label_username)%></span>
|
<span class="fl ml10 c_grey"><%= l(:label_username)%></span>
|
||||||
<%= link_to(member.user.show_name, user_path(member.user),:class => "ml5 c_blue02") %><br />
|
<%= link_to(member.user.show_name, user_path(member.user),:class => "ml5 c_blue02") %><br />
|
||||||
<span class="fl c_grey ml10">身份:<%= member.user.admin_of_org?(organization)?"组织管理员":"组织成员" %></span>
|
<span class="fl c_grey ml10">身份:<%= member.user.admin_of_org?(organization)?"组织管理员":"组织成员" %></span>
|
||||||
|
<% if member.created_at %>
|
||||||
|
<span class="fr c_grey"><%= format_time(member.created_at) %></span>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<% end%>
|
<% end%>
|
||||||
|
|
|
@ -30,49 +30,15 @@
|
||||||
init_activity_KindEditor_data(<%= @organization.home_id%>, null, "87%");
|
init_activity_KindEditor_data(<%= @organization.home_id%>, null, "87%");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id} %>
|
<%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% unless @org_activities.nil? %>
|
<%= render :partial => 'organizations/org_activities',
|
||||||
<% @org_activities.each do |act| %>
|
:locals => {:org_activities =>@org_activities,
|
||||||
<% 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) %> 创建了 <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,
|
:page=>@page,
|
||||||
:org => @organization,
|
:org => @organization,
|
||||||
:org_act_count=>@org_activities.count,
|
:org_act_count=>@org_activities.count}%>
|
||||||
:pro_act_count=>@org_project_activties.count}%>
|
|
||||||
<%# end %>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'organizations/org_project_activities',
|
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'organizations/org_activities',
|
||||||
:locals => {:org_project_activties =>@org_project_activties,
|
:locals => {:org_activities =>@org_activities,
|
||||||
:page=>@page,
|
:page=>@page,
|
||||||
:org => @organization,
|
:org => @organization,
|
||||||
:org_act_count=>@org_activities.count,
|
:org_act_count=>@org_activities.count} )%>");
|
||||||
:pro_act_count=>@org_project_activties.count} )%>");
|
|
||||||
|
|
||||||
|
|
|
@ -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>
|
|
@ -0,0 +1 @@
|
||||||
|
<%= render :partial => 'show_user_org', :locals => {:orgs => @orgs} %>
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
//$("#org_list").replaceWith("<%#= escape_javascript(render :partial => 'show_user_org', :locals => {:orgs => @orgs}) %>")
|
|
@ -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' %>
|
<%#= stylesheet_link_tag 'pleft','prettify','jquery/jquery-ui-1.9.2','header','new_user','repository','org' %>
|
||||||
<div class="homepageContentContainer">
|
<div class="homepageContentContainer">
|
||||||
<div class="homepageContent">
|
<div class="homepageContent">
|
||||||
|
@ -6,12 +6,15 @@
|
||||||
<div class="postBanner" style="padding-bottom:5px;">
|
<div class="postBanner" style="padding-bottom:5px;">
|
||||||
<span class="linkGrey2 f16">组织列表</span>
|
<span class="linkGrey2 f16">组织列表</span>
|
||||||
|
|
||||||
<!--<form class="resourcesSearchloadBox" style="float:right; margin-top:-5px;">-->
|
<%= 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="serach" placeholder="输入关键词进行搜索" class="searchResource"/>-->
|
<input type="text" name="search_orgs" placeholder="输入关键词进行搜索" class="problem_search_input fl"/>
|
||||||
<!--<a href="javascript:void(0);" class="homepageSearchIcon"></a>-->
|
|
||||||
<!--</form>-->
|
<!--<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 class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="org_list">
|
||||||
<% @orgs.each do |org| %>
|
<% @orgs.each do |org| %>
|
||||||
<div class="postRow">
|
<div class="postRow">
|
||||||
<div class="postPortrait">
|
<div class="postPortrait">
|
||||||
|
@ -32,4 +35,5 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -456,6 +456,7 @@ RedmineApp::Application.routes.draw do
|
||||||
get 'dealwith_apply_request'
|
get 'dealwith_apply_request'
|
||||||
get 'store_selected_resource'
|
get 'store_selected_resource'
|
||||||
get 'user_organizations'
|
get 'user_organizations'
|
||||||
|
get 'search_user_orgs'
|
||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
#resources :blogs
|
#resources :blogs
|
||||||
|
|
|
@ -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
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddCreatedAtToOrgMembers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :org_members, :created_at, :timestamp
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,13 @@
|
||||||
|
class SetTimeForOrgMember < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
OrgMember.all.each do |member|
|
||||||
|
if(member.created_at.nil?)
|
||||||
|
member.created_at = Time.now - 5.days
|
||||||
|
member.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue