|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
class OpenSourceProjectsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
before_filter :find_osp, :only => [:master_apply]
|
|
|
|
|
before_filter :require_master, :only => [:master_apply]
|
|
|
|
|
before_filter :find_osp, :only => [:master_apply, :accept_master_apply, :refuse_master_apply]
|
|
|
|
|
before_filter :require_master, :only => [:master_apply, :accept_master_apply, :refuse_master_apply]
|
|
|
|
|
|
|
|
|
|
helper :sort
|
|
|
|
|
include SortHelper
|
|
|
|
@ -146,20 +146,37 @@ class OpenSourceProjectsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def search
|
|
|
|
|
per_page_option = 10
|
|
|
|
|
# per_page_option = 10
|
|
|
|
|
#
|
|
|
|
|
# @open_source_projects = OpenSourceProject.filter(@app_dir, @language, @created_at)
|
|
|
|
|
# @open_source_projects = @open_source_projects.like(params[:name]) if params[:name].present?
|
|
|
|
|
#
|
|
|
|
|
# @os_project_count = @open_source_projects.count
|
|
|
|
|
# @os_project_pages = Paginator.new @os_project_count, per_page_option, params['page']
|
|
|
|
|
#
|
|
|
|
|
# @open_source_projects = @open_source_projects.offset(@os_project_pages.offset).limit(@os_project_pages.per_page)
|
|
|
|
|
|
|
|
|
|
@open_source_projects = OpenSourceProject.filter(@app_dir, @language, @created_at)
|
|
|
|
|
@open_source_projects = @open_source_projects.like(params[:name]) if params[:name].present?
|
|
|
|
|
redirect_to open_source_projects_path(:name => params[:name])
|
|
|
|
|
|
|
|
|
|
@os_project_count = @open_source_projects.count
|
|
|
|
|
@os_project_pages = Paginator.new @os_project_count, per_page_option, params['page']
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@open_source_projects = @open_source_projects.offset(@os_project_pages.offset).limit(@os_project_pages.per_page)
|
|
|
|
|
def refuse_master_apply
|
|
|
|
|
@apply = ApplyProjectMaster.where("user_id = ? and apply_id = ? and apply_type = 'OpenSourceProject'", params[:user_id], @open_source_project.id)
|
|
|
|
|
@apply.first.destory
|
|
|
|
|
|
|
|
|
|
redirect_to open_source_projects_path(:name => params[:name])
|
|
|
|
|
redirect_to master_apply_open_source_project_path
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def accept_master_apply
|
|
|
|
|
@apply = ApplyProjectMaster.where("user_id = ? and apply_id = ? and apply_type = 'OpenSourceProject'", params[:user_id], @open_source_project.id)
|
|
|
|
|
if @apply.count == 1
|
|
|
|
|
@apply.first.update_attributes(:status => 2)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
redirect_to master_apply_open_source_project_path
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def require_master
|
|
|
|
|