Conflicts:
	db/schema.rb
This commit is contained in:
z9hang 2014-07-15 16:16:13 +08:00
commit 53ff6ea335
33 changed files with 446 additions and 121 deletions

35
Gemfile
View File

@ -1,4 +1,4 @@
source 'https://rubygems.org' source 'https://ruby.taobao.org'
unless RUBY_PLATFORM =~ /w32/ unless RUBY_PLATFORM =~ /w32/
# unix-like only # unix-like only
@ -19,19 +19,33 @@ gem 'acts-as-taggable-on', '2.4.1'
group :development do group :development do
gem 'better_errors', path: 'lib/better_errors' gem 'better_errors', path: 'lib/better_errors'
gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler' gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler'
if ENV['PRY']
gem 'pry'
gem 'pry-nav'
end
end end
group :test do group :test do
# shoulda的版本做了改动
#gem "shoulda", "~> 3.3.2" #gem "shoulda", "~> 3.3.2"
gem "shoulda", "> 3.3.2" gem "shoulda", "> 3.3.2"
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'
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 end
@ -53,15 +67,6 @@ group :ldap do
end 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 # Optional gem for OpenID authentication
group :openid do group :openid do
gem "ruby-openid", "~> 2.1.4", :require => "openid" gem "ruby-openid", "~> 2.1.4", :require => "openid"

View File

@ -19,7 +19,7 @@ PATH
rails rails
GEM GEM
remote: https://rubygems.org/ remote: https://ruby.taobao.org/
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actionmailer (3.2.13) actionmailer (3.2.13)
@ -51,7 +51,7 @@ GEM
multi_json (~> 1.0) multi_json (~> 1.0)
acts-as-taggable-on (2.4.1) acts-as-taggable-on (2.4.1)
rails (>= 3, < 5) rails (>= 3, < 5)
arel (3.0.2) arel (3.0.3)
builder (3.0.0) builder (3.0.0)
capybara (2.0.3) capybara (2.0.3)
mime-types (>= 1.16) mime-types (>= 1.16)
@ -60,6 +60,8 @@ GEM
rack-test (>= 0.5.4) rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0) selenium-webdriver (~> 2.0)
xpath (~> 1.0.0) xpath (~> 1.0.0)
celluloid (0.15.2)
timers (~> 1.1.0)
childprocess (0.5.3) childprocess (0.5.3)
ffi (~> 1.0, >= 1.0.11) ffi (~> 1.0, >= 1.0.11)
climate_control (0.0.3) climate_control (0.0.3)
@ -70,51 +72,89 @@ GEM
coffee-rails (3.2.2) coffee-rails (3.2.2)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
railties (~> 3.2.0) railties (~> 3.2.0)
coffee-script (2.2.0) coffee-script (2.3.0)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.7.0) coffee-script-source (1.7.1)
erubis (2.7.0) erubis (2.7.0)
execjs (2.0.2) execjs (2.2.1)
fastercsv (1.5.0) fastercsv (1.5.5)
ffi (1.9.3)
ffi (1.9.3-x86-mingw32) 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) hike (1.2.3)
htmlentities (4.3.2) htmlentities (4.3.2)
i18n (0.6.1) i18n (0.6.1)
iconv (1.0.4)
journey (1.0.4) journey (1.0.4)
jquery-rails (2.0.3) jquery-rails (2.0.3)
railties (>= 3.1.0, < 5.0) railties (>= 3.1.0, < 5.0)
thor (~> 0.14) thor (~> 0.14)
json (1.8.0) json (1.8.1)
kaminari (0.16.1) kaminari (0.16.1)
actionpack (>= 3.0.0) actionpack (>= 3.0.0)
activesupport (>= 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) mail (2.5.4)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
metaclass (0.0.4) metaclass (0.0.4)
mime-types (1.23) method_source (0.8.2)
mime-types (1.25.1)
mocha (0.13.3) mocha (0.13.3)
metaclass (~> 0.0.1) metaclass (~> 0.0.1)
multi_json (1.7.6) multi_json (1.10.1)
mysql2 (0.3.11)
mysql2 (0.3.11-x86-mingw32) mysql2 (0.3.11-x86-mingw32)
net-ldap (0.3.1) net-ldap (0.3.1)
nokogiri (1.5.11)
nokogiri (1.5.11-x86-mingw32) nokogiri (1.5.11-x86-mingw32)
paperclip (3.5.4) paperclip (3.5.4)
activemodel (>= 3.0.0) activemodel (>= 3.0.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
cocaine (~> 0.5.3) cocaine (~> 0.5.3)
mime-types 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 (1.4.5)
rack-cache (1.2) rack-cache (1.2)
rack (>= 0.4) rack (>= 0.4)
rack-openid (1.3.1) rack-openid (1.4.2)
rack (>= 1.1.0) rack (>= 1.1.0)
ruby-openid (>= 2.1.8) ruby-openid (>= 2.1.8)
rack-raw-upload (1.1.1) rack-raw-upload (1.1.1)
multi_json multi_json
rack-ssl (1.3.3) rack-ssl (1.3.4)
rack rack
rack-test (0.6.2) rack-test (0.6.2)
rack (>= 1.0) rack (>= 1.0)
@ -134,8 +174,12 @@ GEM
rdoc (~> 3.4) rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0) thor (>= 0.14.6, < 2.0)
rake (10.3.2) rake (10.3.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rdoc (3.12.2) rdoc (3.12.2)
json (~> 1.4) json (~> 1.4)
ref (1.0.5)
rich (1.4.6) rich (1.4.6)
jquery-rails jquery-rails
kaminari kaminari
@ -146,8 +190,9 @@ GEM
sass-rails sass-rails
rmagick (2.13.2) rmagick (2.13.2)
ruby-openid (2.1.8) ruby-openid (2.1.8)
rubyzip (1.1.4) ruby-prof (0.15.1)
sass (3.2.14) rubyzip (1.1.6)
sass (3.3.10)
sass-rails (3.2.6) sass-rails (3.2.6)
railties (~> 3.2.0) railties (~> 3.2.0)
sass (>= 3.1.10) sass (>= 3.1.10)
@ -163,25 +208,38 @@ GEM
shoulda-context (1.2.1) shoulda-context (1.2.1)
shoulda-matchers (2.6.1) shoulda-matchers (2.6.1)
activesupport (>= 3.0.0) 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) sprockets (2.2.2)
hike (~> 1.2) hike (~> 1.2)
multi_json (~> 1.0) multi_json (~> 1.0)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.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) tilt (1.4.1)
treetop (1.4.14) timers (1.1.0)
treetop (1.4.15)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
tzinfo (0.3.37) tzinfo (0.3.40)
uglifier (2.4.0) uglifier (2.5.1)
execjs (>= 0.3.0) execjs (>= 0.3.0)
json (>= 1.8.0) json (>= 1.8.0)
websocket (1.0.7) websocket (1.0.7)
win32console (1.3.2-x86-mingw32)
xpath (1.0.0) xpath (1.0.0)
nokogiri (~> 1.3) nokogiri (~> 1.3)
zip-zip (0.3)
rubyzip (>= 1.0.0)
PLATFORMS PLATFORMS
ruby
x86-mingw32 x86-mingw32
DEPENDENCIES DEPENDENCIES
@ -194,8 +252,12 @@ DEPENDENCIES
coderay (~> 1.0.6) coderay (~> 1.0.6)
coffee-rails (~> 3.2.1) coffee-rails (~> 3.2.1)
fastercsv (~> 1.5.0) fastercsv (~> 1.5.0)
guard-rails
guard-spork
guard-test (~> 1.0.0)
htmlentities htmlentities
i18n (~> 0.6.0) i18n (~> 0.6.0)
iconv
jquery-rails (~> 2.0.2) jquery-rails (~> 2.0.2)
kaminari kaminari
mocha (~> 0.13.3) mocha (~> 0.13.3)
@ -203,14 +265,20 @@ DEPENDENCIES
net-ldap (~> 0.3.1) net-ldap (~> 0.3.1)
nokogiri (< 1.6.0) nokogiri (< 1.6.0)
paperclip (~> 3.5.4) paperclip (~> 3.5.4)
pry
pry-nav
rack-mini-profiler! rack-mini-profiler!
rack-openid rack-openid
rails (= 3.2.13) rails (= 3.2.13)
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
rubyzip
sass-rails (~> 3.2.3) sass-rails (~> 3.2.3)
seems_rateable! seems_rateable!
shoulda (> 3.3.2) shoulda (> 3.3.2)
spork-testunit
therubyracer therubyracer
uglifier (>= 1.0.3) uglifier (>= 1.0.3)
zip-zip

39
Guardfile Normal file
View File

@ -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

View File

@ -630,7 +630,13 @@ class CoursesController < ApplicationController
:with_subprojects => false, :with_subprojects => false,
:author => @author) :author => @author)
@activity.scope_select {|t| has["show_#{t}"]} @activity.scope_select {|t| has["show_#{t}"]}
# modify by nwb
# 添加私密性判断
if User.current.member_of_course?(@course)|| User.current.admin?
events = @activity.events(@date_from, @date_to) 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}) @offset, @limit = api_offset_and_limit({:limit => 10})
@events_count = events.count @events_count = events.count

View File

@ -23,6 +23,7 @@ class DocumentsController < ApplicationController
before_filter :find_model_object, :except => [:index, :new, :create] before_filter :find_model_object, :except => [:index, :new, :create]
before_filter :find_project_from_association, :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 , :except => [:index]#Added by young
before_filter :authorize_document
helper :attachments helper :attachments
@ -100,4 +101,12 @@ class DocumentsController < ApplicationController
end end
redirect_to document_path(@document) redirect_to document_path(@document)
end 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 end

View File

@ -697,8 +697,14 @@ class ProjectsController < ApplicationController
@activity.scope_select {|t| !has["show_#{t}"].nil?} @activity.scope_select {|t| !has["show_#{t}"].nil?}
# logger.debug "=========================================#{@activity.scope}" # logger.debug "=========================================#{@activity.scope}"
# @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? # @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
#Added by young
# modify by nwb
# 添加私密性判断
if User.current.member_of?(@project)|| User.current.admin?
events = @activity.events(@date_from, @date_to) 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}) @offset, @limit = api_offset_and_limit({:limit => 10})
@events_count = events.count @events_count = events.count

View File

@ -92,6 +92,22 @@ class RepositoriesController < ApplicationController
end end
def create def create
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 ##xianbo
@root_path=RepositoriesHelper::ROOT_PATH @root_path=RepositoriesHelper::ROOT_PATH
@repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
@ -144,6 +160,7 @@ class RepositoriesController < ApplicationController
end end
end end
end end
end
def edit def edit
end end

View File

@ -80,11 +80,12 @@ module ApplicationHelper
name = h(user.name(options[:format])) name = h(user.name(options[:format]))
end end
if user.active? || (User.current.admin? && user.logged?) #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 link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes
else
name
end
else else
h(user.to_s) h(user.to_s)
end end

View File

@ -39,12 +39,14 @@ class Attachment < ActiveRecord::Base
#课程资源文件 #课程资源文件
acts_as_activity_provider :type => 'course_files', acts_as_activity_provider :type => 'course_files',
:is_public => 'attachments.is_public',
:permission => :view_files, :permission => :view_files,
:author_key => :author_id, :author_key => :author_id,
:find_options => {:select => "#{Attachment.table_name}.*", :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 )"} :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', acts_as_activity_provider :type => 'files',
:is_public => 'attachments.is_public',
:permission => :view_files, :permission => :view_files,
:author_key => :author_id, :author_key => :author_id,
:find_options => { :select => "#{Attachment.table_name}.*", :find_options => { :select => "#{Attachment.table_name}.*",
@ -52,6 +54,7 @@ class Attachment < ActiveRecord::Base
"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 )"} "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', acts_as_activity_provider :type => 'documents',
:is_public => 'documents.is_public',
:permission => :view_documents, :permission => :view_documents,
:author_key => :author_id, :author_key => :author_id,
:find_options => {:select => "#{Attachment.table_name}.*", :find_options => {:select => "#{Attachment.table_name}.*",

View File

@ -30,7 +30,8 @@ class Document < ActiveRecord::Base
acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"}, 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) }, :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}} :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_presence_of :project, :title, :category
validates_length_of :title, :maximum => 60 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)) 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) def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_documents, project) !user.nil? && user.allowed_to?(:view_documents, project)

View File

@ -163,7 +163,7 @@ class Setting < ActiveRecord::Base
end end
# fixed domain url in development. tantantan's bug # fixed domain url in development. tantantan's bug
if Rails.env.development? if Rails.env.development? || Rails.env.test?
methods.map do |m| methods.map do |m|
define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/ define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/
end end

View File

@ -2,6 +2,9 @@
<div class="box tabular"> <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_field :title, :required => true, :size => 60 %></p>
<p><%= f.text_area :description, :cols => 60, :rows => 15, :class => 'wiki-edit' %></p> <p><%= f.text_area :description, :cols => 60, :rows => 15, :class => 'wiki-edit' %></p>
</div> </div>

View File

@ -35,7 +35,7 @@
</tr> </tr>
<% end -%> <% end -%>
<% container.attachments.each do |file| %> <% 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%> <%next%>
<%end%> <%end%>
<tr class="file <%= cycle("odd", "odd") %>"> <tr class="file <%= cycle("odd", "odd") %>">

View File

@ -28,7 +28,7 @@
<% @containers.each do |container| %> <% @containers.each do |container| %>
<% next if container.attachments.empty? -%> <% next if container.attachments.empty? -%>
<% container.attachments.each do |file| %> <% 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 %> <% next %>
<% end %> <% end %>
<% if isTypeOk(file, selAttachType, selContentType) %> <% if isTypeOk(file, selAttachType, selContentType) %>

View File

@ -33,21 +33,27 @@
<%= image_tag "/images/time_member.png", :class => "img_member_time"%> <%= image_tag "/images/time_member.png", :class => "img_member_time"%>
<div> <div>
<table style="width: 100%;table-layout: fixed">
<tr>
<td rowspan="2" style="width: 60px;">
<%= image_tag(url_to_avatar(user), :class => 'avatar') %> <%= image_tag(url_to_avatar(user), :class => 'avatar') %>
<%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %> </td>
<td style="width: 200px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title="<%= user.name %>">
<!-- modified by bai --> <span style="position: relative;font-size: 16px;display:block; "><%= link_to_user(user) %></span>
<div style="position:relative;float:left;margin-top:-2px;margin-left: 160px"> </td>
<td>
<span style="color:#ec6300"> <span style="color:#ec6300">
<%= render :partial => 'users/user_score', :locals => {:user => user}%></span> <%= render :partial => 'users/user_score', :locals => {:user => user}%>
</div> </span>
<!-- end --> </td>
</div> </tr>
<tr>
<div style="margin-top: 20px;margin-left:66px"> <td colspan="2">
<%= l(:label_x_has_fans,:count=>user.watcher_users.count)%> <%= l(:label_x_has_fans,:count=>user.watcher_users.count)%>
<%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %> <%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %>
</td>
</tr>
</table>
</div> </div>
<div class="user-bottom"> <div class="user-bottom">
<% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %> <% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %>

View File

@ -537,6 +537,7 @@ en:
label_document_new: New document label_document_new: New document
label_document_plural: Documents label_document_plural: Documents
label_document_added: Document added 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: Role
label_role_plural: Roles label_role_plural: Roles
label_role_new: New role label_role_new: New role

View File

@ -538,6 +538,7 @@ zh:
label_document_new: 新建文档 label_document_new: 新建文档
label_document_plural: 文档 label_document_plural: 文档
label_document_added: 文档已添加 label_document_added: 文档已添加
label_document_public_info: (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该文档。)
label_role: 角色 label_role: 角色
label_role_plural: 角色 label_role_plural: 角色
label_role_new: 新建角色 label_role_new: 新建角色

View File

@ -577,7 +577,6 @@ RedmineApp::Application.routes.draw do
end end
end end
match 'projects/course', :to => 'courses#course', :as => 'courses_course'
match 'courses/search', :to => 'courses#search' match 'courses/search', :to => 'courses#search'
# add by nwb # add by nwb
# 课程路由设置 # 课程路由设置

View File

@ -0,0 +1,5 @@
class AddIsPublicToDocuments < ActiveRecord::Migration
def change
add_column :documents, :is_public, :integer,:default => 1
end
end

Binary file not shown.

View File

@ -29,7 +29,7 @@ module Redmine
send :include, Redmine::Acts::ActivityProvider::InstanceMethods send :include, Redmine::Acts::ActivityProvider::InstanceMethods
end 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 ||= {} self.activity_provider_options ||= {}
# One model can provide different event types # One model can provide different event types
@ -65,6 +65,11 @@ module Redmine
scope = scope.scoped(:conditions => ["#{provider_options[:author_key]} = ?", options[:author].id]) scope = scope.scoped(:conditions => ["#{provider_options[:author_key]} = ?", options[:author].id])
end 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] if options[:limit]
# id and creation time should be in same order in most cases # id and creation time should be in same order in most cases
scope = scope.scoped(:order => "#{table_name}.id DESC", :limit => options[:limit]) scope = scope.scoped(:order => "#{table_name}.id DESC", :limit => options[:limit])

View File

@ -8,7 +8,7 @@ gem 'actionpack'
require 'action_controller' require 'action_controller'
gem 'mocha' gem 'mocha'
require 'mocha' require 'mocha/setup'
gem 'ruby-openid' gem 'ruby-openid'
require 'openid' require 'openid'

View File

@ -82,6 +82,8 @@ module Redmine
def events(from = nil, to = nil, options={}) def events(from = nil, to = nil, options={})
e = [] e = []
@options[:limit] = options[:limit] @options[:limit] = options[:limit]
# modify by nwb
@options[:is_public] = options[:is_public]
@scope.each do |event_type| @scope.each do |event_type|
constantized_providers(event_type).each do |provider| constantized_providers(event_type).each do |provider|

Binary file not shown.

View File

@ -18,7 +18,7 @@
require File.expand_path('../../test_helper', __FILE__) require File.expand_path('../../test_helper', __FILE__)
begin begin
require 'mocha' require 'mocha/setup'
rescue rescue
# Won't run some tests # Won't run some tests
end end

View File

@ -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

View File

@ -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 # Redmine - project management software
# Copyright (C) 2006-2013 Jean-Philippe Lang # Copyright (C) 2006-2013 Jean-Philippe Lang
# #

View File

@ -17,7 +17,7 @@
require File.expand_path('../../../../../../test_helper', __FILE__) require File.expand_path('../../../../../../test_helper', __FILE__)
begin begin
require 'mocha' require 'mocha/setup'
class BazaarAdapterTest < ActiveSupport::TestCase class BazaarAdapterTest < ActiveSupport::TestCase
REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s

View File

@ -17,7 +17,7 @@
require File.expand_path('../../../../../../test_helper', __FILE__) require File.expand_path('../../../../../../test_helper', __FILE__)
begin begin
require 'mocha' require 'mocha/setup'
class CvsAdapterTest < ActiveSupport::TestCase class CvsAdapterTest < ActiveSupport::TestCase
REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s

View File

@ -17,7 +17,7 @@
require File.expand_path('../../../../../../test_helper', __FILE__) require File.expand_path('../../../../../../test_helper', __FILE__)
begin begin
require 'mocha' require 'mocha/setup'
class DarcsAdapterTest < ActiveSupport::TestCase class DarcsAdapterTest < ActiveSupport::TestCase
REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s

View File

@ -17,7 +17,7 @@
require File.expand_path('../../../../../../test_helper', __FILE__) require File.expand_path('../../../../../../test_helper', __FILE__)
begin begin
require 'mocha' require 'mocha/setup'
class GitAdapterTest < ActiveSupport::TestCase class GitAdapterTest < ActiveSupport::TestCase
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s

View File

@ -17,7 +17,7 @@
require File.expand_path('../../../../../../test_helper', __FILE__) require File.expand_path('../../../../../../test_helper', __FILE__)
begin begin
require 'mocha' require 'mocha/setup'
class MercurialAdapterTest < ActiveSupport::TestCase class MercurialAdapterTest < ActiveSupport::TestCase
HELPERS_DIR = Redmine::Scm::Adapters::MercurialAdapter::HELPERS_DIR HELPERS_DIR = Redmine::Scm::Adapters::MercurialAdapter::HELPERS_DIR

View File

@ -18,7 +18,7 @@
require File.expand_path('../../../../../../test_helper', __FILE__) require File.expand_path('../../../../../../test_helper', __FILE__)
begin begin
require 'mocha' require 'mocha/setup'
class SubversionAdapterTest < ActiveSupport::TestCase class SubversionAdapterTest < ActiveSupport::TestCase