修改新建项目显示,优化列表显示速度
This commit is contained in:
parent
edf2d39a06
commit
c00575ce84
|
@ -14,7 +14,6 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class MembersController < ApplicationController
|
class MembersController < ApplicationController
|
||||||
model_object Member
|
model_object Member
|
||||||
before_filter :find_model_object, :except => [:index, :create, :autocomplete]
|
before_filter :find_model_object, :except => [:index, :create, :autocomplete]
|
||||||
|
@ -22,7 +21,6 @@ class MembersController < ApplicationController
|
||||||
before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete]
|
before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete]
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
accept_api_auth :index, :show, :create, :update, :destroy
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@offset, @limit = api_offset_and_limit
|
@offset, @limit = api_offset_and_limit
|
||||||
@member_count = @project.member_principals.count
|
@member_count = @project.member_principals.count
|
||||||
|
@ -49,17 +47,32 @@ class MembersController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
members = []
|
members = []
|
||||||
|
project_info = []
|
||||||
if params[:membership]
|
if params[:membership]
|
||||||
if params[:membership][:user_ids]
|
if params[:membership][:user_ids]
|
||||||
attrs = params[:membership].dup
|
attrs = params[:membership].dup
|
||||||
user_ids = attrs.delete(:user_ids)
|
user_ids = attrs.delete(:user_ids)
|
||||||
user_ids.each do |user_id|
|
user_ids.each do |user_id|
|
||||||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
||||||
|
## added by nie
|
||||||
|
if params[:membership][:role_ids][0] == "3"
|
||||||
|
project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id)
|
||||||
|
# ProjectInfo.create(:name => "test", :user_id => 123)
|
||||||
|
end
|
||||||
|
## end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
|
||||||
|
## added by nie
|
||||||
|
if params[:membership][:role_ids][0] == "3"
|
||||||
|
project_info << Project_info.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
|
||||||
|
end
|
||||||
|
## end
|
||||||
end
|
end
|
||||||
@project.members << members
|
@project.members << members
|
||||||
|
# added by nie
|
||||||
|
@project.project_infos << project_info
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -79,7 +92,21 @@ class MembersController < ApplicationController
|
||||||
def update
|
def update
|
||||||
if params[:membership]
|
if params[:membership]
|
||||||
@member.role_ids = params[:membership][:role_ids]
|
@member.role_ids = params[:membership][:role_ids]
|
||||||
|
|
||||||
|
#added by nie
|
||||||
|
if params[:membership][:role_ids][0] == "3"
|
||||||
|
@projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id)
|
||||||
|
@projectInfo.save
|
||||||
|
else
|
||||||
|
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
||||||
|
if user_admin.size > 0
|
||||||
|
user_admin.each do |user|
|
||||||
|
user.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
saved = @member.save
|
saved = @member.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to_settings_in_projects }
|
format.html { redirect_to_settings_in_projects }
|
||||||
|
@ -96,7 +123,13 @@ class MembersController < ApplicationController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if request.delete? && @member.deletable?
|
if request.delete? && @member.deletable?
|
||||||
@member.destroy
|
@member.destroy
|
||||||
|
end
|
||||||
|
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
||||||
|
if user_admin.size > 0
|
||||||
|
user_admin.each do |user|
|
||||||
|
user.destroy
|
||||||
|
end
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to_settings_in_projects }
|
format.html { redirect_to_settings_in_projects }
|
||||||
|
|
|
@ -50,7 +50,6 @@ class ProjectsController < ApplicationController
|
||||||
helper :members
|
helper :members
|
||||||
helper :activities
|
helper :activities
|
||||||
helper :documents
|
helper :documents
|
||||||
|
|
||||||
helper :watchers
|
helper :watchers
|
||||||
|
|
||||||
### added by william
|
### added by william
|
||||||
|
@ -85,8 +84,18 @@ class ProjectsController < ApplicationController
|
||||||
# @project_pages = Paginator.new @project_count, @limit, params['page']
|
# @project_pages = Paginator.new @project_count, @limit, params['page']
|
||||||
# @offset ||= @project_pages.offset
|
# @offset ||= @project_pages.offset
|
||||||
# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
||||||
|
|
||||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||||
@projects = Project.visible
|
@projects = Project.visible
|
||||||
|
# @projects.each do |project|
|
||||||
|
# @admin = project.users_by_role[Role.find(3)]
|
||||||
|
# unless @admin.nil?
|
||||||
|
# @admin.each do |user|
|
||||||
|
# ProjectInfo.create(:user_id => user.id, :project_id => project.id)
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# end
|
||||||
|
# end
|
||||||
@projects = Project.visible.like(params[:name]) if params[:name].present?
|
@projects = Project.visible.like(params[:name]) if params[:name].present?
|
||||||
@project_count = @projects.count
|
@project_count = @projects.count
|
||||||
@project_pages = Paginator.new @project_count, @limit, params['page']
|
@project_pages = Paginator.new @project_count, @limit, params['page']
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
class TagsController < ApplicationController
|
class TagsController < ApplicationController
|
||||||
|
|
||||||
before_filter :require_admin,:only => :show
|
before_filter :require_admin,:only => :show
|
||||||
|
|
||||||
include ProjectsHelper
|
include ProjectsHelper
|
||||||
include IssuesHelper
|
include IssuesHelper
|
||||||
include UsersHelper
|
include UsersHelper
|
||||||
|
@ -10,7 +9,6 @@ class TagsController < ApplicationController
|
||||||
|
|
||||||
$selected_tags = Array.new
|
$selected_tags = Array.new
|
||||||
$related_tags = Array.new
|
$related_tags = Array.new
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
||||||
$selected_tags = []
|
$selected_tags = []
|
||||||
|
@ -26,17 +24,13 @@ class TagsController < ApplicationController
|
||||||
@users_results = get_users_by_tag($selected_tags)
|
@users_results = get_users_by_tag($selected_tags)
|
||||||
|
|
||||||
@obj_id = params[:obj_id]
|
@obj_id = params[:obj_id]
|
||||||
@show_flag = params[:object_flag]
|
case params[:object_flag]
|
||||||
|
|
||||||
case @show_flag
|
|
||||||
when '1' then
|
when '1' then
|
||||||
@obj = User.find_by_id(@obj_id)
|
@obj = User.find_by_id(@obj_id)
|
||||||
when '2' then
|
when '2' then
|
||||||
@obj = Project.find_by_id(@obj_id)
|
@obj = Project.find_by_id(@obj_id)
|
||||||
when '3' then
|
when '3' then
|
||||||
@obj = Issue.find_by_id(@obj_id)
|
@obj = Issue.find_by_id(@obj_id)
|
||||||
when '4' then
|
|
||||||
@obj = Bid.find_by_id(@obj_id)
|
|
||||||
else
|
else
|
||||||
@obj = nil
|
@obj = nil
|
||||||
end
|
end
|
||||||
|
@ -79,10 +73,5 @@ class TagsController < ApplicationController
|
||||||
def show
|
def show
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_all
|
|
||||||
@tags = ActsAsTaggableOn::Tag.find(:all)
|
|
||||||
@tags = @tags.to_a
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -51,6 +51,9 @@ class Project < ActiveRecord::Base
|
||||||
has_one :repository, :conditions => ["is_default = ?", true]
|
has_one :repository, :conditions => ["is_default = ?", true]
|
||||||
has_many :repositories, :dependent => :destroy
|
has_many :repositories, :dependent => :destroy
|
||||||
has_many :changesets, :through => :repository
|
has_many :changesets, :through => :repository
|
||||||
|
#ADDED BY NIE
|
||||||
|
has_many :project_infos, :dependent => :destroy
|
||||||
|
#end
|
||||||
has_one :wiki, :dependent => :destroy
|
has_one :wiki, :dependent => :destroy
|
||||||
# Custom field for the project issues
|
# Custom field for the project issues
|
||||||
has_and_belongs_to_many :issue_custom_fields,
|
has_and_belongs_to_many :issue_custom_fields,
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
class ProjectInfo < ActiveRecord::Base
|
||||||
|
attr_accessible :project_id, :user_id
|
||||||
|
|
||||||
|
belongs_to :project
|
||||||
|
belongs_to :user
|
||||||
|
validates_presence_of :project_id, :user_id
|
||||||
|
validates_uniqueness_of :project_id, :scope => :user_id
|
||||||
|
end
|
|
@ -85,6 +85,9 @@ class User < Principal
|
||||||
has_many :activities
|
has_many :activities
|
||||||
#####
|
#####
|
||||||
|
|
||||||
|
######added by nie
|
||||||
|
has_many :project_infos, :dependent => :destroy
|
||||||
|
#####
|
||||||
|
|
||||||
scope :logged, lambda { where("#{User.table_name}.status <> #{STATUS_ANONYMOUS}") }
|
scope :logged, lambda { where("#{User.table_name}.status <> #{STATUS_ANONYMOUS}") }
|
||||||
scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
|
scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
|
||||||
|
|
|
@ -26,10 +26,10 @@
|
||||||
<div class="add-info">
|
<div class="add-info">
|
||||||
<div class="main-language">
|
<div class="main-language">
|
||||||
<%= content_tag('span', "#{l(:default_role_manager)}: ") %>
|
<%= content_tag('span', "#{l(:default_role_manager)}: ") %>
|
||||||
<% @admin = @project.users_by_role[Role.find(3)]%>
|
<% @admin = @project.project_infos%>
|
||||||
<% unless @admin.nil?%>
|
<% if @admin.size > 0 %>
|
||||||
<%= content_tag('a', @admin.sort.collect{|u| link_to_user u}.join(", ").html_safe) %>
|
<%= content_tag('a', @admin.collect{|u| link_to(u.user.name, user_path(u.user_id))}.join(", ").html_safe) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="licences">
|
<div class="licences">
|
||||||
<%= content_tag('span', "#{l(:label_create_time)}: ") %><%= content_tag('span', format_time(@project.created_on)) %>
|
<%= content_tag('span', "#{l(:label_create_time)}: ") %><%= content_tag('span', format_time(@project.created_on)) %>
|
||||||
|
|
|
@ -2,13 +2,16 @@
|
||||||
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
|
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="contextual" style="padding-top:10px;padding-right:10px;">
|
|
||||||
<%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= form_tag(projects_path, :method => :get) do %>
|
<%= form_tag(projects_path, :method => :get) do %>
|
||||||
<div class="project-search-block">
|
<div class="project-search-block">
|
||||||
<span><%=l(:label_project_plural)%></span>
|
<span style="margin-left:0px"><%=l(:label_project_plural)%></span>
|
||||||
|
<span class="contextual" style="font-size: 12px; float: none; vertical-align: center; margin-left: 100px">
|
||||||
|
<%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %>
|
||||||
|
</span>
|
||||||
<div class="project-search">
|
<div class="project-search">
|
||||||
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
||||||
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
|
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
|
||||||
|
|
|
@ -1,21 +1,4 @@
|
||||||
<style type="text/css">
|
<div class="splitcontentleft">
|
||||||
.tags_left{
|
|
||||||
width: 30%;
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
.tags_right{
|
|
||||||
padding-top:18px;
|
|
||||||
width: 68%;
|
|
||||||
float:right;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script type="text/javascript" language="JavaScript">
|
|
||||||
function show_selector(var id){
|
|
||||||
$('.issues')
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="tags_left">
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
Selected Tags
|
Selected Tags
|
||||||
|
@ -32,18 +15,17 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tags_right">
|
<div class="splitcontentright">
|
||||||
<h2>Search Results</h2>
|
<h2>Search Results</h2>
|
||||||
<div id="filter-menu" align="right">
|
<div id="filter-menu" align="right">
|
||||||
<%= toggle_link "Project", 'projects' %> (<%= @users_tags_num %>) |
|
<%= link_to "Issue",:action => "index"%>(<%= @issues_tags_num %>)|
|
||||||
<%= toggle_link "User", 'users' %> (<%= @projects_tags_num %>)|
|
<%= link_to "Project",:action => "index"%>(<%= @projects_tags_num %>) |
|
||||||
<%= toggle_link "Issue", 'issues' %> (<%= @issues_tags_num %>)|
|
<%= link_to "User",:action => "index"%>(<%= @users_tags_num %>)
|
||||||
<%= link_to "Bid",:action => "index"%> ()|
|
|
||||||
<%= link_to "All",:action => "index"%> |
|
|
||||||
</div>
|
</div>
|
||||||
<div id="show_results">
|
<div id="show_results">
|
||||||
<!-- 显示规则 0 全部显示 1显示users 2显示projects 3显示issues 4显示需求-->
|
|
||||||
<%= render :partial => "tag_search_results",:locals => {:issues_results => @issues_results,
|
<%= render :partial => "tag_search_results",:locals => {:issues_results => @issues_results,
|
||||||
:projects_results => @projects_results,:users_results => @users_results,:show_flag => @show_flag } %>
|
:projects_results => @projects_results,:users_results => @users_results }%>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,9 @@
|
||||||
|
|
||||||
<div class="autoscroll">
|
<div class="autoscroll">
|
||||||
<% for user in @users -%>
|
<% for user in @users -%>
|
||||||
<div class="well">
|
<% unless user.id == 1%>
|
||||||
|
<div class="well">
|
||||||
|
|
||||||
<%= content_tag "p", "#{format_date(user.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
|
<%= content_tag "p", "#{format_date(user.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
|
||||||
<%= image_tag "/images/time_member.png", :class => "img_member_time"%>
|
<%= image_tag "/images/time_member.png", :class => "img_member_time"%>
|
||||||
<!-- <%= get_avatar?(user) ? (link_to image_tag(avatar_image(user), :class => 'avatar'), user_path(user), :class => "avatar") : (link_to image_tag("/images/12_50.png", :class => 'avatar'), user_path(user), :class => "avatar") %> -->
|
<!-- <%= get_avatar?(user) ? (link_to image_tag(avatar_image(user), :class => 'avatar'), user_path(user), :class => "avatar") : (link_to image_tag("/images/12_50.png", :class => 'avatar'), user_path(user), :class => "avatar") %> -->
|
||||||
|
@ -111,6 +113,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
<% end -%>
|
||||||
</div>
|
</div>
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -435,8 +435,8 @@ RedmineApp::Application.routes.draw do
|
||||||
|
|
||||||
match 'bids/:id', :controller => 'bids', :action => 'show', :as => 'respond'
|
match 'bids/:id', :controller => 'bids', :action => 'show', :as => 'respond'
|
||||||
|
|
||||||
|
######added by nie
|
||||||
|
match 'tags/show_projects_tags',:to => 'tags#show_projects_tags'
|
||||||
########### added by liuping
|
########### added by liuping
|
||||||
match 'tags/add_tag',:to => 'tags#add_tag',:as=>"add_tag"
|
match 'tags/add_tag',:to => 'tags#add_tag',:as=>"add_tag"
|
||||||
match 'tags/delete_tag',:to => 'tags#delete_tag',:as=>"add_tag"
|
match 'tags/delete_tag',:to => 'tags#delete_tag',:as=>"add_tag"
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
class CreateProjectInfos < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :project_infos do |t|
|
||||||
|
t.string :name
|
||||||
|
t.integer :project_id
|
||||||
|
t.integer :user_id
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
class DeleteNameFromProjectInfo < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
remove_column :project_infos, :name
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
add_column :project_infos, :name, :string
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue