|
|
@ -23,8 +23,8 @@ class ProjectsController < ApplicationController
|
|
|
|
menu_item l(:label_sort_by_active), :only => :index
|
|
|
|
menu_item l(:label_sort_by_active), :only => :index
|
|
|
|
menu_item l(:label_sort_by_influence), :only => :index
|
|
|
|
menu_item l(:label_sort_by_influence), :only => :index
|
|
|
|
|
|
|
|
|
|
|
|
before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ]
|
|
|
|
before_filter :find_project, :except => [ :index, :search, :list, :new, :create, :copy ]
|
|
|
|
before_filter :authorize, :except => [:watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback, :project_respond]
|
|
|
|
before_filter :authorize, :except => [:watcherlist, :index, :search, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback, :project_respond]
|
|
|
|
before_filter :authorize_global, :only => [:new, :create]
|
|
|
|
before_filter :authorize_global, :only => [:new, :create]
|
|
|
|
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
|
|
|
|
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
|
|
|
|
#by young
|
|
|
|
#by young
|
|
|
@ -89,7 +89,7 @@ class ProjectsController < ApplicationController
|
|
|
|
# @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_status = ProjectStatus.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?
|
|
|
@ -102,8 +102,8 @@ class ProjectsController < ApplicationController
|
|
|
|
# @projects.each do |project|
|
|
|
|
# @projects.each do |project|
|
|
|
|
# ProjectStatus.create(:changesets_count => project.changesets.count, :project_id => project.id, :watchers_count => project.watcher_users.count)
|
|
|
|
# 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_status = Project.visible.like(params[:name]) if params[:name].present?
|
|
|
|
@project_count = @projects.count
|
|
|
|
@project_count = @projects_status.count
|
|
|
|
@project_pages = Paginator.new @project_count, @limit, params['page']
|
|
|
|
@project_pages = Paginator.new @project_count, @limit, params['page']
|
|
|
|
|
|
|
|
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
@ -114,13 +114,13 @@ class ProjectsController < ApplicationController
|
|
|
|
when '0'
|
|
|
|
when '0'
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
unless @offset == 0
|
|
|
|
unless @offset == 0
|
|
|
|
@projects = @projects.offset(@offset).limit(@limit).all.reverse
|
|
|
|
@projects_status = @projects_status.offset(@offset).limit(@limit).all.reverse
|
|
|
|
else
|
|
|
|
else
|
|
|
|
limit = @project_count % @limit
|
|
|
|
limit = @project_count % @limit
|
|
|
|
if limit == 0
|
|
|
|
if limit == 0
|
|
|
|
limit = @limit
|
|
|
|
limit = @limit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@projects = @projects.offset(@offset).limit(limit).all.reverse
|
|
|
|
@projects_status = @projects_status.offset(@offset).limit(limit).all.reverse
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@s_type = 0
|
|
|
|
@s_type = 0
|
|
|
|
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
|
|
|
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
|
|
@ -128,13 +128,13 @@ class ProjectsController < ApplicationController
|
|
|
|
when '1'
|
|
|
|
when '1'
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
unless @offset == 0
|
|
|
|
unless @offset == 0
|
|
|
|
@projects = @projects.includes(:project_status).reorder('project_statuses.changesets_count').offset(@offset).limit(@limit).all.reverse
|
|
|
|
@projects_status = @projects_status.reorder('changesets_count').offset(@offset).limit(@limit).all.reverse
|
|
|
|
else
|
|
|
|
else
|
|
|
|
limit = @project_count % @limit
|
|
|
|
limit = @project_count % @limit
|
|
|
|
if limit == 0
|
|
|
|
if limit == 0
|
|
|
|
limit = @limit
|
|
|
|
limit = @limit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@projects = @projects.includes(:project_status).reorder('project_statuses.changesets_count').offset(@offset).limit(limit).all.reverse
|
|
|
|
@projects_status = @projects_status.reorder('changesets_count').offset(@offset).limit(limit).all.reverse
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@s_type = 1
|
|
|
|
@s_type = 1
|
|
|
|
|
|
|
|
|
|
|
@ -142,31 +142,35 @@ class ProjectsController < ApplicationController
|
|
|
|
when '2'
|
|
|
|
when '2'
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
unless @offset == 0
|
|
|
|
unless @offset == 0
|
|
|
|
@projects = @projects.includes(:project_status).reorder('project_statuses.watchers_count').offset(@offset).limit(@limit).all.reverse
|
|
|
|
@projects_status = @projects_status.reorder('watchers_count').offset(@offset).limit(@limit).all.reverse
|
|
|
|
else
|
|
|
|
else
|
|
|
|
limit = @project_count % @limit
|
|
|
|
limit = @project_count % @limit
|
|
|
|
if limit == 0
|
|
|
|
if limit == 0
|
|
|
|
limit = @limit
|
|
|
|
limit = @limit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@projects = @projects.includes(:project_status).reorder('project_statuses.watchers_count').offset(@offset).limit(limit).all.reverse
|
|
|
|
@projects_status = @projects_status.reorder('watchers_count').offset(@offset).limit(limit).all.reverse
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@s_type = 2
|
|
|
|
@s_type = 2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
@offset ||= @project_pages.reverse_offset
|
|
|
|
unless @offset == 0
|
|
|
|
unless @offset == 0
|
|
|
|
@projects = @projects.includes(:project_status).reorder('project_statuses.changesets_count').offset(@offset).limit(@limit).all.reverse
|
|
|
|
@projects_status = @projects_status.reorder('changesets_count').offset(@offset).limit(@limit).all.reverse
|
|
|
|
else
|
|
|
|
else
|
|
|
|
limit = @project_count % @limit
|
|
|
|
limit = @project_count % @limit
|
|
|
|
if limit == 0
|
|
|
|
if limit == 0
|
|
|
|
limit = @limit
|
|
|
|
limit = @limit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@projects = @projects.includes(:project_status).reorder('project_statuses.changesets_count').offset(@offset).limit(limit).all.reverse
|
|
|
|
@projects_status = @projects_status.reorder('changesets_count').offset(@offset).limit(limit).all.reverse
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@s_type = 1
|
|
|
|
@s_type = 1
|
|
|
|
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
|
|
|
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
|
|
|
# @projects = @projects[@offset, @limit]
|
|
|
|
# @projects = @projects[@offset, @limit]
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@projects = []
|
|
|
|
|
|
|
|
@projects_status.each do |obj|
|
|
|
|
|
|
|
|
@projects << Project.find_by_id("#{obj.project_id}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#end
|
|
|
|
#end
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
@ -188,6 +192,35 @@ class ProjectsController < ApplicationController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def search
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@projects = Project.visible
|
|
|
|
|
|
|
|
@projects = @projects.visible.like(params[:name]) if params[:name].present?
|
|
|
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
|
|
|
|
@project_count = @projects.visible.count
|
|
|
|
|
|
|
|
@project_pages = Paginator.new @project_count, @limit, params['page']
|
|
|
|
|
|
|
|
@offset ||= @project_pages.offset
|
|
|
|
|
|
|
|
@projects = @projects.visible.offset(@offset).limit(@limit).all
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
|
|
|
format.html {
|
|
|
|
|
|
|
|
render :layout => 'base'
|
|
|
|
|
|
|
|
scope = Project
|
|
|
|
|
|
|
|
unless params[:closed]
|
|
|
|
|
|
|
|
scope = scope.active
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
format.api {
|
|
|
|
|
|
|
|
# @offset, @limit = api_offset_and_limit
|
|
|
|
|
|
|
|
# @project_count = Project.visible.count
|
|
|
|
|
|
|
|
# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
format.atom {
|
|
|
|
|
|
|
|
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)}")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def feedback
|
|
|
|
def feedback
|
|
|
|
@jours = @project.journals_for_messages.reverse
|
|
|
|
@jours = @project.journals_for_messages.reverse
|
|
|
|