Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
Conflicts: db/schema.rb
This commit is contained in:
commit
6379dd704a
3
Gemfile
3
Gemfile
|
@ -27,6 +27,7 @@ group :test do
|
||||||
gem "mocha", "~> 0.13.3"
|
gem "mocha", "~> 0.13.3"
|
||||||
gem 'capybara', '~> 2.0.0'
|
gem 'capybara', '~> 2.0.0'
|
||||||
gem 'nokogiri', '< 1.6.0'
|
gem 'nokogiri', '< 1.6.0'
|
||||||
|
gem 'factory_girl'
|
||||||
|
|
||||||
platforms :mri, :mingw do
|
platforms :mri, :mingw do
|
||||||
group :rmagick do
|
group :rmagick do
|
||||||
|
@ -43,7 +44,7 @@ group :development, :test do
|
||||||
gem 'spork-testunit'
|
gem 'spork-testunit'
|
||||||
gem 'guard-spork'
|
gem 'guard-spork'
|
||||||
gem 'guard-test', '~> 1.0.0'
|
gem 'guard-test', '~> 1.0.0'
|
||||||
gem 'ruby-prof'
|
gem 'ruby-prof' unless RUBY_PLATFORM =~ /w32/
|
||||||
gem 'pry'
|
gem 'pry'
|
||||||
gem 'pry-nav'
|
gem 'pry-nav'
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,6 +78,8 @@ GEM
|
||||||
coffee-script-source (1.7.1)
|
coffee-script-source (1.7.1)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
execjs (2.2.1)
|
execjs (2.2.1)
|
||||||
|
factory_girl (4.4.0)
|
||||||
|
activesupport (>= 3.0.0)
|
||||||
fastercsv (1.5.5)
|
fastercsv (1.5.5)
|
||||||
ffi (1.9.3)
|
ffi (1.9.3)
|
||||||
ffi (1.9.3-x86-mingw32)
|
ffi (1.9.3-x86-mingw32)
|
||||||
|
@ -189,7 +191,6 @@ GEM
|
||||||
sass-rails
|
sass-rails
|
||||||
rmagick (2.13.2)
|
rmagick (2.13.2)
|
||||||
ruby-openid (2.1.8)
|
ruby-openid (2.1.8)
|
||||||
ruby-prof (0.15.1)
|
|
||||||
rubyzip (1.1.6)
|
rubyzip (1.1.6)
|
||||||
sass (3.3.10)
|
sass (3.3.10)
|
||||||
sass-rails (3.2.6)
|
sass-rails (3.2.6)
|
||||||
|
@ -248,6 +249,7 @@ DEPENDENCIES
|
||||||
capybara (~> 2.0.0)
|
capybara (~> 2.0.0)
|
||||||
coderay (~> 1.0.6)
|
coderay (~> 1.0.6)
|
||||||
coffee-rails (~> 3.2.1)
|
coffee-rails (~> 3.2.1)
|
||||||
|
factory_girl
|
||||||
fastercsv (~> 1.5.0)
|
fastercsv (~> 1.5.0)
|
||||||
guard-rails
|
guard-rails
|
||||||
guard-spork
|
guard-spork
|
||||||
|
@ -269,7 +271,6 @@ DEPENDENCIES
|
||||||
rich (= 1.4.6)
|
rich (= 1.4.6)
|
||||||
rmagick (>= 2.0.0)
|
rmagick (>= 2.0.0)
|
||||||
ruby-openid (~> 2.1.4)
|
ruby-openid (~> 2.1.4)
|
||||||
ruby-prof
|
|
||||||
sass-rails (~> 3.2.3)
|
sass-rails (~> 3.2.3)
|
||||||
seems_rateable!
|
seems_rateable!
|
||||||
shoulda (> 3.3.2)
|
shoulda (> 3.3.2)
|
||||||
|
|
|
@ -244,6 +244,7 @@ class AdminController < ApplicationController
|
||||||
@first_page.web_title = params[:web_title]
|
@first_page.web_title = params[:web_title]
|
||||||
@first_page.description = params[:description]
|
@first_page.description = params[:description]
|
||||||
@first_page.title = params[:title]
|
@first_page.title = params[:title]
|
||||||
|
@first_page.sort_type = params[:sort_type]
|
||||||
if @first_page.save
|
if @first_page.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
|
|
@ -55,32 +55,35 @@ class AttachmentsController < ApplicationController
|
||||||
candown = false
|
candown = false
|
||||||
if @attachment.container.has_attribute?(:project) && @attachment.container.project
|
if @attachment.container.has_attribute?(:project) && @attachment.container.project
|
||||||
project = @attachment.container.project
|
project = @attachment.container.project
|
||||||
candown= User.current.member_of?(project)
|
candown= User.current.member_of?(project) || (project.is_public==1 && @attachment.is_public == 1)
|
||||||
elsif @attachment.container.is_a?(Project)
|
elsif @attachment.container.is_a?(Project)
|
||||||
project = @attachment.container
|
project = @attachment.container
|
||||||
candown= User.current.member_of?(project)
|
candown= User.current.member_of?(project) || (project.is_public==1 && @attachment.is_public == 1)
|
||||||
elsif @attachment.container.has_attribute?(:course) && @attachment.container.course
|
elsif @attachment.container.has_attribute?(:course) && @attachment.container.course
|
||||||
course = @attachment.container.course
|
course = @attachment.container.course
|
||||||
candown= User.current.member_of_course?(course)
|
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
|
||||||
elsif @attachment.container.is_a?(Course)
|
elsif @attachment.container.is_a?(Course)
|
||||||
course = @attachment.container
|
course = @attachment.container
|
||||||
candown= User.current.member_of_course?(course)
|
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
|
||||||
elsif @attachment.container.class.to_s=="HomeworkAttach" && @attachment.container.bid.reward_type == 3
|
elsif @attachment.container.class.to_s=="HomeworkAttach" && @attachment.container.bid.reward_type == 3
|
||||||
candown = true
|
candown = true
|
||||||
|
else
|
||||||
|
candown = @attachment.is_public == 1
|
||||||
end
|
end
|
||||||
if candown || User.current.admin?
|
if candown || User.current.admin?
|
||||||
@attachment.increment_download
|
@attachment.increment_download
|
||||||
|
|
||||||
|
if stale?(:etag => @attachment.digest)
|
||||||
|
# images are sent inline
|
||||||
|
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
||||||
|
:type => detect_content_type(@attachment),
|
||||||
|
:disposition => (@attachment.image? ? 'inline' : 'attachment')
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
render_403 :message => :notice_not_authorized
|
render_403 :message => :notice_not_authorized
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if stale?(:etag => @attachment.digest)
|
|
||||||
# images are sent inline
|
|
||||||
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
|
||||||
:type => detect_content_type(@attachment),
|
|
||||||
:disposition => (@attachment.image? ? 'inline' : 'attachment')
|
|
||||||
end
|
|
||||||
rescue => e
|
rescue => e
|
||||||
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
|
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
|
||||||
end
|
end
|
||||||
|
|
|
@ -217,7 +217,7 @@ class CoursesController < ApplicationController
|
||||||
@issue_category ||= IssueCategory.new
|
@issue_category ||= IssueCategory.new
|
||||||
@member ||= @course.members.new
|
@member ||= @course.members.new
|
||||||
@trackers = Tracker.sorted.all
|
@trackers = Tracker.sorted.all
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if User.current.user_extensions.identity
|
if User.current.user_extensions.identity
|
||||||
|
@ -239,18 +239,18 @@ class CoursesController < ApplicationController
|
||||||
@trackers = Tracker.sorted.all
|
@trackers = Tracker.sorted.all
|
||||||
|
|
||||||
if User.current.user_extensions.identity == 0
|
if User.current.user_extensions.identity == 0
|
||||||
if @course.save
|
if @course.save
|
||||||
#unless User.current.admin?
|
#unless User.current.admin?
|
||||||
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])
|
||||||
m.project_id = -1
|
m.project_id = -1
|
||||||
course = CourseInfos.new(:user_id => User.current.id, :course_id => @course.id)
|
course = CourseInfos.new(:user_id => User.current.id, :course_id => @course.id)
|
||||||
#user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
|
#user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
|
||||||
if params[:course][:is_public] == '1'
|
if params[:course][:is_public] == '1'
|
||||||
course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag)
|
course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag)
|
||||||
end
|
end
|
||||||
@course.members << m
|
@course.members << m
|
||||||
@course.course_infos << course
|
@course.course_infos << course
|
||||||
#end
|
#end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
|
@ -272,7 +272,7 @@ class CoursesController < ApplicationController
|
||||||
format.api { render_validation_errors(@course) }
|
format.api { render_validation_errors(@course) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -50,14 +50,14 @@ class ForumsController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||||
@forums_all = Forum.all
|
@forums_all = Forum.where('1=1')
|
||||||
@forums_count = @forums_all.count
|
@forums_count = @forums_all.count
|
||||||
@forums_pages = Paginator.new @forums_count, @limit, params['page']
|
@forums_pages = Paginator.new @forums_count, @limit, params['page']
|
||||||
|
|
||||||
|
|
||||||
@offset ||= @forums_pages.offset
|
@offset ||= @forums_pages.offset
|
||||||
# @forums = @forums_all.offset(@offset).limit(@limit).all
|
@forums = @forums_all.offset(@offset).limit(@limit).all
|
||||||
@forums = Forum.all
|
#@forums = Forum.all
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
format.json { render json: @forums }
|
format.json { render json: @forums }
|
||||||
|
|
|
@ -38,7 +38,7 @@ class StoresController < ApplicationController
|
||||||
LIMIT = 12 unless const_defined?(:LIMIT)
|
LIMIT = 12 unless const_defined?(:LIMIT)
|
||||||
def index
|
def index
|
||||||
@projects_attach = project_classification(0).take(LIMIT)
|
@projects_attach = project_classification(0).take(LIMIT)
|
||||||
@courses_attach = Attachment.includes(:course).where("courses.is_public = ?", 1).
|
@courses_attach = Attachment.includes(:course).where("courses.is_public = 1").
|
||||||
where(container_type: 'Course').
|
where(container_type: 'Course').
|
||||||
limit(LIMIT)
|
limit(LIMIT)
|
||||||
# @projects_attach = Attachment.includes(:project).where("projects.project_type=? AND projects.is_public = ?", 0, 1).
|
# @projects_attach = Attachment.includes(:project).where("projects.project_type=? AND projects.is_public = ?", 0, 1).
|
||||||
|
|
|
@ -53,6 +53,7 @@ class UsersController < ApplicationController
|
||||||
include CustomFieldsHelper
|
include CustomFieldsHelper
|
||||||
include AvatarHelper
|
include AvatarHelper
|
||||||
include WordsHelper
|
include WordsHelper
|
||||||
|
include GitlabHelper
|
||||||
|
|
||||||
# added by liuping 关注
|
# added by liuping 关注
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,44 @@
|
||||||
|
|
||||||
class WelcomeController < ApplicationController
|
class WelcomeController < ApplicationController
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
include WelcomeHelper
|
||||||
caches_action :robots
|
caches_action :robots
|
||||||
# before_filter :fake, :only => [:index, :course]
|
# before_filter :fake, :only => [:index, :course]
|
||||||
before_filter :entry_select, :only => [:index]
|
before_filter :entry_select, :only => [:index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@first_page = FirstPage.where("page_type = 'project'").first
|
@first_page = FirstPage.where("page_type = 'project'").first
|
||||||
|
@hot_projects = find_miracle_project(10, 3)
|
||||||
|
@hot_projects_ids = []
|
||||||
|
@hot_projects.each do |p|
|
||||||
|
@hot_projects_ids << p
|
||||||
|
end
|
||||||
|
@projects_all = Project.active.visible.
|
||||||
|
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").
|
||||||
|
where("#{Project.table_name}.project_type = ? and #{Project.table_name}.id in (?)", Project::ProjectType_project,@hot_projects_ids)
|
||||||
|
if @first_page.nil? || @first_page.sort_type.nil?
|
||||||
|
@projects = @projects_all.order("grade desc")
|
||||||
|
else
|
||||||
|
case @first_page.sort_type
|
||||||
|
when 0
|
||||||
|
@projects = @projects_all.order("created_on desc")
|
||||||
|
when 1
|
||||||
|
@projects = @projects_all.order("grade desc")
|
||||||
|
when 2
|
||||||
|
@projects = @projects_all.order("watchers_count desc")
|
||||||
|
|
||||||
|
#gcm
|
||||||
|
#when '3'
|
||||||
|
#@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array)
|
||||||
|
# @projects=handle_project @projects_all,@project_activity_count
|
||||||
|
# @s_type = 3
|
||||||
|
# @projects = @projects[@project_pages.offset, @project_pages.per_page]
|
||||||
|
|
||||||
|
else
|
||||||
|
@projects = @projects_all.order("grade desc")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def robots
|
def robots
|
||||||
|
|
|
@ -0,0 +1,247 @@
|
||||||
|
# Gitlab5.3 API操作接口
|
||||||
|
# Add by nwb
|
||||||
|
# 暂时没支持SSH
|
||||||
|
# 接口通过HTTP协议与服务器交互,理论上只要能安装gitlab的操作系统本接口都能支持
|
||||||
|
# 本机的测试环境是Ubuntu 12.04
|
||||||
|
|
||||||
|
module GitlabHelper
|
||||||
|
|
||||||
|
# gitlab版本库数据本地保存的根目录
|
||||||
|
ROOT_PATH="/home/git/repositories/"
|
||||||
|
PROJECT_PATH_CUT = 40
|
||||||
|
# gitlab版本库所在服务器
|
||||||
|
# 注意REPO_IP_ADDRESS必须以http://开头,暂时只支持HTTP协议,未支持SSH
|
||||||
|
#REPO_IP_ADDRESS = "http://" + Setting.repository_domain
|
||||||
|
REPO_IP_ADDRESS = "http://192.168.137.100"
|
||||||
|
GITLAB_API = "/api/v3"
|
||||||
|
|
||||||
|
# 用户在项目中的权限级别
|
||||||
|
GUEST = 10
|
||||||
|
REPORTER = 20
|
||||||
|
DEVELOPER = 30
|
||||||
|
MASTER = 40
|
||||||
|
|
||||||
|
# gitlab的登录验证信息
|
||||||
|
# add by nwb
|
||||||
|
def self.gitlab_token=(token)
|
||||||
|
Thread.current[:gitlab_token] = token
|
||||||
|
end
|
||||||
|
|
||||||
|
# gitlab的登录验证信息
|
||||||
|
# add by nwb
|
||||||
|
def self.gitlab_token
|
||||||
|
Thread.current[:gitlab_token] ||= nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# 登录gitlab
|
||||||
|
# add by nwb
|
||||||
|
def login_gitlab(email,password)
|
||||||
|
url = REPO_IP_ADDRESS + GITLAB_API + "/session"
|
||||||
|
uri = URI.parse(url)
|
||||||
|
data = {email:email, password:password}
|
||||||
|
begin
|
||||||
|
res = Net::HTTP.post_form(uri, data)
|
||||||
|
if res.code == '201'
|
||||||
|
temp = ActiveSupport::JSON.decode(res.body)
|
||||||
|
GitlabHelper.gitlab_token= temp['private_token']
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
rescue =>err
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 创建项目
|
||||||
|
# add by nwb
|
||||||
|
def create_project(project_name)
|
||||||
|
url = REPO_IP_ADDRESS + GITLAB_API + "/projects"
|
||||||
|
uri = URI.parse(url)
|
||||||
|
data = {name:project_name, private_token:GitlabHelper.gitlab_token}
|
||||||
|
begin
|
||||||
|
res = Net::HTTP.post_form(uri, data)
|
||||||
|
if res.code == '201'
|
||||||
|
temp = ActiveSupport::JSON.decode(res.body)
|
||||||
|
#新创建项目的版本库地址
|
||||||
|
respo = temp['http_url_to_repo']
|
||||||
|
respo['http://localhost'] = REPO_IP_ADDRESS
|
||||||
|
# 新创建项目的web地址
|
||||||
|
webaddress = temp['web_url']
|
||||||
|
webaddress['http://localhost'] = REPO_IP_ADDRESS
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
rescue =>err
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 为指定用户创建版本库
|
||||||
|
# project_name:版本库名称 user_id:Gitlab版本库中的用户编号
|
||||||
|
# add by nwb
|
||||||
|
def create_project_for_user(project_name,user_id)
|
||||||
|
url = REPO_IP_ADDRESS + GITLAB_API + "/projects/user/" + user_id
|
||||||
|
uri = URI.parse(url)
|
||||||
|
data = {user_id:user_id, name:project_name,private_token:GitlabHelper.gitlab_token}
|
||||||
|
begin
|
||||||
|
res = Net::HTTP.post_form(uri, data)
|
||||||
|
if res.code == '201'
|
||||||
|
temp = ActiveSupport::JSON.decode(res.body)
|
||||||
|
#新创建项目的版本库地址
|
||||||
|
respo = temp['http_url_to_repo']
|
||||||
|
respo['http://localhost'] = REPO_IP_ADDRESS
|
||||||
|
# 新创建项目的web地址
|
||||||
|
webaddress = temp['web_url']
|
||||||
|
webaddress['http://localhost'] = REPO_IP_ADDRESS
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
rescue =>err
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 创建用户
|
||||||
|
# loginname:登录名称(版本库路径包含) name:用户姓名
|
||||||
|
# add by nwb
|
||||||
|
def create_user (loginname,name,password,email)
|
||||||
|
url = REPO_IP_ADDRESS + GITLAB_API + "/users"
|
||||||
|
uri = URI.parse(url)
|
||||||
|
data = {email:email,password:password,username:loginname, name:name, private_token:GitlabHelper.gitlab_token}
|
||||||
|
begin
|
||||||
|
res = Net::HTTP.post_form(uri, data)
|
||||||
|
if res.code == '201'
|
||||||
|
temp = ActiveSupport::JSON.decode(res.body)
|
||||||
|
#新创建的gitlab用户编号(需保存)
|
||||||
|
user_id = temp['id']
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
rescue =>err
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 删除用户
|
||||||
|
# user_id:用户在gitlab中的id
|
||||||
|
# add by nwb
|
||||||
|
def delete_user(user_id)
|
||||||
|
url = REPO_IP_ADDRESS + GITLAB_API + "/users/" + user_id
|
||||||
|
uri = URI.parse(url)
|
||||||
|
data = {id:user_id,private_token:GitlabHelper.gitlab_token}
|
||||||
|
http = Net::HTTP.new uri.host, uri.port
|
||||||
|
begin
|
||||||
|
req = Net::HTTP::Delete.new(uri.request_uri)
|
||||||
|
req.form_data = data
|
||||||
|
res= http.start { |http| http.request req }
|
||||||
|
if res.code == '200'
|
||||||
|
temp = ActiveSupport::JSON.decode(res.body)
|
||||||
|
# 删除成功,对应更新trustie用户的gitlab用户编号
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
rescue =>err
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 给用户添加一个可操作的项目
|
||||||
|
# 若用户已在该项目中,权限级别取新权限与现有权限的最大值
|
||||||
|
# project_id:项目在gitlab中的id user_id:用户在gitlab中的id
|
||||||
|
# access_level为用户在项目中的权限级别,对应如下:
|
||||||
|
#GUEST = 10
|
||||||
|
#REPORTER = 20
|
||||||
|
#DEVELOPER = 30
|
||||||
|
#MASTER = 40
|
||||||
|
# add by nwb
|
||||||
|
def add_user_to_project(project_id,user_id,access_level)
|
||||||
|
url = REPO_IP_ADDRESS + GITLAB_API + "/projects/" + project_id +"/members"
|
||||||
|
uri = URI.parse(url)
|
||||||
|
data = {id:project_id,user_id:user_id,access_level:access_level, private_token:GitlabHelper.gitlab_token}
|
||||||
|
begin
|
||||||
|
res = Net::HTTP.post_form(uri, data)
|
||||||
|
if res.code == '201'
|
||||||
|
temp = ActiveSupport::JSON.decode(res.body)
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
rescue =>err
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 从项目中删除用户
|
||||||
|
# project_id:项目在gitlab中的ids user_id:用户在gitlab中的id
|
||||||
|
# add by nwb
|
||||||
|
def delete_user_from_project(project_id,user_id)
|
||||||
|
url = REPO_IP_ADDRESS + GITLAB_API + "/projects/" + project_id +"/members/" + user_id
|
||||||
|
uri = URI.parse(url)
|
||||||
|
data = {id:project_id,user_id:user_id,private_token:GitlabHelper.gitlab_token}
|
||||||
|
http = Net::HTTP.new uri.host, uri.port
|
||||||
|
begin
|
||||||
|
req = Net::HTTP::Delete.new(uri.request_uri)
|
||||||
|
req.form_data = data
|
||||||
|
res= http.start { |http| http.request req }
|
||||||
|
if res.code == '200'
|
||||||
|
temp = ActiveSupport::JSON.decode(res.body)
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
rescue =>err
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 发送post消息
|
||||||
|
# add by nwb
|
||||||
|
def post(url, params)
|
||||||
|
uri = URI.parse(url)
|
||||||
|
http = Net::HTTP.new(uri.host, uri.port)
|
||||||
|
if uri.scheme == 'https'
|
||||||
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||||
|
http.use_ssl = true
|
||||||
|
end
|
||||||
|
begin
|
||||||
|
request = Net::HTTP::Post.new(uri.request_uri)
|
||||||
|
request['Content-Type'] = 'application/json;charset=utf-8'
|
||||||
|
request['User-Agent'] = 'Mozilla/5.0 (Windows NT 5.1; rv:29.0) Gecko/20100101 Firefox/29.0'
|
||||||
|
request['X-ACL-TOKEN'] = 'xxx_token'
|
||||||
|
#request.set_form_data(params)
|
||||||
|
request.body = params.to_json
|
||||||
|
response = http.start { |http| http.request(request) }
|
||||||
|
return JSON.parse response.body
|
||||||
|
rescue =>err
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 发送get消息
|
||||||
|
# add by nwb
|
||||||
|
def get(url, params)
|
||||||
|
uri = URI.parse(url)
|
||||||
|
uri.query = URI.encode_www_form(params)
|
||||||
|
http = Net::HTTP.new uri.host, uri.port
|
||||||
|
if uri.scheme == 'https'
|
||||||
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||||
|
http.use_ssl = true
|
||||||
|
end
|
||||||
|
begin
|
||||||
|
request = Net::HTTP::Get.new uri.request_uri
|
||||||
|
request['Content-Type'] = 'application/json;charset=utf-8'
|
||||||
|
request['User-Agent'] = 'Mozilla/5.0 (Windows NT 5.1; rv:29.0) Gecko/20100101 Firefox/29.0'
|
||||||
|
request['X-ACL-TOKEN'] = 'xxx_token'
|
||||||
|
response = http.start { |http| http.request request }
|
||||||
|
return JSON.parse response.body
|
||||||
|
rescue =>err
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -16,6 +16,8 @@ module StoresHelper
|
||||||
news_path(container)
|
news_path(container)
|
||||||
when 'Project'
|
when 'Project'
|
||||||
project_files_path(container)
|
project_files_path(container)
|
||||||
|
when 'Course'
|
||||||
|
course_files_path(container)
|
||||||
when 'Version'
|
when 'Version'
|
||||||
# version_path(container)
|
# version_path(container)
|
||||||
project_files_path(container.project)
|
project_files_path(container.project)
|
||||||
|
|
|
@ -208,7 +208,7 @@ module WelcomeHelper
|
||||||
#c1 = find_new_project(sum).to_a.dup
|
#c1 = find_new_project(sum).to_a.dup
|
||||||
#c2 = find_all_hot_project(sum).to_a.dup
|
#c2 = find_all_hot_project(sum).to_a.dup
|
||||||
#(c2.take(sum-max)+c1.take(max)).take(sum)
|
#(c2.take(sum-max)+c1.take(max)).take(sum)
|
||||||
find_all_hot_project(sum).to_a.dup
|
find_all_hot_project(sum).dup#.to_a.dup
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_new_course limit=15
|
def find_new_course limit=15
|
||||||
|
@ -433,7 +433,7 @@ module WelcomeHelper
|
||||||
# FROM projects AS p LEFT OUTER JOIN (
|
# FROM projects AS p LEFT OUTER JOIN (
|
||||||
# SELECT project_id,grade FROM project_statuses
|
# SELECT project_id,grade FROM project_statuses
|
||||||
# WHERE project_type = #{project_type} ORDER BY #{order_by} LIMIT #{limit} ) AS t ON p.id = t.project_id ")
|
# WHERE project_type = #{project_type} ORDER BY #{order_by} LIMIT #{limit} ) AS t ON p.id = t.project_id ")
|
||||||
Project.visible.joins(:project_status).where("#{Project.table_name}.project_type = ?", project_type).order(order_by).limit(limit).all
|
Project.visible.joins(:project_status).where("#{Project.table_name}.project_type = ?", project_type).order(order_by).limit(limit)#.all
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_bid_by_hot_rails reward_type, limit = 10
|
def sort_bid_by_hot_rails reward_type, limit = 10
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class FirstPage < ActiveRecord::Base
|
class FirstPage < ActiveRecord::Base
|
||||||
attr_accessible :description, :title, :web_title,:page_type
|
attr_accessible :description, :title, :web_title,:page_type,:sort_type
|
||||||
validates_presence_of :web_title, :title, :description,:page_type
|
validates_presence_of :web_title, :title, :description,:page_type
|
||||||
validates_length_of :web_title,:title, maximum: 30
|
validates_length_of :web_title,:title, maximum: 30
|
||||||
validates_length_of :description, maximum: 100
|
validates_length_of :description, maximum: 100
|
||||||
|
|
|
@ -156,7 +156,7 @@ class Project < ActiveRecord::Base
|
||||||
where(nil)
|
where(nil)
|
||||||
else
|
else
|
||||||
pattern = "%#{arg.to_s.strip.downcase}%"
|
pattern = "%#{arg.to_s.strip.downcase}%"
|
||||||
where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p ", :p => pattern)
|
where("LOWER(name) LIKE :p ", :p => pattern)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
scope :project_entities, -> { where(project_type: ProjectType_project) }
|
scope :project_entities, -> { where(project_type: ProjectType_project) }
|
||||||
|
|
|
@ -28,6 +28,14 @@
|
||||||
<label for='description' style="vertical-align: top"> <%= l(:label_site_description)%>:</label>
|
<label for='description' style="vertical-align: top"> <%= l(:label_site_description)%>:</label>
|
||||||
<%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
<%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||||
</p>
|
</p>
|
||||||
|
<p style="margin-left:60px;padding-right: 20px;">
|
||||||
|
<label for='sort_type' style="vertical-align: top"> <%= l(:label_sort_type)%>:</label>
|
||||||
|
<select name="sort_type" id="sort_type" style="font-size:small;width:496px;margin-left:80px;">
|
||||||
|
<option value="1" <%= "selected=selected" if @first_page.sort_type == 1 %>><%= l(:label_sort_by_active) %></option>
|
||||||
|
<option value="2" <%= "selected=selected" if @first_page.sort_type == 2 %>><%= l(:label_sort_by_influence) %></option>
|
||||||
|
<option value="0" <%= "selected=selected" if @first_page.sort_type == 0 %>><%= l(:label_sort_by_time) %></option>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
|
||||||
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
|
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
<div id="file_buttons" class="nhidden">
|
<div id="file_buttons" class="nhidden">
|
||||||
<%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @course) %>
|
<%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @course) %>
|
||||||
<%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @course) %>
|
<%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @course) %>
|
||||||
|
<p></p>
|
||||||
|
<div class="box" id="files-box">
|
||||||
|
<label for="files-box" style="font-weight:bold;"> <%= l(:label_files_filter) %></label>
|
||||||
<% if attachmenttypes.any? %>
|
<% if attachmenttypes.any? %>
|
||||||
|
|
||||||
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
|
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
|
||||||
|
@ -24,7 +26,7 @@
|
||||||
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
|
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
|
||||||
:onchange => "course_attachment_contenttypes_searchex(this.value)" %>
|
:onchange => "course_attachment_contenttypes_searchex(this.value)" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</div>
|
||||||
<div id="upload_file_div" class="relation_file_div hidden">
|
<div id="upload_file_div" class="relation_file_div hidden">
|
||||||
<%= render :partial => 'course_new', locals: {course: @course} %>
|
<%= render :partial => 'course_new', locals: {course: @course} %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
<div id="file_buttons" class="nhidden">
|
<div id="file_buttons" class="nhidden">
|
||||||
<%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %>
|
<%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %>
|
||||||
<%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
|
<%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
|
||||||
|
<p></p>
|
||||||
|
<div class="box" id="files-box">
|
||||||
|
<label for="files-box" style="font-weight:bold;"> <%= l(:label_files_filter) %></label>
|
||||||
<% if attachmenttypes.any? %>
|
<% if attachmenttypes.any? %>
|
||||||
|
|
||||||
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
|
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
|
||||||
|
@ -24,6 +26,7 @@
|
||||||
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
|
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
|
||||||
:onchange => "attachment_contenttypes_searchex(this.value)" %>
|
:onchange => "attachment_contenttypes_searchex(this.value)" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="upload_file_div" class="relation_file_div hidden">
|
<div id="upload_file_div" class="relation_file_div hidden">
|
||||||
<%= render :partial => 'new', locals: {project: @project} %>
|
<%= render :partial => 'new', locals: {project: @project} %>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<ul class="course_sub_menu">
|
<ul class="course_sub_menu">
|
||||||
<% User.current.courses.each do |course| %>
|
<% User.current.courses.each do |course| %>
|
||||||
<% if !course_endTime_timeout?(course) %>
|
<% if !course_endTime_timeout?(course) %>
|
||||||
<li><%= link_to course.name.truncate(10, omission: '...'), course_path(course) %></li>
|
<li><%= link_to course.name.truncate(10, omission: '...'), {:controller => 'courses',:action => 'show',id:course.id} %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
<li id="project_loggedas_li"><%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %>
|
<li id="project_loggedas_li"><%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %>
|
||||||
<ul class="project_sub_menu">
|
<ul class="project_sub_menu">
|
||||||
<% User.current.projects.each do |project| %>
|
<% User.current.projects.each do |project| %>
|
||||||
<li><%= link_to project.name.truncate(10, omission: '...'), project_path(project) %></li>
|
<li><%= link_to project.name.truncate(10, omission: '...'), {:controller => 'projects', :action => 'show',id: project.id } %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 8px"><%= link_to request.host()+"/course", :controller => 'courses', :action => 'index' %></td>
|
<td style="padding-left: 8px"><%= link_to request.host()+"/course", :controller => 'courses', :action => 'index' %></td>
|
||||||
<td><p class="top-content-list"><%= link_to "主页", home_path %>
|
<td><p class="top-content-list"><%= link_to "主页", home_path %>
|
||||||
> <%= link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %>
|
> <%= link_to l(:label_course_all), :controller => 'courses', :action => 'index' %>
|
||||||
> <%= link_to @course.name, nil %></p></td>
|
> <%= link_to @course.name, nil %></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -183,12 +183,12 @@
|
||||||
<!--description-->
|
<!--description-->
|
||||||
<div class="inf_user_context">
|
<div class="inf_user_context">
|
||||||
<div class="font_title_left">
|
<div class="font_title_left">
|
||||||
<%= l(:label_course_overview) %>
|
<%= l(:label_new_course_description) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="padding-bottom: 8px">
|
<div style="padding-bottom: 8px">
|
||||||
<% if @course.description && @course.description.size>0 %>
|
<% if @course.description && @course.description.size>0 %>
|
||||||
<div class="font_lighter_sidebar">
|
<div class="font_lighter_sidebar" style="word-break:break-all; word-wrap:break-all;">
|
||||||
|
|
||||||
<%= textilizable @course.description %>
|
<%= textilizable @course.description %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<% @nav_dispaly_project_label = 1 %>
|
<% #@nav_dispaly_project_label = 1 %>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
|
|
||||||
<strong class="font_small_watch"><%= link_to l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count)+"("+@user.watcher_users.count.to_s+")", :controller=>"users", :action=>"user_fanslist" %></strong>
|
<strong class="font_small_watch"><%= link_to l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count)+"("+@user.watcher_users.count.to_s+")", :controller=>"users", :action=>"user_fanslist" %></strong>
|
||||||
|
|
||||||
<strong class="font_small_watch"><%= link_to l(:label_requirement_focus)+"("+Bid.watched_by(@user).where('reward_type = ?', 1).count.to_s+")" ,:controller=>"users", :action=>"watch_bids"%></strong> <!-- added by huang -->
|
<!-- <strong class="font_small_watch"><%= link_to l(:label_requirement_focus)+"("+Bid.watched_by(@user).where('reward_type = ?', 1).count.to_s+")" ,:controller=>"users", :action=>"watch_bids"%></strong>--> <!-- added by huang -->
|
||||||
<!-- added by bai 个人签名-->
|
<!-- added by bai 个人签名-->
|
||||||
<% if @user.id == User.current.id %>
|
<% if @user.id == User.current.id %>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -60,8 +60,8 @@
|
||||||
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}, :target => "_blank" %></span>
|
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}, :target => "_blank" %></span>
|
||||||
<div class="d-p-projectlist-box">
|
<div class="d-p-projectlist-box">
|
||||||
<ul class="d-p-projectlist">
|
<ul class="d-p-projectlist">
|
||||||
<% projects = find_miracle_project(10, 3) %>
|
<% #projects = find_miracle_project(10, 3) %>
|
||||||
<% projects.map do |project| %>
|
<% @projects.map do |project| %>
|
||||||
<!--<%# cache cache_key_for_project(project) do %> -->
|
<!--<%# cache cache_key_for_project(project) do %> -->
|
||||||
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
|
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
|
||||||
<div style="float: left;">
|
<div style="float: left;">
|
||||||
|
|
|
@ -937,6 +937,7 @@ en:
|
||||||
label_cross_project_hierarchy: With project hierarchy
|
label_cross_project_hierarchy: With project hierarchy
|
||||||
label_cross_project_system: With all projects
|
label_cross_project_system: With all projects
|
||||||
label_gantt_progress_line: Progress line
|
label_gantt_progress_line: Progress line
|
||||||
|
label_files_filter: Files Filter:
|
||||||
|
|
||||||
button_login: Login
|
button_login: Login
|
||||||
button_submit: Submit
|
button_submit: Submit
|
||||||
|
|
|
@ -572,6 +572,7 @@ zh:
|
||||||
label_site_title: 网站标题
|
label_site_title: 网站标题
|
||||||
label_site_description: 网站简介
|
label_site_description: 网站简介
|
||||||
label_site_image: 简介图片
|
label_site_image: 简介图片
|
||||||
|
label_sort_type: 热门项目排序方式
|
||||||
#by young
|
#by young
|
||||||
label_requirement: 需求
|
label_requirement: 需求
|
||||||
label_new_course: 课程列表
|
label_new_course: 课程列表
|
||||||
|
@ -1741,6 +1742,7 @@ zh:
|
||||||
label_file_number: 文档的数量
|
label_file_number: 文档的数量
|
||||||
label_code_submit_number: 代码提交数量
|
label_code_submit_number: 代码提交数量
|
||||||
label_topic_number: 讨论区帖子数量
|
label_topic_number: 讨论区帖子数量
|
||||||
|
label_files_filter: 资源过滤:
|
||||||
|
|
||||||
label_course_contribute_to: 参与了 %{project_count} 个项目:
|
label_course_contribute_to: 参与了 %{project_count} 个项目:
|
||||||
label_x_course_contribute_to:
|
label_x_course_contribute_to:
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddColumnForFirstPage < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column("first_pages","sort_type",:integer)
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,8 @@
|
||||||
|
class SetSortType < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
FirstPage.all.each do |fp|
|
||||||
|
fp.sort_type = 1
|
||||||
|
fp.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
36
db/schema.rb
36
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140715015540) do
|
ActiveRecord::Schema.define(:version => 20140716021558) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -415,6 +415,7 @@ ActiveRecord::Schema.define(:version => 20140715015540) do
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.string "page_type"
|
t.string "page_type"
|
||||||
|
t.integer "sort_type"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "forums", :force => true do |t|
|
create_table "forums", :force => true do |t|
|
||||||
|
@ -808,18 +809,18 @@ ActiveRecord::Schema.define(:version => 20140715015540) do
|
||||||
create_table "relative_memos", :force => true do |t|
|
create_table "relative_memos", :force => true do |t|
|
||||||
t.integer "osp_id"
|
t.integer "osp_id"
|
||||||
t.integer "parent_id"
|
t.integer "parent_id"
|
||||||
t.string "subject", :null => false
|
t.string "subject", :null => false
|
||||||
t.text "content", :limit => 16777215, :null => false
|
t.text "content", :null => false
|
||||||
t.integer "author_id"
|
t.integer "author_id"
|
||||||
t.integer "replies_count", :default => 0
|
t.integer "replies_count", :default => 0
|
||||||
t.integer "last_reply_id"
|
t.integer "last_reply_id"
|
||||||
t.boolean "lock", :default => false
|
t.boolean "lock", :default => false
|
||||||
t.boolean "sticky", :default => false
|
t.boolean "sticky", :default => false
|
||||||
t.boolean "is_quote", :default => false
|
t.boolean "is_quote", :default => false
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "viewed_count_crawl", :default => 0
|
t.integer "viewed_count_crawl", :default => 0
|
||||||
t.integer "viewed_count_local", :default => 0
|
t.integer "viewed_count_local", :default => 0
|
||||||
t.string "url"
|
t.string "url"
|
||||||
t.string "username"
|
t.string "username"
|
||||||
t.string "userhomeurl"
|
t.string "userhomeurl"
|
||||||
|
@ -843,19 +844,6 @@ ActiveRecord::Schema.define(:version => 20140715015540) do
|
||||||
|
|
||||||
add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
|
add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
|
||||||
|
|
||||||
create_table "rich_rich_files", :force => true do |t|
|
|
||||||
t.datetime "created_at", :null => false
|
|
||||||
t.datetime "updated_at", :null => false
|
|
||||||
t.string "rich_file_file_name"
|
|
||||||
t.string "rich_file_content_type"
|
|
||||||
t.integer "rich_file_file_size"
|
|
||||||
t.datetime "rich_file_updated_at"
|
|
||||||
t.string "owner_type"
|
|
||||||
t.integer "owner_id"
|
|
||||||
t.text "uri_cache"
|
|
||||||
t.string "simplified_type", :default => "file"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "roles", :force => true do |t|
|
create_table "roles", :force => true do |t|
|
||||||
t.string "name", :limit => 30, :default => "", :null => false
|
t.string "name", :limit => 30, :default => "", :null => false
|
||||||
t.integer "position", :default => 1
|
t.integer "position", :default => 1
|
||||||
|
|
|
@ -45,6 +45,8 @@ class AttachmentsControllerTest < ActionController::TestCase
|
||||||
role.save
|
role.save
|
||||||
}
|
}
|
||||||
User.current = nil
|
User.current = nil
|
||||||
|
@request.session[:ctime] = Time.now.to_i
|
||||||
|
@request.session[:atime] = Time.now.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ class CodeReviewControllerTest < ActionController::TestCase
|
||||||
role.permissions << :view_code_review
|
role.permissions << :view_code_review
|
||||||
role.save
|
role.save
|
||||||
}
|
}
|
||||||
|
@request.session[:ctime] = Time.now.to_i
|
||||||
|
@request.session[:atime] = Time.now.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
context "index" do
|
context "index" do
|
||||||
|
|
|
@ -42,6 +42,8 @@ class CodeReviewSettingsControllerTest < ActionController::TestCase
|
||||||
role.permissions << :view_code_review
|
role.permissions << :view_code_review
|
||||||
role.save
|
role.save
|
||||||
}
|
}
|
||||||
|
@request.session[:ctime] = Time.now.to_i
|
||||||
|
@request.session[:atime] = Time.now.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
role.permissions << :view_code_review
|
role.permissions << :view_code_review
|
||||||
role.save
|
role.save
|
||||||
}
|
}
|
||||||
|
@request.session[:ctime] = Time.now.to_i
|
||||||
|
@request.session[:atime] = Time.now.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show
|
def test_show
|
||||||
|
|
|
@ -26,6 +26,8 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
@controller = ProjectsController.new
|
@controller = ProjectsController.new
|
||||||
@request = ActionController::TestRequest.new
|
@request = ActionController::TestRequest.new
|
||||||
@response = ActionController::TestResponse.new
|
@response = ActionController::TestResponse.new
|
||||||
|
@request.session[:ctime] = Time.now.to_i
|
||||||
|
@request.session[:atime] = Time.now.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#settings" do
|
context "#settings" do
|
||||||
|
|
|
@ -52,6 +52,8 @@ class RepositoriesControllerTest < ActionController::TestCase
|
||||||
role.permissions << :browse_repository
|
role.permissions << :browse_repository
|
||||||
role.save
|
role.save
|
||||||
}
|
}
|
||||||
|
@request.session[:ctime] = Time.now.to_i
|
||||||
|
@request.session[:atime] = Time.now.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_revision
|
def test_revision
|
||||||
|
|
|
@ -117,3 +117,9 @@ FactoryGirl.define do
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
ActiveRecord::Fixtures.create_fixtures(File.dirname(__FILE__)+ '/fixtures/',
|
||||||
|
[ :code_review_assignments,
|
||||||
|
:code_reviews,
|
||||||
|
:code_review_project_settings,
|
||||||
|
:code_review_user_settings])
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,11 @@ class CodeReviewAssignmentTest < ActiveSupport::TestCase
|
||||||
fixtures :code_review_assignments, :issues, :issue_statuses,
|
fixtures :code_review_assignments, :issues, :issue_statuses,
|
||||||
:projects, :trackers, :projects_trackers, :users, :members, :repositories,
|
:projects, :trackers, :projects_trackers, :users, :members, :repositories,
|
||||||
:enumerations
|
:enumerations
|
||||||
|
ActiveRecord::Fixtures.create_fixtures(File.dirname(__FILE__)+ '/../fixtures/',
|
||||||
|
[ :code_review_assignments,
|
||||||
|
:code_reviews,
|
||||||
|
:code_review_project_settings,
|
||||||
|
:code_review_user_settings])
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@assignment = CodeReviewAssignment.new
|
@assignment = CodeReviewAssignment.new
|
||||||
|
|
|
@ -1852,7 +1852,7 @@ span.required {color: #bb0000;}
|
||||||
a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block; padding-left:16px;}
|
a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block; padding-left:16px;}
|
||||||
a.remove-upload:hover {text-decoration:none !important;}
|
a.remove-upload:hover {text-decoration:none !important;}
|
||||||
#attachments_fields input.is_public_checkbox {width:20px;}
|
#attachments_fields input.is_public_checkbox {width:20px;}
|
||||||
#attachments_fields span.ispublic-label {display:inline-block;width:50px;margin-left:10px; }
|
#attachments_fields span.ispublic-label {display:inline-block;width:30px;margin-left:10px; }
|
||||||
|
|
||||||
/*gcm upload file count and deleteall*/
|
/*gcm upload file count and deleteall*/
|
||||||
#upload_file_count #count {color:red; font-size:1.5em;}
|
#upload_file_count #count {color:red; font-size:1.5em;}
|
||||||
|
|
|
@ -1,69 +1,126 @@
|
||||||
---
|
---
|
||||||
courses_006:
|
courses_008:
|
||||||
id: 6
|
id: 8
|
||||||
tea_id: 193
|
tea_id: 5
|
||||||
name:
|
name: 分布式计算环境
|
||||||
state: 0
|
state:
|
||||||
code:
|
code:
|
||||||
time: 2013
|
time: 2013
|
||||||
extra: course2013-09-30_08-11-15
|
extra: course2013-09-30_23-36-00
|
||||||
created_at: 2013-09-30 08:11:15.000000000 +08:00
|
created_at: 2013-09-30 15:36:00.000000000 Z
|
||||||
updated_at: 2013-10-11 12:34:29.000000000 +08:00
|
updated_at: 2014-04-19 01:50:41.000000000 Z
|
||||||
location:
|
location:
|
||||||
term: "秋季学期"
|
term: 春季学期
|
||||||
|
string:
|
||||||
|
password: '1234'
|
||||||
|
setup_time:
|
||||||
|
endup_time: '2014-04-18 00:00:00'
|
||||||
|
class_period: ''
|
||||||
|
school_id: 117
|
||||||
|
description: 介绍分布计算模型,分布计算平台,分布式软件开发环境等分布计算方向的概念、技术和环境,并通过实验提高学生的实践能力。
|
||||||
|
status: 1
|
||||||
|
attachmenttype: 2
|
||||||
|
lft:
|
||||||
|
rgt:
|
||||||
|
is_public: 1
|
||||||
|
inherit_members: 1
|
||||||
|
courses_058:
|
||||||
|
id: 58
|
||||||
|
tea_id: 1168
|
||||||
|
name: 软件工程实践
|
||||||
|
state:
|
||||||
|
code:
|
||||||
|
time: 2014
|
||||||
|
extra: course2014-04-17_17-12-17
|
||||||
|
created_at: 2014-04-17 09:12:17.000000000 Z
|
||||||
|
updated_at: 2014-04-17 09:12:17.000000000 Z
|
||||||
|
location:
|
||||||
|
term: 春季学期
|
||||||
|
string:
|
||||||
|
password: SEP2014
|
||||||
|
setup_time:
|
||||||
|
endup_time:
|
||||||
|
class_period: '18'
|
||||||
|
school_id: 0
|
||||||
|
description: 国防科技大学计算机学院工程硕士专业选修课。
|
||||||
|
status: 1
|
||||||
|
attachmenttype: 2
|
||||||
|
lft:
|
||||||
|
rgt:
|
||||||
|
is_public: 1
|
||||||
|
inherit_members: 1
|
||||||
|
courses_059:
|
||||||
|
id: 59
|
||||||
|
tea_id: 193
|
||||||
|
name: 软件项目管理
|
||||||
|
state:
|
||||||
|
code:
|
||||||
|
time: 2014
|
||||||
|
extra: course2014-04-18_18-10-46
|
||||||
|
created_at: 2014-04-18 10:10:46.000000000 Z
|
||||||
|
updated_at: 2014-04-18 10:10:46.000000000 Z
|
||||||
|
location:
|
||||||
|
term: 春季学期
|
||||||
string:
|
string:
|
||||||
password: software
|
password: software
|
||||||
setup_time:
|
setup_time:
|
||||||
endup_time:
|
endup_time:
|
||||||
class_period:
|
class_period: '30'
|
||||||
courses_004:
|
school_id: 0
|
||||||
id: 4
|
description: 面向“软件工程”专业的本科生
|
||||||
tea_id: 193
|
status: 1
|
||||||
name:
|
attachmenttype: 2
|
||||||
state: 0
|
lft:
|
||||||
code:
|
rgt:
|
||||||
time: 2013
|
is_public: 1
|
||||||
extra: course2013-09-27_11-16-11
|
inherit_members: 1
|
||||||
created_at: 2013-09-27 11:16:11.000000000 +08:00
|
courses_060:
|
||||||
updated_at: 2013-12-21 10:55:20.000000000 +08:00
|
id: 60
|
||||||
location:
|
tea_id: 1179
|
||||||
term: "秋季学期"
|
name: android开发
|
||||||
string:
|
|
||||||
password: '123456'
|
|
||||||
setup_time: ''
|
|
||||||
endup_time: ''
|
|
||||||
class_period: ''
|
|
||||||
courses_012:
|
|
||||||
id: 12
|
|
||||||
tea_id: 193
|
|
||||||
name:
|
|
||||||
state:
|
state:
|
||||||
code:
|
code:
|
||||||
time: 2013
|
time: 2014
|
||||||
extra: course2013-10-08_20-52-10
|
extra: course2014-04-19_15-40-39
|
||||||
created_at: 2013-10-08 20:52:10.000000000 +08:00
|
created_at: 2014-04-19 07:40:39.000000000 Z
|
||||||
updated_at: 2013-10-08 20:52:10.000000000 +08:00
|
updated_at: 2014-04-19 07:40:39.000000000 Z
|
||||||
location:
|
location:
|
||||||
term: "秋季学期"
|
term: 春季学期
|
||||||
string:
|
string:
|
||||||
password: software
|
password: trustie740208
|
||||||
setup_time:
|
setup_time:
|
||||||
endup_time:
|
endup_time:
|
||||||
class_period:
|
class_period: '48'
|
||||||
courses_020:
|
school_id: 37
|
||||||
id: 20
|
description: ''
|
||||||
tea_id: 193
|
status: 1
|
||||||
name:
|
attachmenttype: 2
|
||||||
|
lft:
|
||||||
|
rgt:
|
||||||
|
is_public: 1
|
||||||
|
inherit_members: 1
|
||||||
|
courses_061:
|
||||||
|
id: 61
|
||||||
|
tea_id: 29
|
||||||
|
name: 测试课程1
|
||||||
state:
|
state:
|
||||||
code:
|
code:
|
||||||
time: 2013
|
time: 2014
|
||||||
extra: course2013-10-21_20-47-58
|
extra: course2014-06-04_14-51-56
|
||||||
created_at: 2013-10-21 20:47:58.000000000 +08:00
|
created_at: 2014-06-04 06:51:56.000000000 Z
|
||||||
updated_at: 2014-01-08 09:48:56.000000000 +08:00
|
updated_at: 2014-07-15 01:40:49.000000000 Z
|
||||||
location:
|
location:
|
||||||
term: '秋季学期'
|
term: 春季学期
|
||||||
string:
|
string:
|
||||||
password: multi-agent
|
password: '1234'
|
||||||
setup_time: ''
|
setup_time:
|
||||||
endup_time: ''
|
endup_time: '2014-07-14 00:00:00'
|
||||||
class_period: ''
|
class_period: '23'
|
||||||
|
school_id: 1579
|
||||||
|
description: '233'
|
||||||
|
status: 1
|
||||||
|
attachmenttype: 2
|
||||||
|
lft:
|
||||||
|
rgt:
|
||||||
|
is_public: 0
|
||||||
|
inherit_members: 1
|
||||||
|
|
|
@ -103,3 +103,54 @@ enabled_modules_026:
|
||||||
name: repository
|
name: repository
|
||||||
project_id: 2
|
project_id: 2
|
||||||
id: 26
|
id: 26
|
||||||
|
#trustie
|
||||||
|
enabled_modules_trustie_001:
|
||||||
|
id: 415
|
||||||
|
project_id: -1
|
||||||
|
name: issue_tracking
|
||||||
|
course_id: 8
|
||||||
|
enabled_modules_trustie_002:
|
||||||
|
id: 416
|
||||||
|
project_id: -1
|
||||||
|
name: time_tracking
|
||||||
|
course_id: 8
|
||||||
|
enabled_modules_trustie_003:
|
||||||
|
id: 417
|
||||||
|
project_id: -1
|
||||||
|
name: news
|
||||||
|
course_id: 8
|
||||||
|
enabled_modules_trustie_004:
|
||||||
|
id: 418
|
||||||
|
project_id: -1
|
||||||
|
name: documents
|
||||||
|
course_id: 8
|
||||||
|
enabled_modules_trustie_005:
|
||||||
|
id: 419
|
||||||
|
project_id: -1
|
||||||
|
name: files
|
||||||
|
course_id: 8
|
||||||
|
enabled_modules_trustie_006:
|
||||||
|
id: 420
|
||||||
|
project_id: -1
|
||||||
|
name: wiki
|
||||||
|
course_id: 8
|
||||||
|
enabled_modules_trustie_007:
|
||||||
|
id: 421
|
||||||
|
project_id: -1
|
||||||
|
name: repository
|
||||||
|
course_id: 8
|
||||||
|
enabled_modules_trustie_008:
|
||||||
|
id: 422
|
||||||
|
project_id: -1
|
||||||
|
name: boards
|
||||||
|
course_id: 8
|
||||||
|
enabled_modules_trustie_009:
|
||||||
|
id: 423
|
||||||
|
project_id: -1
|
||||||
|
name: calendar
|
||||||
|
course_id: 8
|
||||||
|
enabled_modules_trustie_010:
|
||||||
|
id: 424
|
||||||
|
project_id: -1
|
||||||
|
name: gantt
|
||||||
|
course_id: 8
|
||||||
|
|
|
@ -47,3 +47,8 @@ member_roles_011:
|
||||||
role_id: 2
|
role_id: 2
|
||||||
member_id: 10
|
member_id: 10
|
||||||
inherited_from: 10
|
inherited_from: 10
|
||||||
|
member_roles_179:
|
||||||
|
id: 179
|
||||||
|
member_id: 126
|
||||||
|
role_id: 3
|
||||||
|
inherited_from:
|
||||||
|
|
|
@ -60,3 +60,10 @@ members_010:
|
||||||
project_id: 2
|
project_id: 2
|
||||||
user_id: 8
|
user_id: 8
|
||||||
mail_notification: false
|
mail_notification: false
|
||||||
|
members_course_001:
|
||||||
|
id: 126
|
||||||
|
user_id: 5
|
||||||
|
project_id: -1
|
||||||
|
created_on: 2013-09-30 15:36:00.000000000 Z
|
||||||
|
mail_notification: false
|
||||||
|
course_id: 8
|
||||||
|
|
|
@ -199,4 +199,158 @@ roles_005:
|
||||||
- :view_changesets
|
- :view_changesets
|
||||||
|
|
||||||
position: 5
|
position: 5
|
||||||
|
roles_trustie_001:
|
||||||
|
id: 7
|
||||||
|
name: 助教
|
||||||
|
position: 6
|
||||||
|
assignable: true
|
||||||
|
builtin: 0
|
||||||
|
permissions:
|
||||||
|
- :add_project
|
||||||
|
- :edit_project
|
||||||
|
- :manage_members
|
||||||
|
- :view_journals_for_messages
|
||||||
|
- :add_course
|
||||||
|
- :edit_course
|
||||||
|
- :close_course
|
||||||
|
- :select_course_modules
|
||||||
|
- :view_course_journals_for_messages
|
||||||
|
- :manage_files
|
||||||
|
- :view_course_files
|
||||||
|
- :comment_news
|
||||||
|
- :manage_boards
|
||||||
|
- :add_messages
|
||||||
|
- :delete_own_messages
|
||||||
|
- :view_calendar
|
||||||
|
- :view_documents
|
||||||
|
- :view_files
|
||||||
|
- :view_gantt
|
||||||
|
- :view_issues
|
||||||
|
- :add_issues
|
||||||
|
- :add_issue_notes
|
||||||
|
- :save_queries
|
||||||
|
- :browse_repository
|
||||||
|
- :view_changesets
|
||||||
|
- :view_time_entries
|
||||||
|
- :view_wiki_pages
|
||||||
|
- :export_wiki_pages
|
||||||
|
- :view_wiki_edits
|
||||||
|
- :edit_wiki_pages
|
||||||
|
- :delete_wiki_pages_attachments
|
||||||
|
- :as_teacher
|
||||||
|
issues_visibility: default
|
||||||
|
roles_trustie_002:
|
||||||
|
id: 9
|
||||||
|
name: 老师
|
||||||
|
position: 7
|
||||||
|
assignable: true
|
||||||
|
builtin: 0
|
||||||
|
permissions:
|
||||||
|
- :add_project
|
||||||
|
- :edit_project
|
||||||
|
- :close_project
|
||||||
|
- :select_project_modules
|
||||||
|
- :manage_members
|
||||||
|
- :manage_versions
|
||||||
|
- :add_subprojects
|
||||||
|
- :view_journals_for_messages
|
||||||
|
- :add_course
|
||||||
|
- :edit_course
|
||||||
|
- :close_course
|
||||||
|
- :select_course_modules
|
||||||
|
- :view_course_journals_for_messages
|
||||||
|
- :manage_files
|
||||||
|
- :view_course_files
|
||||||
|
- :manage_news
|
||||||
|
- :comment_news
|
||||||
|
- :manage_boards
|
||||||
|
- :add_messages
|
||||||
|
- :edit_messages
|
||||||
|
- :edit_own_messages
|
||||||
|
- :delete_messages
|
||||||
|
- :delete_own_messages
|
||||||
|
- :view_calendar
|
||||||
|
- :add_documents
|
||||||
|
- :edit_documents
|
||||||
|
- :delete_documents
|
||||||
|
- :view_documents
|
||||||
|
- :view_files
|
||||||
|
- :view_gantt
|
||||||
|
- :manage_categories
|
||||||
|
- :view_issues
|
||||||
|
- :add_issues
|
||||||
|
- :edit_issues
|
||||||
|
- :manage_issue_relations
|
||||||
|
- :manage_subtasks
|
||||||
|
- :set_issues_private
|
||||||
|
- :set_own_issues_private
|
||||||
|
- :add_issue_notes
|
||||||
|
- :edit_issue_notes
|
||||||
|
- :edit_own_issue_notes
|
||||||
|
- :view_private_notes
|
||||||
|
- :set_notes_private
|
||||||
|
- :move_issues
|
||||||
|
- :delete_issues
|
||||||
|
- :manage_public_queries
|
||||||
|
- :save_queries
|
||||||
|
- :view_issue_watchers
|
||||||
|
- :add_issue_watchers
|
||||||
|
- :delete_issue_watchers
|
||||||
|
- :manage_repository
|
||||||
|
- :browse_repository
|
||||||
|
- :view_changesets
|
||||||
|
- :commit_access
|
||||||
|
- :manage_related_issues
|
||||||
|
- :log_time
|
||||||
|
- :view_time_entries
|
||||||
|
- :edit_time_entries
|
||||||
|
- :edit_own_time_entries
|
||||||
|
- :manage_project_activities
|
||||||
|
- :manage_wiki
|
||||||
|
- :rename_wiki_pages
|
||||||
|
- :delete_wiki_pages
|
||||||
|
- :view_wiki_pages
|
||||||
|
- :export_wiki_pages
|
||||||
|
- :view_wiki_edits
|
||||||
|
- :edit_wiki_pages
|
||||||
|
- :delete_wiki_pages_attachments
|
||||||
|
- :protect_wiki_pages
|
||||||
|
- :as_teacher
|
||||||
|
issues_visibility: default
|
||||||
|
roles_trustie_003:
|
||||||
|
id: 10
|
||||||
|
name: 学生
|
||||||
|
position: 8
|
||||||
|
assignable: true
|
||||||
|
builtin: 0
|
||||||
|
permissions:
|
||||||
|
- :add_project
|
||||||
|
- :view_journals_for_messages
|
||||||
|
- :add_course
|
||||||
|
- :edit_course
|
||||||
|
- :close_course
|
||||||
|
- :select_course_modules
|
||||||
|
- :view_course_journals_for_messages
|
||||||
|
- :view_course_files
|
||||||
|
- :comment_news
|
||||||
|
- :manage_boards
|
||||||
|
- :add_messages
|
||||||
|
- :edit_own_messages
|
||||||
|
- :delete_own_messages
|
||||||
|
- :view_calendar
|
||||||
|
- :view_documents
|
||||||
|
- :view_files
|
||||||
|
- :view_gantt
|
||||||
|
- :view_issues
|
||||||
|
- :add_issues
|
||||||
|
- :add_issue_notes
|
||||||
|
- :save_queries
|
||||||
|
- :browse_repository
|
||||||
|
- :view_changesets
|
||||||
|
- :view_time_entries
|
||||||
|
- :view_wiki_pages
|
||||||
|
- :view_wiki_edits
|
||||||
|
- :paret_in_homework
|
||||||
|
- :as_student
|
||||||
|
issues_visibility: default
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
|
||||||
|
|
||||||
person_one_extra:
|
person_one_extra:
|
||||||
id: 44
|
id: 44
|
||||||
user_id: 29
|
user_id: 29
|
||||||
|
@ -37,3 +35,42 @@ person_mao_extra:
|
||||||
teacher_realname: nil
|
teacher_realname: nil
|
||||||
student_realname: nil
|
student_realname: nil
|
||||||
location_city: nil
|
location_city: nil
|
||||||
|
ue_lirongzhen:
|
||||||
|
id: 587
|
||||||
|
user_id: 642
|
||||||
|
birthday:
|
||||||
|
brief_introduction:
|
||||||
|
gender: 0
|
||||||
|
location: 河南
|
||||||
|
occupation: kylinos-cloud
|
||||||
|
work_experience:
|
||||||
|
zip_code:
|
||||||
|
created_at: 2014-03-18 14:52:55.000000000 Z
|
||||||
|
updated_at: 2014-03-26 07:19:04.000000000 Z
|
||||||
|
technical_title:
|
||||||
|
identity: 1
|
||||||
|
student_id: '14066023'
|
||||||
|
teacher_realname:
|
||||||
|
student_realname:
|
||||||
|
location_city: 周口
|
||||||
|
school_id:
|
||||||
|
ue_yingang:
|
||||||
|
id: 6
|
||||||
|
user_id: 5
|
||||||
|
birthday:
|
||||||
|
brief_introduction: 现有功能的精细化!
|
||||||
|
gender: 0
|
||||||
|
location: 湖南
|
||||||
|
occupation: 国防科学技术大学计算机学院
|
||||||
|
work_experience:
|
||||||
|
zip_code:
|
||||||
|
created_at: 2013-09-24 09:36:12.000000000 Z
|
||||||
|
updated_at: 2014-04-19 08:16:55.000000000 Z
|
||||||
|
technical_title: 副教授
|
||||||
|
identity: 0
|
||||||
|
student_id: ''
|
||||||
|
teacher_realname:
|
||||||
|
student_realname:
|
||||||
|
location_city: 长沙
|
||||||
|
school_id: 117
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ users_003:
|
||||||
login: dlopper
|
login: dlopper
|
||||||
type: User
|
type: User
|
||||||
users_005:
|
users_005:
|
||||||
id: 5
|
id: 12
|
||||||
created_on: 2006-07-19 19:33:19 +02:00
|
created_on: 2006-07-19 19:33:19 +02:00
|
||||||
# Locked
|
# Locked
|
||||||
status: 3
|
status: 3
|
||||||
|
@ -165,5 +165,39 @@ groups_011:
|
||||||
id: 11
|
id: 11
|
||||||
lastname: B Team
|
lastname: B Team
|
||||||
type: Group
|
type: Group
|
||||||
|
users_yingang_teacher:
|
||||||
|
id: 5
|
||||||
|
login: jacknudt
|
||||||
|
hashed_password: dbbd96684c9a64afe9c4935ce0b517e5e9c08064
|
||||||
|
firstname: 刚
|
||||||
|
lastname: 尹
|
||||||
|
mail: jack_nudt@163.com
|
||||||
|
admin: false
|
||||||
|
status: 1
|
||||||
|
last_login_on: 2014-04-27 13:49:18.000000000 Z
|
||||||
|
language: zh
|
||||||
|
auth_source_id:
|
||||||
|
created_on: 2013-06-25 05:20:59.000000000 Z
|
||||||
|
updated_on: 2014-07-16 03:37:51.000000000 Z
|
||||||
|
type: User
|
||||||
|
identity_url:
|
||||||
|
mail_notification: only_my_events
|
||||||
|
salt: 92944df2ce4dae1a4f01007263c5d8bb
|
||||||
|
users_lirongzhen_student:
|
||||||
|
id: 642
|
||||||
|
login: lirongzhen
|
||||||
|
hashed_password: 070922b015398577c3ae0d87a68d5ffa93bf82e9
|
||||||
|
firstname: 荣振
|
||||||
|
lastname: 李
|
||||||
|
mail: lrongzheni@gmail.com
|
||||||
|
admin: false
|
||||||
|
status: 1
|
||||||
|
last_login_on: 2014-04-16 14:06:07.000000000 Z
|
||||||
|
language: zh
|
||||||
|
auth_source_id:
|
||||||
|
created_on: 2014-03-18 14:52:55.000000000 Z
|
||||||
|
updated_on: 2014-03-26 07:19:04.000000000 Z
|
||||||
|
type: User
|
||||||
|
identity_url:
|
||||||
|
mail_notification: all
|
||||||
|
salt: dca66d84fcb88b37de04dd3058f73576
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
require File.expand_path('../../test_helper', __FILE__)
|
||||||
|
|
||||||
|
class CoursesControllerTest < ActionController::TestCase
|
||||||
|
fixtures :courses, :users, :user_extensions, :roles, :members, :member_roles, :enabled_modules, :boards, :messages
|
||||||
|
|
||||||
|
def setup
|
||||||
|
@request.session[:user_id] = nil
|
||||||
|
@request.session[:ctime] = Time.now.to_i
|
||||||
|
@request.session[:atime] = Time.now.to_i
|
||||||
|
Setting.default_language = 'en'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_index_by_anonymous_should_not_show_private_projects
|
||||||
|
get :index
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'index'
|
||||||
|
courses = assigns(:courses)
|
||||||
|
assert_not_nil courses
|
||||||
|
assert courses.all?(&:is_public?)
|
||||||
|
end
|
||||||
|
|
||||||
|
# 人员添加课程的权限是不属于任何角色
|
||||||
|
def test_new_course_anyone_temporary
|
||||||
|
@request.session[:user_id] = 5
|
||||||
|
Role.find_by_name("Non member").add_permission! :add_course #Non member
|
||||||
|
|
||||||
|
get :new
|
||||||
|
assert_response :success
|
||||||
|
assert_template :new
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_create_course_with_access_control
|
||||||
|
@request.session[:user_id] = 5
|
||||||
|
Role.find_by_name("Non member").add_permission! :add_course #Non member
|
||||||
|
course_name = 'course_one'
|
||||||
|
|
||||||
|
post :create,
|
||||||
|
:class_period => '32',
|
||||||
|
:time => '2014',
|
||||||
|
:term => 'spring',
|
||||||
|
:course => {
|
||||||
|
:name => course_name, # names can't contain space.
|
||||||
|
:password => '1234',
|
||||||
|
:description => 'description',
|
||||||
|
:is_public => '1',
|
||||||
|
:course_type => '1'
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_response :found
|
||||||
|
course = Course.find_by_name(course_name)
|
||||||
|
red_url = "courses/#{course.id}/settings"
|
||||||
|
assert_match %r(#{red_url}), @response.redirect_url
|
||||||
|
# 创建成功跳转settings方法会带参数一枚,故一下方法失败
|
||||||
|
# assert_redirected_to "courses/#{course.id}/settings"
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_create_course_without_access_control
|
||||||
|
@request.session[:user_id] = 5
|
||||||
|
#Role.find_by_name("Non member").add_permission! :add_course #Non member
|
||||||
|
course_name = 'course_one'
|
||||||
|
|
||||||
|
post :create,
|
||||||
|
:class_period => '32',
|
||||||
|
:time => '2014',
|
||||||
|
:term => 'spring',
|
||||||
|
:course => {
|
||||||
|
:name => course_name, # names can't contain space.
|
||||||
|
:password => '1234',
|
||||||
|
:description => 'description',
|
||||||
|
:is_public => '1',
|
||||||
|
:course_type => '1'
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_response :forbidden
|
||||||
|
end
|
||||||
|
|
||||||
|
# test "#index by non-admin user with view_time_entries permission should show overall spent time link" do
|
||||||
|
# @request.session[:user_id] = 3
|
||||||
|
# get :index
|
||||||
|
# assert_template 'index'
|
||||||
|
# assert_select 'a[href=?]', '/time_entries'
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# test "#index by non-admin user without view_time_entries permission should not show overall spent time link" do
|
||||||
|
# Role.find(2).remove_permission! :view_time_entries
|
||||||
|
# Role.non_member.remove_permission! :view_time_entries
|
||||||
|
# Role.anonymous.remove_permission! :view_time_entries
|
||||||
|
# @request.session[:user_id] = 3
|
||||||
|
#
|
||||||
|
# get :index
|
||||||
|
# assert_template 'index'
|
||||||
|
# assert_select 'a[href=?]', '/time_entries', 0
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue