|
|
|
@ -15,9 +15,8 @@
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
class ProjectsController < ApplicationController
|
|
|
|
|
# if @project.project_type == 1
|
|
|
|
|
# layout 'base_projects'# by young
|
|
|
|
|
layout :select_project_layout
|
|
|
|
|
|
|
|
|
|
menu_item :overview
|
|
|
|
|
menu_item :roadmap, :only => :roadmap
|
|
|
|
|
menu_item :settings, :only => :settings
|
|
|
|
@ -32,18 +31,7 @@ class ProjectsController < ApplicationController
|
|
|
|
|
menu_item :feedback, :only => :feedback
|
|
|
|
|
menu_item l(:label_course_file), :only => :index
|
|
|
|
|
menu_item l(:label_course_news), :only => :index
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# layout 'base_courses'# by young
|
|
|
|
|
# menu_item :overview
|
|
|
|
|
# menu_item l(:label_homework), :only => :homework
|
|
|
|
|
# menu_item :files, :only => :files
|
|
|
|
|
#
|
|
|
|
|
# layout 'base_courses'
|
|
|
|
|
# menu_item l(:label_homework), :only => homework
|
|
|
|
|
# menu_item l(:label_course_file), :only => files
|
|
|
|
|
# menu_item l(:label_settings), :only => settings
|
|
|
|
|
|
|
|
|
|
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise]
|
|
|
|
|
# before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file,
|
|
|
|
@ -52,11 +40,11 @@ class ProjectsController < ApplicationController
|
|
|
|
|
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen]
|
|
|
|
|
before_filter :authorize_global, :only => [:new, :create]
|
|
|
|
|
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar]
|
|
|
|
|
#by young
|
|
|
|
|
# before_filter :member, :file, :statistics, :watcherlist
|
|
|
|
|
# modified by fq
|
|
|
|
|
before_filter :file, :statistics, :watcherlist
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# 除非项目内人员,不可查看成员, TODO: 完了写报表里去
|
|
|
|
|
before_filter :memberAccess, only: :member
|
|
|
|
|
|
|
|
|
|
accept_rss_auth :index
|
|
|
|
|
accept_api_auth :index, :show, :create, :update, :destroy
|
|
|
|
|
|
|
|
|
@ -89,27 +77,6 @@ class ProjectsController < ApplicationController
|
|
|
|
|
### added by william
|
|
|
|
|
include ActsAsTaggableOn::TagsHelper
|
|
|
|
|
|
|
|
|
|
# Lists visible projects
|
|
|
|
|
# def index
|
|
|
|
|
# respond_to do |format|
|
|
|
|
|
# format.html {
|
|
|
|
|
# scope = Project
|
|
|
|
|
# unless params[:closed]
|
|
|
|
|
# scope = scope.active
|
|
|
|
|
# end
|
|
|
|
|
# @projects = scope.visible.order('lft').all
|
|
|
|
|
# }
|
|
|
|
|
# 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 enterprise_course
|
|
|
|
|
session[:enterprise_college] = 2
|
|
|
|
|
respond_to do |format|
|
|
|
|
@ -384,36 +351,6 @@ class ProjectsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
#gcmend
|
|
|
|
|
|
|
|
|
|
# def search
|
|
|
|
|
# #modified by nie
|
|
|
|
|
# project_type = params[:project_type].to_i
|
|
|
|
|
# projects_all = (project_type.eql? Project::ProjectType_course) ? Project.course_entities : Project.project_entities
|
|
|
|
|
# @projects = projects_all.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
|
|
|
|
|
|
|
|
|
|
# added by fq
|
|
|
|
|
def new_join
|
|
|
|
@ -861,22 +798,7 @@ class ProjectsController < ApplicationController
|
|
|
|
|
memberlist
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# def news
|
|
|
|
|
# if @project.project_type == 1
|
|
|
|
|
# render :layout => 'base_courses'
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
def file
|
|
|
|
|
# if @project.project_type == 1
|
|
|
|
|
# render :layout => 'base_courses'
|
|
|
|
|
# end
|
|
|
|
|
# @course_tag = params[:course]
|
|
|
|
|
# if @course_tag == '1'
|
|
|
|
|
# render :layout => 'base_courses'
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
# User.current
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def statistics
|
|
|
|
@ -999,12 +921,8 @@ class ProjectsController < ApplicationController
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
before_filter :toggleCourse, only: [:finishcourse, :restartcourse]
|
|
|
|
|
# TODO:#finishcourse and #restartcourse 没有设置权限,也就是说,任何人的调用都会关闭or重启课程。
|
|
|
|
|
# 最好通过用户与项目的权限解决这种事情。还没写
|
|
|
|
|
def finishcourse
|
|
|
|
|
#course_prefs = Course.find_by_extra(@project.identifier)
|
|
|
|
|
# setup_time = Time.parse(course_prefs.setup_time)
|
|
|
|
|
# end_time = Time.parse(course_prefs.endup_time)
|
|
|
|
|
yesterday = Date.today.prev_day.to_time
|
|
|
|
|
|
|
|
|
|
@course_prefs.endup_time = yesterday
|
|
|
|
@ -1016,7 +934,6 @@ class ProjectsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def restartcourse
|
|
|
|
|
#course_prefs = Course.find_by_extra(@project.identifier)
|
|
|
|
|
day = Time.parse("3000-01-01")
|
|
|
|
|
|
|
|
|
|
@course_prefs.endup_time = day
|
|
|
|
@ -1030,6 +947,14 @@ class ProjectsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def memberAccess
|
|
|
|
|
# 是课程,则判断当前用户是否参加了课程
|
|
|
|
|
return 0 if @project.project_type == Project::ProjectType_project
|
|
|
|
|
currentUser = User.current
|
|
|
|
|
render_403 unless currentUser.member_of?(@project)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def toggleCourse
|
|
|
|
|
@course_prefs = Course.find_by_extra(@project.identifier)
|
|
|
|
|
unless (@course_prefs.teacher == User.current || User.current.admin?)
|
|
|
|
|