Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
Conflicts: db/schema.rb
This commit is contained in:
commit
53ff6ea335
35
Gemfile
35
Gemfile
|
@ -1,4 +1,4 @@
|
|||
source 'https://rubygems.org'
|
||||
source 'https://ruby.taobao.org'
|
||||
|
||||
unless RUBY_PLATFORM =~ /w32/
|
||||
# unix-like only
|
||||
|
@ -19,19 +19,33 @@ gem 'acts-as-taggable-on', '2.4.1'
|
|||
group :development do
|
||||
gem 'better_errors', path: 'lib/better_errors'
|
||||
gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler'
|
||||
if ENV['PRY']
|
||||
gem 'pry'
|
||||
gem 'pry-nav'
|
||||
end
|
||||
end
|
||||
|
||||
group :test do
|
||||
# shoulda的版本做了改动
|
||||
#gem "shoulda", "~> 3.3.2"
|
||||
gem "shoulda", "> 3.3.2"
|
||||
gem "mocha", "~> 0.13.3"
|
||||
gem 'capybara', '~> 2.0.0'
|
||||
gem 'nokogiri', '< 1.6.0'
|
||||
|
||||
platforms :mri, :mingw do
|
||||
group :rmagick do
|
||||
# RMagick 2 supports ruby 1.9
|
||||
# RMagick 1 would be fine for ruby 1.8 but Bundler does not support
|
||||
# different requirements for the same gem on different platforms
|
||||
gem "rmagick", ">= 2.0.0"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
gem "guard-rails"
|
||||
gem 'spork-testunit'
|
||||
gem 'guard-spork'
|
||||
gem 'guard-test', '~> 1.0.0'
|
||||
gem 'ruby-prof'
|
||||
gem 'pry'
|
||||
gem 'pry-nav'
|
||||
end
|
||||
|
||||
|
||||
|
@ -53,15 +67,6 @@ group :ldap do
|
|||
end
|
||||
|
||||
|
||||
platforms :mri, :mingw do
|
||||
group :rmagick do
|
||||
# RMagick 2 supports ruby 1.9
|
||||
# RMagick 1 would be fine for ruby 1.8 but Bundler does not support
|
||||
# different requirements for the same gem on different platforms
|
||||
gem "rmagick", ">= 2.0.0"
|
||||
end
|
||||
end
|
||||
|
||||
# Optional gem for OpenID authentication
|
||||
group :openid do
|
||||
gem "ruby-openid", "~> 2.1.4", :require => "openid"
|
||||
|
|
104
Gemfile.lock
104
Gemfile.lock
|
@ -19,7 +19,7 @@ PATH
|
|||
rails
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
remote: https://ruby.taobao.org/
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (3.2.13)
|
||||
|
@ -51,7 +51,7 @@ GEM
|
|||
multi_json (~> 1.0)
|
||||
acts-as-taggable-on (2.4.1)
|
||||
rails (>= 3, < 5)
|
||||
arel (3.0.2)
|
||||
arel (3.0.3)
|
||||
builder (3.0.0)
|
||||
capybara (2.0.3)
|
||||
mime-types (>= 1.16)
|
||||
|
@ -60,6 +60,8 @@ GEM
|
|||
rack-test (>= 0.5.4)
|
||||
selenium-webdriver (~> 2.0)
|
||||
xpath (~> 1.0.0)
|
||||
celluloid (0.15.2)
|
||||
timers (~> 1.1.0)
|
||||
childprocess (0.5.3)
|
||||
ffi (~> 1.0, >= 1.0.11)
|
||||
climate_control (0.0.3)
|
||||
|
@ -70,51 +72,89 @@ GEM
|
|||
coffee-rails (3.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (~> 3.2.0)
|
||||
coffee-script (2.2.0)
|
||||
coffee-script (2.3.0)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.7.0)
|
||||
coffee-script-source (1.7.1)
|
||||
erubis (2.7.0)
|
||||
execjs (2.0.2)
|
||||
fastercsv (1.5.0)
|
||||
execjs (2.2.1)
|
||||
fastercsv (1.5.5)
|
||||
ffi (1.9.3)
|
||||
ffi (1.9.3-x86-mingw32)
|
||||
formatador (0.2.5)
|
||||
guard (2.6.1)
|
||||
formatador (>= 0.2.4)
|
||||
listen (~> 2.7)
|
||||
lumberjack (~> 1.0)
|
||||
pry (>= 0.9.12)
|
||||
thor (>= 0.18.1)
|
||||
guard-rails (0.5.2)
|
||||
guard (~> 2.0)
|
||||
guard-spork (1.5.1)
|
||||
childprocess (>= 0.2.3)
|
||||
guard (>= 1.1)
|
||||
spork (>= 0.8.4)
|
||||
guard-test (1.0.0)
|
||||
guard (>= 1.8)
|
||||
test-unit (~> 2.2)
|
||||
hike (1.2.3)
|
||||
htmlentities (4.3.2)
|
||||
i18n (0.6.1)
|
||||
iconv (1.0.4)
|
||||
journey (1.0.4)
|
||||
jquery-rails (2.0.3)
|
||||
railties (>= 3.1.0, < 5.0)
|
||||
thor (~> 0.14)
|
||||
json (1.8.0)
|
||||
json (1.8.1)
|
||||
kaminari (0.16.1)
|
||||
actionpack (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
libv8 (3.16.14.3)
|
||||
listen (2.7.9)
|
||||
celluloid (>= 0.15.2)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9)
|
||||
lumberjack (1.0.9)
|
||||
mail (2.5.4)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
metaclass (0.0.4)
|
||||
mime-types (1.23)
|
||||
method_source (0.8.2)
|
||||
mime-types (1.25.1)
|
||||
mocha (0.13.3)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.7.6)
|
||||
multi_json (1.10.1)
|
||||
mysql2 (0.3.11)
|
||||
mysql2 (0.3.11-x86-mingw32)
|
||||
net-ldap (0.3.1)
|
||||
nokogiri (1.5.11)
|
||||
nokogiri (1.5.11-x86-mingw32)
|
||||
paperclip (3.5.4)
|
||||
activemodel (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
cocaine (~> 0.5.3)
|
||||
mime-types
|
||||
polyglot (0.3.3)
|
||||
polyglot (0.3.5)
|
||||
pry (0.9.12.6)
|
||||
coderay (~> 1.0)
|
||||
method_source (~> 0.8)
|
||||
slop (~> 3.4)
|
||||
pry (0.9.12.6-x86-mingw32)
|
||||
coderay (~> 1.0)
|
||||
method_source (~> 0.8)
|
||||
slop (~> 3.4)
|
||||
win32console (~> 1.3)
|
||||
pry-nav (0.2.3)
|
||||
pry (~> 0.9.10)
|
||||
rack (1.4.5)
|
||||
rack-cache (1.2)
|
||||
rack (>= 0.4)
|
||||
rack-openid (1.3.1)
|
||||
rack-openid (1.4.2)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-raw-upload (1.1.1)
|
||||
multi_json
|
||||
rack-ssl (1.3.3)
|
||||
rack-ssl (1.3.4)
|
||||
rack
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
|
@ -134,8 +174,12 @@ GEM
|
|||
rdoc (~> 3.4)
|
||||
thor (>= 0.14.6, < 2.0)
|
||||
rake (10.3.2)
|
||||
rb-fsevent (0.9.4)
|
||||
rb-inotify (0.9.5)
|
||||
ffi (>= 0.5.0)
|
||||
rdoc (3.12.2)
|
||||
json (~> 1.4)
|
||||
ref (1.0.5)
|
||||
rich (1.4.6)
|
||||
jquery-rails
|
||||
kaminari
|
||||
|
@ -146,8 +190,9 @@ GEM
|
|||
sass-rails
|
||||
rmagick (2.13.2)
|
||||
ruby-openid (2.1.8)
|
||||
rubyzip (1.1.4)
|
||||
sass (3.2.14)
|
||||
ruby-prof (0.15.1)
|
||||
rubyzip (1.1.6)
|
||||
sass (3.3.10)
|
||||
sass-rails (3.2.6)
|
||||
railties (~> 3.2.0)
|
||||
sass (>= 3.1.10)
|
||||
|
@ -163,25 +208,38 @@ GEM
|
|||
shoulda-context (1.2.1)
|
||||
shoulda-matchers (2.6.1)
|
||||
activesupport (>= 3.0.0)
|
||||
slop (3.5.0)
|
||||
spork (0.9.2)
|
||||
spork-testunit (0.0.8)
|
||||
spork (>= 0.6.0)
|
||||
sprockets (2.2.2)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
thor (0.18.1)
|
||||
test-unit (2.5.5)
|
||||
therubyracer (0.12.1)
|
||||
libv8 (~> 3.16.14.0)
|
||||
ref
|
||||
thor (0.19.1)
|
||||
tilt (1.4.1)
|
||||
treetop (1.4.14)
|
||||
timers (1.1.0)
|
||||
treetop (1.4.15)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.37)
|
||||
uglifier (2.4.0)
|
||||
tzinfo (0.3.40)
|
||||
uglifier (2.5.1)
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
websocket (1.0.7)
|
||||
win32console (1.3.2-x86-mingw32)
|
||||
xpath (1.0.0)
|
||||
nokogiri (~> 1.3)
|
||||
zip-zip (0.3)
|
||||
rubyzip (>= 1.0.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
x86-mingw32
|
||||
|
||||
DEPENDENCIES
|
||||
|
@ -194,8 +252,12 @@ DEPENDENCIES
|
|||
coderay (~> 1.0.6)
|
||||
coffee-rails (~> 3.2.1)
|
||||
fastercsv (~> 1.5.0)
|
||||
guard-rails
|
||||
guard-spork
|
||||
guard-test (~> 1.0.0)
|
||||
htmlentities
|
||||
i18n (~> 0.6.0)
|
||||
iconv
|
||||
jquery-rails (~> 2.0.2)
|
||||
kaminari
|
||||
mocha (~> 0.13.3)
|
||||
|
@ -203,14 +265,20 @@ DEPENDENCIES
|
|||
net-ldap (~> 0.3.1)
|
||||
nokogiri (< 1.6.0)
|
||||
paperclip (~> 3.5.4)
|
||||
pry
|
||||
pry-nav
|
||||
rack-mini-profiler!
|
||||
rack-openid
|
||||
rails (= 3.2.13)
|
||||
rich (= 1.4.6)
|
||||
rmagick (>= 2.0.0)
|
||||
ruby-openid (~> 2.1.4)
|
||||
ruby-prof
|
||||
rubyzip
|
||||
sass-rails (~> 3.2.3)
|
||||
seems_rateable!
|
||||
shoulda (> 3.3.2)
|
||||
spork-testunit
|
||||
therubyracer
|
||||
uglifier (>= 1.0.3)
|
||||
zip-zip
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
# More info at https://github.com/guard/guard#readme
|
||||
|
||||
# guard 'rails' do
|
||||
# watch('Gemfile.lock')
|
||||
# watch(%r{^(config|lib)/.*})
|
||||
# end
|
||||
#
|
||||
guard 'spork', :test_unit => true, :test_unit_env => {'RAILS_ENV' => 'test'}, :wait => 60 do
|
||||
watch('config/application.rb')
|
||||
watch('config/environment.rb')
|
||||
watch('config/environments/test.rb')
|
||||
watch(%r{^config/initializers/.+\.rb$})
|
||||
watch('Gemfile.lock')
|
||||
watch('spec/spec_helper.rb') { :rspec }
|
||||
watch('test/test_helper.rb') { :test_unit }
|
||||
watch(%r{features/support/}) { :cucumber }
|
||||
end
|
||||
|
||||
guard :test, :drb => true, :all_after_pass => false, :all_on_start => false do
|
||||
watch(%r{^test/.+_test\.rb$})
|
||||
watch('test/test_helper.rb') { 'test' }
|
||||
|
||||
# Non-rails
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
||||
|
||||
# Rails 4
|
||||
# watch(%r{^app/(.+)\.rb}) { |m| "test/#{m[1]}_test.rb" }
|
||||
# watch(%r{^app/controllers/application_controller\.rb}) { 'test/controllers' }
|
||||
# watch(%r{^app/controllers/(.+)_controller\.rb}) { |m| "test/integration/#{m[1]}_test.rb" }
|
||||
# watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
|
||||
# watch(%r{^lib/(.+)\.rb}) { |m| "test/lib/#{m[1]}_test.rb" }
|
||||
|
||||
# Rails < 4
|
||||
watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
|
||||
watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
|
||||
watch(%r{^app/views/(.+)/.+\.erb$}) { |m| "test/functional/#{m[1]}_controller_test.rb" }
|
||||
watch(%r{^app/views/.+$}) { 'test/integration' }
|
||||
watch('app/controllers/application_controller.rb') { ['test/functional', 'test/integration'] }
|
||||
end
|
|
@ -630,7 +630,13 @@ class CoursesController < ApplicationController
|
|||
:with_subprojects => false,
|
||||
:author => @author)
|
||||
@activity.scope_select {|t| has["show_#{t}"]}
|
||||
events = @activity.events(@date_from, @date_to)
|
||||
# modify by nwb
|
||||
# 添加私密性判断
|
||||
if User.current.member_of_course?(@course)|| User.current.admin?
|
||||
events = @activity.events(@date_from, @date_to)
|
||||
else
|
||||
events = @activity.events(@date_from, @date_to, :is_public => 1)
|
||||
end
|
||||
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@events_count = events.count
|
||||
|
|
|
@ -23,6 +23,7 @@ class DocumentsController < ApplicationController
|
|||
before_filter :find_model_object, :except => [:index, :new, :create]
|
||||
before_filter :find_project_from_association, :except => [:index, :new, :create]
|
||||
before_filter :authorize , :except => [:index]#Added by young
|
||||
before_filter :authorize_document
|
||||
|
||||
helper :attachments
|
||||
|
||||
|
@ -100,4 +101,12 @@ class DocumentsController < ApplicationController
|
|||
end
|
||||
redirect_to document_path(@document)
|
||||
end
|
||||
|
||||
# 权限判断
|
||||
# add by nwb
|
||||
def authorize_document
|
||||
if !(User.current.admin? || User.current.member_of?(@project) || @document.is_public==1)
|
||||
render_403 :message => :notice_not_authorized
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -697,8 +697,14 @@ class ProjectsController < ApplicationController
|
|||
@activity.scope_select {|t| !has["show_#{t}"].nil?}
|
||||
# logger.debug "=========================================#{@activity.scope}"
|
||||
# @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
|
||||
#Added by young
|
||||
events = @activity.events(@date_from, @date_to)
|
||||
|
||||
# modify by nwb
|
||||
# 添加私密性判断
|
||||
if User.current.member_of?(@project)|| User.current.admin?
|
||||
events = @activity.events(@date_from, @date_to)
|
||||
else
|
||||
events = @activity.events(@date_from, @date_to, :is_public => 1)
|
||||
end
|
||||
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@events_count = events.count
|
||||
|
|
|
@ -92,57 +92,74 @@ class RepositoriesController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
##xianbo
|
||||
@root_path=RepositoriesHelper::ROOT_PATH
|
||||
@repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
|
||||
@project_path=@root_path+"htdocs/"+@repository_name
|
||||
@repository_tag=params[:repository][:upassword]
|
||||
@repo_name=User.current.login.to_s+"_"+params[:repository][:identifier]
|
||||
logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag
|
||||
logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name
|
||||
attrs = pickup_extra_info
|
||||
if((@repository_tag!="")&¶ms[:repository_scm]=="Git")
|
||||
if params[:repository_scm].to_s == 'Gitlab'
|
||||
# add by nwb
|
||||
# 增加对gitlab版本库的支持
|
||||
attrs = pickup_extra_info
|
||||
@repository = Repository.factory(params[:repository_scm])
|
||||
@repository.safe_attributes = params[:repository]
|
||||
if attrs[:attrs_extra].keys.any?
|
||||
@repository.merge_extra_info(attrs[:attrs_extra])
|
||||
end
|
||||
@repository.project = @project
|
||||
if request.post? && @repository.save
|
||||
redirect_to settings_project_path(@project, :tab => 'repositories')
|
||||
else
|
||||
render :action => 'new'
|
||||
end
|
||||
else # 原逻辑
|
||||
##xianbo
|
||||
@root_path=RepositoriesHelper::ROOT_PATH
|
||||
@repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
|
||||
@project_path=@root_path+"htdocs/"+@repository_name
|
||||
@repository_tag=params[:repository][:upassword]
|
||||
@repo_name=User.current.login.to_s+"_"+params[:repository][:identifier]
|
||||
logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag
|
||||
logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name
|
||||
attrs = pickup_extra_info
|
||||
if((@repository_tag!="")&¶ms[:repository_scm]=="Git")
|
||||
params[:repository][:url]=@project_path
|
||||
end
|
||||
###xianbo
|
||||
@repository = Repository.factory(params[:repository_scm])
|
||||
@repository.safe_attributes = params[:repository]
|
||||
if attrs[:attrs_extra].keys.any?
|
||||
@repository.merge_extra_info(attrs[:attrs_extra])
|
||||
end
|
||||
#by xianbo
|
||||
|
||||
@repository.project = @project
|
||||
if request.post? && @repository.save
|
||||
if(params[:repository_scm]=="Git")
|
||||
system "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+" "+@repository_tag
|
||||
system "echo -e '"+@repo_name+"-write:"+
|
||||
" "+@repo_name+"' >> "+@root_path+"group.passwd"
|
||||
system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s
|
||||
system "git init --bare "+@project_path
|
||||
system "mv "+@project_path+"/hooks/post-update{.sample,}"
|
||||
system "chmod a+x "+@project_path+"/hooks/post-update"
|
||||
system "echo -e 'Allow from all \n Order Deny,Allow \n "+
|
||||
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
|
||||
"Require group "+@repo_name+"-write \n "+
|
||||
"</Limit> \n ' >> "+
|
||||
@root_path+"htdocs/"+ @repository_name+"/.htaccess"
|
||||
system "cd "+@project_path+" ;git update-server-info"
|
||||
# if(create_repo_file&&create_passwd&&create_group&&init_repository&&add_privilege&&init_server_info)
|
||||
# else
|
||||
# logger.info "An error occured when authenticating "+"create passwd"+@creat_passwd+"create_group"+
|
||||
# crate_group+"create repository file "+create_repo_file+"init repository"+init_repostory+
|
||||
# "aad privilege to rpository"+add_privilege+"init server infos"+init_server_info
|
||||
# end
|
||||
end
|
||||
###xianbo
|
||||
@repository = Repository.factory(params[:repository_scm])
|
||||
@repository.safe_attributes = params[:repository]
|
||||
if attrs[:attrs_extra].keys.any?
|
||||
@repository.merge_extra_info(attrs[:attrs_extra])
|
||||
end
|
||||
#by xianbo
|
||||
|
||||
@repository.project = @project
|
||||
if request.post? && @repository.save
|
||||
if(params[:repository_scm]=="Git")
|
||||
system "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+" "+@repository_tag
|
||||
system "echo -e '"+@repo_name+"-write:"+
|
||||
" "+@repo_name+"' >> "+@root_path+"group.passwd"
|
||||
system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s
|
||||
system "git init --bare "+@project_path
|
||||
system "mv "+@project_path+"/hooks/post-update{.sample,}"
|
||||
system "chmod a+x "+@project_path+"/hooks/post-update"
|
||||
system "echo -e 'Allow from all \n Order Deny,Allow \n "+
|
||||
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
|
||||
"Require group "+@repo_name+"-write \n "+
|
||||
"</Limit> \n ' >> "+
|
||||
@root_path+"htdocs/"+ @repository_name+"/.htaccess"
|
||||
system "cd "+@project_path+" ;git update-server-info"
|
||||
# if(create_repo_file&&create_passwd&&create_group&&init_repository&&add_privilege&&init_server_info)
|
||||
# else
|
||||
# logger.info "An error occured when authenticating "+"create passwd"+@creat_passwd+"create_group"+
|
||||
# crate_group+"create repository file "+create_repo_file+"init repository"+init_repostory+
|
||||
# "aad privilege to rpository"+add_privilege+"init server infos"+init_server_info
|
||||
# end
|
||||
@repository.update_attributes(:login => User.current.login.to_s)
|
||||
end
|
||||
redirect_to settings_project_path(@project, :tab => 'repositories')
|
||||
else if(@repository_tag)
|
||||
render :action => 'newrepo', :layout =>'base_projects'
|
||||
else
|
||||
render :action => 'new', :layout =>'base_projects'
|
||||
end
|
||||
redirect_to settings_project_path(@project, :tab => 'repositories')
|
||||
else if(@repository_tag)
|
||||
render :action => 'newrepo', :layout =>'base_projects'
|
||||
else
|
||||
render :action => 'new', :layout =>'base_projects'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
|
|
|
@ -80,11 +80,12 @@ module ApplicationHelper
|
|||
name = h(user.name(options[:format]))
|
||||
end
|
||||
|
||||
if user.active? || (User.current.admin? && user.logged?)
|
||||
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes
|
||||
else
|
||||
name
|
||||
end
|
||||
#if user.active? || (User.current.admin? && user.logged?)
|
||||
# link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes
|
||||
#else
|
||||
# name
|
||||
#end
|
||||
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes
|
||||
else
|
||||
h(user.to_s)
|
||||
end
|
||||
|
|
|
@ -39,19 +39,22 @@ class Attachment < ActiveRecord::Base
|
|||
|
||||
#课程资源文件
|
||||
acts_as_activity_provider :type => 'course_files',
|
||||
:is_public => 'attachments.is_public',
|
||||
:permission => :view_files,
|
||||
:author_key => :author_id,
|
||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||
:joins => "LEFT JOIN #{Course.table_name} ON ( #{Attachment.table_name}.container_type='Course' AND #{Attachment.table_name}.container_id = #{Course.table_name}.id )"}
|
||||
|
||||
acts_as_activity_provider :type => 'files',
|
||||
:is_public => 'attachments.is_public',
|
||||
:permission => :view_files,
|
||||
:author_key => :author_id,
|
||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||
:find_options => { :select => "#{Attachment.table_name}.*",
|
||||
:joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||
"LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )"}
|
||||
|
||||
acts_as_activity_provider :type => 'documents',
|
||||
:is_public => 'documents.is_public',
|
||||
:permission => :view_documents,
|
||||
:author_key => :author_id,
|
||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||
|
|
|
@ -30,7 +30,8 @@ class Document < ActiveRecord::Base
|
|||
acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"},
|
||||
:author => Proc.new {|o| o.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) },
|
||||
:url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}}
|
||||
acts_as_activity_provider :find_options => {:include => :project}
|
||||
acts_as_activity_provider :find_options => {:include => :project},
|
||||
:is_public => 'documents.is_public'
|
||||
|
||||
validates_presence_of :project, :title, :category
|
||||
validates_length_of :title, :maximum => 60
|
||||
|
@ -39,7 +40,7 @@ class Document < ActiveRecord::Base
|
|||
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args))
|
||||
}
|
||||
|
||||
safe_attributes 'category_id', 'title', 'description'
|
||||
safe_attributes 'category_id', 'title', 'description','is_public'
|
||||
|
||||
def visible?(user=User.current)
|
||||
!user.nil? && user.allowed_to?(:view_documents, project)
|
||||
|
|
|
@ -163,7 +163,7 @@ class Setting < ActiveRecord::Base
|
|||
end
|
||||
|
||||
# fixed domain url in development. tantantan's bug
|
||||
if Rails.env.development?
|
||||
if Rails.env.development? || Rails.env.test?
|
||||
methods.map do |m|
|
||||
define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/
|
||||
end
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<%= error_messages_for @document %>
|
||||
|
||||
<div class="box tabular">
|
||||
<p><%= f.select :category_id, DocumentCategory.active.collect {|c| [c.name, c.id]} %></p>
|
||||
<p><%= f.select :category_id, DocumentCategory.active.collect {|c| [c.name, c.id]} %> </p>
|
||||
<p> <em style ="display: block;font-size: 90%;font-style: normal;"><%= f.check_box :is_public, :style => "margin-left:10px;" %>
|
||||
<%= l(:label_document_public_info) %></em>
|
||||
</p>
|
||||
<p><%= f.text_field :title, :required => true, :size => 60 %></p>
|
||||
<p><%= f.text_area :description, :cols => 60, :rows => 15, :class => 'wiki-edit' %></p>
|
||||
</div>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
</tr>
|
||||
<% end -%>
|
||||
<% container.attachments.each do |file| %>
|
||||
<%if file.is_public == 0 && !User.current.member_of?(@project)%>
|
||||
<%if file.is_public == 0 && !User.current.member_of_course?(@course)%>
|
||||
<%next%>
|
||||
<%end%>
|
||||
<tr class="file <%= cycle("odd", "odd") %>">
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<% @containers.each do |container| %>
|
||||
<% next if container.attachments.empty? -%>
|
||||
<% container.attachments.each do |file| %>
|
||||
<% if file.is_public == 0 && !User.current.member_of?(@project) %>
|
||||
<% if file.is_public == 0 && !User.current.member_of_course?(@course) %>
|
||||
<% next %>
|
||||
<% end %>
|
||||
<% if isTypeOk(file, selAttachType, selContentType) %>
|
||||
|
|
|
@ -33,21 +33,27 @@
|
|||
<%= image_tag "/images/time_member.png", :class => "img_member_time"%>
|
||||
|
||||
<div>
|
||||
<%= image_tag(url_to_avatar(user), :class => 'avatar') %>
|
||||
<%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %>
|
||||
|
||||
<!-- modified by bai -->
|
||||
<div style="position:relative;float:left;margin-top:-2px;margin-left: 160px">
|
||||
<span style="color:#ec6300">
|
||||
<%= render :partial => 'users/user_score', :locals => {:user => user}%></span>
|
||||
</div>
|
||||
<!-- end -->
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 20px;margin-left:66px">
|
||||
<%= l(:label_x_has_fans,:count=>user.watcher_users.count)%>
|
||||
<%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %>
|
||||
|
||||
<table style="width: 100%;table-layout: fixed">
|
||||
<tr>
|
||||
<td rowspan="2" style="width: 60px;">
|
||||
<%= image_tag(url_to_avatar(user), :class => 'avatar') %>
|
||||
</td>
|
||||
<td style="width: 200px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title="<%= user.name %>">
|
||||
<span style="position: relative;font-size: 16px;display:block; "><%= link_to_user(user) %></span>
|
||||
</td>
|
||||
<td>
|
||||
<span style="color:#ec6300">
|
||||
<%= render :partial => 'users/user_score', :locals => {:user => user}%>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<%= l(:label_x_has_fans,:count=>user.watcher_users.count)%>
|
||||
<%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="user-bottom">
|
||||
<% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %>
|
||||
|
|
|
@ -537,6 +537,7 @@ en:
|
|||
label_document_new: New document
|
||||
label_document_plural: Documents
|
||||
label_document_added: Document added
|
||||
label_document_public_info: "If you don't choose public, only the project's members can see the document."
|
||||
label_role: Role
|
||||
label_role_plural: Roles
|
||||
label_role_new: New role
|
||||
|
|
|
@ -538,6 +538,7 @@ zh:
|
|||
label_document_new: 新建文档
|
||||
label_document_plural: 文档
|
||||
label_document_added: 文档已添加
|
||||
label_document_public_info: (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该文档。)
|
||||
label_role: 角色
|
||||
label_role_plural: 角色
|
||||
label_role_new: 新建角色
|
||||
|
|
|
@ -577,7 +577,6 @@ RedmineApp::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
match 'projects/course', :to => 'courses#course', :as => 'courses_course'
|
||||
match 'courses/search', :to => 'courses#search'
|
||||
# add by nwb
|
||||
# 课程路由设置
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddIsPublicToDocuments < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :documents, :is_public, :integer,:default => 1
|
||||
end
|
||||
end
|
Binary file not shown.
|
@ -29,7 +29,7 @@ module Redmine
|
|||
send :include, Redmine::Acts::ActivityProvider::InstanceMethods
|
||||
end
|
||||
|
||||
options.assert_valid_keys(:type, :permission, :timestamp, :author_key, :find_options, :func)
|
||||
options.assert_valid_keys(:type, :permission, :timestamp, :author_key, :find_options, :func,:is_public)
|
||||
self.activity_provider_options ||= {}
|
||||
|
||||
# One model can provide different event types
|
||||
|
@ -65,6 +65,11 @@ module Redmine
|
|||
scope = scope.scoped(:conditions => ["#{provider_options[:author_key]} = ?", options[:author].id])
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
if options[:is_public] && !provider_options[:is_public].nil?
|
||||
scope = scope.scoped(:conditions => ["#{provider_options[:is_public]} = ?", options[:is_public]])
|
||||
end
|
||||
|
||||
if options[:limit]
|
||||
# id and creation time should be in same order in most cases
|
||||
scope = scope.scoped(:order => "#{table_name}.id DESC", :limit => options[:limit])
|
||||
|
|
|
@ -8,7 +8,7 @@ gem 'actionpack'
|
|||
require 'action_controller'
|
||||
|
||||
gem 'mocha'
|
||||
require 'mocha'
|
||||
require 'mocha/setup'
|
||||
|
||||
gem 'ruby-openid'
|
||||
require 'openid'
|
||||
|
|
|
@ -82,6 +82,8 @@ module Redmine
|
|||
def events(from = nil, to = nil, options={})
|
||||
e = []
|
||||
@options[:limit] = options[:limit]
|
||||
# modify by nwb
|
||||
@options[:is_public] = options[:is_public]
|
||||
|
||||
@scope.each do |event_type|
|
||||
constantized_providers(event_type).each do |provider|
|
||||
|
|
Binary file not shown.
|
@ -18,7 +18,7 @@
|
|||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
begin
|
||||
require 'mocha'
|
||||
require 'mocha/setup'
|
||||
rescue
|
||||
# Won't run some tests
|
||||
end
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../test_helper', __FILE__)
|
||||
|
||||
class RoutingProjectsTest < ActionController::IntegrationTest
|
||||
def test_courses
|
||||
assert_routing(
|
||||
{ :method => 'get', :path => "/courses" },
|
||||
{ :controller => 'courses', :action => 'index' }
|
||||
)
|
||||
end
|
||||
def test_courses_search
|
||||
assert_routing(
|
||||
"/courses/search",
|
||||
{controller: 'courses', action: 'search'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_courses_item
|
||||
assert_routing(
|
||||
'courses/233',
|
||||
{controller: 'courses', action: 'show', id: '233'}
|
||||
)
|
||||
# id eq str
|
||||
assert_routing(
|
||||
'courses/timestypo',
|
||||
{controller: 'courses', action: 'show', id: 'timestypo'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_setting
|
||||
assert_routing(
|
||||
'courses/233/settings',
|
||||
{controller: 'courses', action: 'settings', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_homework
|
||||
assert_routing(
|
||||
'courses/233/homework',
|
||||
{controller: 'courses', action: 'homework', id: '233'}
|
||||
)
|
||||
assert_routing(
|
||||
'courses/233/new_homework',
|
||||
{controller: 'courses', action: 'new_homework', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_file
|
||||
assert_routing(
|
||||
'courses/233/file',
|
||||
{controller: 'courses', action: 'file', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_feedback
|
||||
assert_routing(
|
||||
'courses/233/feedback',
|
||||
{controller: 'courses', action: 'feedback', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_member
|
||||
assert_routing(
|
||||
'courses/233/member',
|
||||
{controller: 'courses', action: 'member', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_finish_restart_course
|
||||
assert_routing(
|
||||
{path: 'courses/233/finishcourse', method: :post},
|
||||
{controller: 'courses', action: 'finishcourse', id: '233'}
|
||||
)
|
||||
assert_routing(
|
||||
{path: 'courses/233/restartcourse', method: :post},
|
||||
{controller: 'courses', action: 'restartcourse', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,3 +1,55 @@
|
|||
require 'rubygems'
|
||||
require 'spork'
|
||||
#uncomment the following line to use spork with the debugger
|
||||
#require 'spork/ext/ruby-debug'
|
||||
|
||||
Spork.prefork do
|
||||
# Loading more in this block will cause your tests to run faster. However,
|
||||
# if you change any configuration or code from libraries loaded here, you'll
|
||||
# need to restart spork for it take effect.
|
||||
ENV["RAILS_ENV"] = "test"
|
||||
require File.expand_path('../../config/environment', __FILE__)
|
||||
require 'rails/test_help'
|
||||
|
||||
end
|
||||
|
||||
Spork.each_run do
|
||||
# This code will be run each time you run your specs.
|
||||
|
||||
end
|
||||
|
||||
# --- Instructions ---
|
||||
# Sort the contents of this file into a Spork.prefork and a Spork.each_run
|
||||
# block.
|
||||
#
|
||||
# The Spork.prefork block is run only once when the spork server is started.
|
||||
# You typically want to place most of your (slow) initializer code in here, in
|
||||
# particular, require'ing any 3rd-party gems that you don't normally modify
|
||||
# during development.
|
||||
#
|
||||
# The Spork.each_run block is run each time you run your specs. In case you
|
||||
# need to load files that tend to change during development, require them here.
|
||||
# With Rails, your application modules are loaded automatically, so sometimes
|
||||
# this block can remain empty.
|
||||
#
|
||||
# Note: You can modify files loaded *from* the Spork.each_run block without
|
||||
# restarting the spork server. However, this file itself will not be reloaded,
|
||||
# so if you change any of the code inside the each_run block, you still need to
|
||||
# restart the server. In general, if you have non-trivial code in this file,
|
||||
# it's advisable to move it into a separate file so you can easily edit it
|
||||
# without restarting spork. (For example, with RSpec, you could move
|
||||
# non-trivial code into a file spec/support/my_helper.rb, making sure that the
|
||||
# spec/support/* files are require'd from inside the each_run block.)
|
||||
#
|
||||
# Any code that is left outside the two blocks will be run during preforking
|
||||
# *and* during each_run -- that's probably not what you want.
|
||||
#
|
||||
# These instructions should self-destruct in 10 seconds. If they don't, feel
|
||||
# free to delete them.
|
||||
|
||||
|
||||
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
require File.expand_path('../../../../../../test_helper', __FILE__)
|
||||
begin
|
||||
require 'mocha'
|
||||
require 'mocha/setup'
|
||||
|
||||
class BazaarAdapterTest < ActiveSupport::TestCase
|
||||
REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
require File.expand_path('../../../../../../test_helper', __FILE__)
|
||||
begin
|
||||
require 'mocha'
|
||||
require 'mocha/setup'
|
||||
|
||||
class CvsAdapterTest < ActiveSupport::TestCase
|
||||
REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
require File.expand_path('../../../../../../test_helper', __FILE__)
|
||||
begin
|
||||
require 'mocha'
|
||||
require 'mocha/setup'
|
||||
|
||||
class DarcsAdapterTest < ActiveSupport::TestCase
|
||||
REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
require File.expand_path('../../../../../../test_helper', __FILE__)
|
||||
begin
|
||||
require 'mocha'
|
||||
require 'mocha/setup'
|
||||
|
||||
class GitAdapterTest < ActiveSupport::TestCase
|
||||
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
require File.expand_path('../../../../../../test_helper', __FILE__)
|
||||
begin
|
||||
require 'mocha'
|
||||
require 'mocha/setup'
|
||||
|
||||
class MercurialAdapterTest < ActiveSupport::TestCase
|
||||
HELPERS_DIR = Redmine::Scm::Adapters::MercurialAdapter::HELPERS_DIR
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
require File.expand_path('../../../../../../test_helper', __FILE__)
|
||||
|
||||
begin
|
||||
require 'mocha'
|
||||
require 'mocha/setup'
|
||||
|
||||
class SubversionAdapterTest < ActiveSupport::TestCase
|
||||
|
||||
|
|
Loading…
Reference in New Issue