|
|
@ -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 ProjectsController < ApplicationController
|
|
|
|
class ProjectsController < ApplicationController
|
|
|
|
layout 'base_projects'# by young
|
|
|
|
layout 'base_projects'# by young
|
|
|
|
menu_item :overview
|
|
|
|
menu_item :overview
|
|
|
@ -51,32 +50,32 @@ class ProjectsController < ApplicationController
|
|
|
|
helper :activities
|
|
|
|
helper :activities
|
|
|
|
helper :documents
|
|
|
|
helper :documents
|
|
|
|
helper :watchers
|
|
|
|
helper :watchers
|
|
|
|
# helper :watcherlist
|
|
|
|
# helper :watcherlist
|
|
|
|
|
|
|
|
|
|
|
|
### added by william
|
|
|
|
### added by william
|
|
|
|
include ActsAsTaggableOn::TagsHelper
|
|
|
|
include ActsAsTaggableOn::TagsHelper
|
|
|
|
|
|
|
|
|
|
|
|
# Lists visible projects
|
|
|
|
# Lists visible projects
|
|
|
|
# def index
|
|
|
|
# def index
|
|
|
|
# respond_to do |format|
|
|
|
|
# respond_to do |format|
|
|
|
|
# format.html {
|
|
|
|
# format.html {
|
|
|
|
# scope = Project
|
|
|
|
# scope = Project
|
|
|
|
# unless params[:closed]
|
|
|
|
# unless params[:closed]
|
|
|
|
# scope = scope.active
|
|
|
|
# scope = scope.active
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# @projects = scope.visible.order('lft').all
|
|
|
|
# @projects = scope.visible.order('lft').all
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
# format.api {
|
|
|
|
# format.api {
|
|
|
|
# @offset, @limit = api_offset_and_limit
|
|
|
|
# @offset, @limit = api_offset_and_limit
|
|
|
|
# @project_count = Project.visible.count
|
|
|
|
# @project_count = Project.visible.count
|
|
|
|
# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
|
|
|
# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
# format.atom {
|
|
|
|
# format.atom {
|
|
|
|
# projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
|
|
|
# projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
|
|
|
# render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
|
|
|
# render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
def index
|
|
|
|
#Modified by nie
|
|
|
|
#Modified by nie
|
|
|
@ -89,33 +88,79 @@ class ProjectsController < ApplicationController
|
|
|
|
@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|
|
|
|
|
# @projects.each do |project|
|
|
|
|
# @admin = project.users_by_role[Role.find(3)]
|
|
|
|
# @admin = project.users_by_role[Role.find(3)]
|
|
|
|
# unless @admin.nil?
|
|
|
|
# unless @admin.nil?
|
|
|
|
# @admin.each do |user|
|
|
|
|
# @admin.each do |user|
|
|
|
|
# ProjectInfo.create(:user_id => user.id, :project_id => project.id)
|
|
|
|
# ProjectInfo.create(:user_id => user.id, :project_id => project.id)
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
# @projects.each do |project|
|
|
|
|
|
|
|
|
# ProjectStatus.create(:changesets_count => project.changesets.count, :project_id => project.id, :watchers_count => project.watcher_users.count)
|
|
|
|
# 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']
|
|
|
|
@offset ||= @project_pages.offset
|
|
|
|
|
|
|
|
@projects = @projects.offset(@offset).limit(@limit).order('created_on DESC').all
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
|
|
|
|
#@projects = @projects.offset(@offset).limit(@limit).order('created_on DESC').all
|
|
|
|
|
|
|
|
if params[:project_sort_type].present?
|
|
|
|
|
|
|
|
case params[:project_sort_type]
|
|
|
|
|
|
|
|
when '0'
|
|
|
|
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
|
|
|
|
unless @offset == 0
|
|
|
|
|
|
|
|
@projects = @projects.offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
limit = @project_count % @limit
|
|
|
|
|
|
|
|
@projects = @projects.offset(@offset).limit(limit).all.reverse
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
|
|
|
|
|
|
|
# @projects = @projects[@offset, @limit]
|
|
|
|
|
|
|
|
when '1'
|
|
|
|
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
|
|
|
|
unless @offset == 0
|
|
|
|
|
|
|
|
@projects = @projects.includes(:project_status).reorder('project_statuses.changesets_count').offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
limit = @project_count % @limit
|
|
|
|
|
|
|
|
@projects = @projects.includes(:project_status).reorder('project_statuses.changesets_count').offset(@offset).limit(limit).all.reverse
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#@projects = @projects[@offset, @limit]
|
|
|
|
|
|
|
|
when '2'
|
|
|
|
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
|
|
|
|
unless @offset == 0
|
|
|
|
|
|
|
|
@projects = @projects.includes(:project_status).reorder('project_statuses.watchers_count').offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
limit = @project_count % @limit
|
|
|
|
|
|
|
|
@projects = @projects.includes(:project_status).reorder('project_statuses.watchers_count').offset(@offset).limit(limit).all.reverse
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
|
|
|
|
unless @offset == 0
|
|
|
|
|
|
|
|
@projects = @projects.offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
limit = @project_count % @limit
|
|
|
|
|
|
|
|
@projects = @projects.offset(@offset).limit(limit).all.reverse
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
|
|
|
|
|
|
|
# @projects = @projects[@offset, @limit]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
#end
|
|
|
|
#end
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html {
|
|
|
|
format.html {
|
|
|
|
render :layout => 'base'
|
|
|
|
render :layout => 'base'
|
|
|
|
scope = Project
|
|
|
|
scope = Project
|
|
|
|
unless params[:closed]
|
|
|
|
unless params[:closed]
|
|
|
|
scope = scope.active
|
|
|
|
scope = scope.active
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@projects = scope.visible.offset(@offset).limit(@limit).order('created_on DESC').all
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
format.api {
|
|
|
|
format.api {
|
|
|
|
# @offset, @limit = api_offset_and_limit
|
|
|
|
# @offset, @limit = api_offset_and_limit
|
|
|
|
# @project_count = Project.visible.count
|
|
|
|
# @project_count = Project.visible.count
|
|
|
|
# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
|
|
|
# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
|
|
|
}
|
|
|
|
}
|
|
|
|
format.atom {
|
|
|
|
format.atom {
|
|
|
|
projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
|
|
|
projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
|
|
@ -155,8 +200,9 @@ class ProjectsController < ApplicationController
|
|
|
|
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
|
|
|
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
|
|
|
m = Member.new(:user => User.current, :roles => [r])
|
|
|
|
m = Member.new(:user => User.current, :roles => [r])
|
|
|
|
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
|
|
|
|
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
|
|
|
|
@project.members << m
|
|
|
|
project_status = ProjectStatus.create(:project_id => @project.id)
|
|
|
|
@project.project_infos << project
|
|
|
|
@project.members << m
|
|
|
|
|
|
|
|
@project.project_infos << project
|
|
|
|
end
|
|
|
|
end
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html {
|
|
|
|
format.html {
|
|
|
@ -203,15 +249,15 @@ class ProjectsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
# source_project not found
|
|
|
|
# source_project not found
|
|
|
|
render_404
|
|
|
|
render_404
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Show @project
|
|
|
|
# Show @project
|
|
|
|
def show
|
|
|
|
def show
|
|
|
|
# try to redirect to the requested menu item
|
|
|
|
# try to redirect to the requested menu item
|
|
|
|
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
|
|
|
|
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@users_by_role = @project.users_by_role
|
|
|
|
@users_by_role = @project.users_by_role
|
|
|
@ -229,7 +275,7 @@ class ProjectsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@key = User.current.rss_key
|
|
|
|
@key = User.current.rss_key
|
|
|
|
#新增内容
|
|
|
|
#新增内容
|
|
|
|
@days = Setting.activity_days_default.to_i
|
|
|
|
@days = Setting.activity_days_default.to_i
|
|
|
|
|
|
|
|
|
|
|
|
if params[:from]
|
|
|
|
if params[:from]
|
|
|
@ -246,12 +292,12 @@ class ProjectsController < ApplicationController
|
|
|
|
@date_from = @date_to - @days
|
|
|
|
@date_from = @date_to - @days
|
|
|
|
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
|
|
|
|
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
|
|
|
|
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
|
|
|
|
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
|
|
|
|
# 决定显示所用用户或单个用户活动
|
|
|
|
# 决定显示所用用户或单个用户活动
|
|
|
|
@activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
|
|
|
|
@activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
|
|
|
|
:with_subprojects => @with_subprojects,
|
|
|
|
:with_subprojects => @with_subprojects,
|
|
|
|
:author => @author)
|
|
|
|
:author => @author)
|
|
|
|
@activity.scope_select {|t| !has["show_#{t}"].nil?}
|
|
|
|
@activity.scope_select {|t| !has["show_#{t}"].nil?}
|
|
|
|
# @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
|
|
|
|
# @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
|
|
|
|
#Added by young
|
|
|
|
#Added by young
|
|
|
|
events = @activity.events(@date_from, @date_to)
|
|
|
|
events = @activity.events(@date_from, @date_to)
|
|
|
|
|
|
|
|
|
|
|
@ -262,8 +308,8 @@ class ProjectsController < ApplicationController
|
|
|
|
events = events.slice(@offset,@limit)
|
|
|
|
events = events.slice(@offset,@limit)
|
|
|
|
#Ended by young
|
|
|
|
#Ended by young
|
|
|
|
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
|
|
|
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
|
|
|
# documents
|
|
|
|
# documents
|
|
|
|
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
|
|
|
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
|
|
|
documents = @project.documents.includes(:attachments, :category).all
|
|
|
|
documents = @project.documents.includes(:attachments, :category).all
|
|
|
|
case @sort_by
|
|
|
|
case @sort_by
|
|
|
|
when 'date'
|
|
|
|
when 'date'
|
|
|
@ -273,17 +319,16 @@ class ProjectsController < ApplicationController
|
|
|
|
when 'author'
|
|
|
|
when 'author'
|
|
|
|
@grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
|
|
|
|
@grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@grouped = documents.group_by(&:category)
|
|
|
|
@grouped = documents.group_by(&:category)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@document = @project.documents.build
|
|
|
|
@document = @project.documents.build
|
|
|
|
#
|
|
|
|
#
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.html
|
|
|
|
format.api
|
|
|
|
format.api
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def settings
|
|
|
|
def settings
|
|
|
|
@issue_custom_fields = IssueCustomField.sorted.all
|
|
|
|
@issue_custom_fields = IssueCustomField.sorted.all
|
|
|
|
@issue_category ||= IssueCategory.new
|
|
|
|
@issue_category ||= IssueCategory.new
|
|
|
@ -299,7 +344,6 @@ class ProjectsController < ApplicationController
|
|
|
|
def member
|
|
|
|
def member
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def file
|
|
|
|
def file
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -369,9 +413,9 @@ class ProjectsController < ApplicationController
|
|
|
|
format.html { redirect_to admin_projects_path }
|
|
|
|
format.html { redirect_to admin_projects_path }
|
|
|
|
format.api { render_api_ok }
|
|
|
|
format.api { render_api_ok }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
render :layout => "base"
|
|
|
|
render :layout => "base"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# hide project in layout
|
|
|
|
# hide project in layout
|
|
|
|
@project = nil
|
|
|
|
@project = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -387,18 +431,17 @@ class ProjectsController < ApplicationController
|
|
|
|
parent = parent_id.blank? ? nil : Project.find_by_id(parent_id.to_i)
|
|
|
|
parent = parent_id.blank? ? nil : Project.find_by_id(parent_id.to_i)
|
|
|
|
unless @project.allowed_parents.include?(parent)
|
|
|
|
unless @project.allowed_parents.include?(parent)
|
|
|
|
@project.errors.add :parent_id, :invalid
|
|
|
|
@project.errors.add :parent_id, :invalid
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
true
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# added by huang
|
|
|
|
# added by huang
|
|
|
|
def watcherlist
|
|
|
|
|
|
|
|
|
|
|
|
def watcherlist
|
|
|
|
if @watched
|
|
|
|
if @watched
|
|
|
|
@users -= watched.watcher_users
|
|
|
|
@users -= watched.watcher_users
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# end
|
|
|
|
|
|
|
|