Compare commits
255 Commits
master
...
GitlabVers
Author | SHA1 | Date |
---|---|---|
nwb | 9b2bfcb2eb | |
nwb | 111f60b04a | |
nwb | a330c77e76 | |
nwb | 0b68e9e24e | |
nwb | 45a0f91b34 | |
nwb | 1597dfd4ef | |
nwb | bc865ccb4f | |
nwb | 4e4878f8b1 | |
nwb | 126cb93db2 | |
nwb | 08676e1b6f | |
nwb | 7fffbfaea5 | |
nwb | 72021232b5 | |
nwb | b6a2153020 | |
nwb | ff80ef7f42 | |
nwb | e98f548bc3 | |
nwb | cc6949d427 | |
nwb | c675ac67e0 | |
nwb | b550e98603 | |
nwb | c5f6f5884f | |
nwb | 48ded776de | |
nwb | 0a06e2033f | |
nwb | 5d22bc5510 | |
yanxd | ee95d9b115 | |
yanxd | 18d096f0d8 | |
yanxd | cccbd941ce | |
nwb | f22a39fbfa | |
nwb | a5d829b95e | |
z9hang | 41ea3a1baf | |
z9hang | dee09aad75 | |
nwb | 8f74241eda | |
nwb | 095cb7fc32 | |
sw | 47ae398748 | |
sw | de17a84061 | |
nwb | 42c2f6c2ee | |
sw | 7e0210dd9d | |
sw | e5547b953e | |
nwb | 09f13409de | |
nwb | 840a7b337b | |
sw | d9b9b2152f | |
sw | 58c3e98a21 | |
sw | ab55043880 | |
nwb | 5954ba1788 | |
nwb | cf11cac0ad | |
yanxd | 8496d6e0d2 | |
yanxd | edee2b2327 | |
nwb | 67dfd72845 | |
nwb | 518edeac68 | |
z9hang | 513fd32ec5 | |
z9hang | 221aef4a7f | |
z9hang | 3e79dd6e32 | |
nwb | b49344107c | |
nwb | aebae800dd | |
sw | 6e954d314f | |
sw | bfda30ee80 | |
nwb | feaea8375e | |
nwb | 774eed0dbf | |
sw | b1251db30c | |
nwb | 5e462f1ae7 | |
nwb | 51e4d00691 | |
sw | c8aaa2776c | |
yanxd | fb138d1593 | |
nwb | 222959d1da | |
nwb | 27fda1f938 | |
yanxd | 04ec6ff27a | |
yanxd | 472b61fefe | |
nwb | aea41ba997 | |
sw | 890bc7459d | |
nwb | 5adac1a32a | |
nwb | d8d8473811 | |
nwb | 3a249e7196 | |
nwb | ec71e8eeeb | |
nwb | c7f80effb7 | |
z9hang | 5e4571d6af | |
z9hang | f273b60f32 | |
z9hang | 162a4cfa84 | |
z9hang | 0322258386 | |
z9hang | 376ba1d793 | |
sw | 8db6b50a65 | |
sw | e24323147d | |
z9hang | 5c0e3e96cc | |
sw | ba66cde840 | |
nwb | bda9921fb0 | |
nwb | 49aa3a994e | |
sw | 6186ff343e | |
sw | fdfba199f3 | |
sw | 93d8fd31a0 | |
sw | 64f025fe70 | |
sw | 71ffdb9164 | |
nwb | 206aeeccfb | |
sw | 79c76d26c8 | |
nwb | 60fa473608 | |
nwb | 6bced5106e | |
sw | 9fe4c9f8a2 | |
z9hang | 599a277af3 | |
z9hang | 74ff5d505d | |
nwb | e1edb46ba2 | |
nwb | 908254b911 | |
yanxd | f5efaac93a | |
yanxd | 6af11fea68 | |
z9hang | 40d8ec6c6e | |
z9hang | 4bd083b059 | |
sw | 6a42ce143b | |
z9hang | b44b488807 | |
nwb | 0e0da39113 | |
sw | 9f02003bb9 | |
nwb | 955cf619b8 | |
nwb | 0e9a15aad5 | |
sw | 41983833d7 | |
z9hang | bd43ef5d61 | |
sw | e0f5708038 | |
yanxd | 3f6a298eb4 | |
sw | 999a252f7b | |
nwb | 5087f90a26 | |
nwb | 3b9245d143 | |
sw | 0f3c2ff558 | |
nwb | bc50d5f469 | |
sw | 46c7a4bb9f | |
sw | 4a04d47c3c | |
nwb | 29618d6a72 | |
nwb | c443de5873 | |
nwb | 5272a90227 | |
nwb | 7898bc1dd7 | |
nwb | 046142f437 | |
yanxd | df848ca756 | |
sw | 5838b3e47d | |
z9hang | 057447f810 | |
nwb | a4d06fbb12 | |
sw | 6f858795ef | |
sw | bcaaa02bed | |
nwb | 6968039c87 | |
z9hang | 036f8a3870 | |
nwb | 28543e3288 | |
nwb | 8eac756ac7 | |
yanxd | 164ec645ee | |
z9hang | 5b7fc4048a | |
sw | 6379dd704a | |
sw | b81b5fc42c | |
z9hang | 0f4933240b | |
z9hang | 7c3a81735c | |
yanxd | 355d452472 | |
nwb | ed00adb3ba | |
nwb | 3b1b057f0a | |
nwb | 634ef8df5f | |
nwb | baf181f1d7 | |
nwb | f4d6696d2e | |
yanxd | 2554e9fc5b | |
nwb | 02b4029e8c | |
nwb | 615b3ac2ac | |
nwb | 6a65b2a84b | |
nwb | 0dc2466539 | |
nwb | b60a0ddf59 | |
yanxd | 12fb6bf5ca | |
nwb | 63e855725f | |
nwb | a58a747cfa | |
yanxd | 4eee70a845 | |
nwb | b34a8d6166 | |
nwb | 3d8571b59e | |
nwb | 1f5d792783 | |
nwb | 6dcc50e60b | |
z9hang | 8d181c4e93 | |
z9hang | 2cab9f7895 | |
z9hang | ab05bf6f36 | |
z9hang | 494d3af9a4 | |
nwb | 36ab954cf9 | |
nwb | 297fe9a3f4 | |
yanxd | 386aa1adc3 | |
z9hang | d9e04bab0a | |
z9hang | cc4bf3b328 | |
nwb | 62af03debd | |
nwb | ca7ad03a05 | |
sw | 4825c5287e | |
z9hang | fbc4cd1cf1 | |
nwb | 3254c4a237 | |
z9hang | 3cda9294fd | |
nwb | 13a3725b06 | |
sw | f8d3d60b27 | |
sw | 62e24eda1c | |
sw | e303009917 | |
z9hang | 53ff6ea335 | |
z9hang | 6a45a0287d | |
sw | 121ffa0342 | |
sw | b142953a4b | |
yanxd | 37d0560b70 | |
sw | bff1319c5e | |
sw | 61ba2c47ee | |
nwb | ba3d1755d4 | |
nwb | e6b80de3b5 | |
yanxd | ec2384f110 | |
sw | 8f8fb79a63 | |
z9hang | cf339edb6c | |
yanxd | 14f1ad63d2 | |
sw | 90e28518f2 | |
nwb | 1da147684a | |
nwb | 2a1a051362 | |
sw | ef95835bc6 | |
sw | 31245f6fb2 | |
sw | b704a44dfb | |
sw | 7a9b5156c9 | |
nwb | 0950ac2329 | |
nwb | 0031f90c64 | |
z9hang | 3aab1b172c | |
nwb | 87b623bc51 | |
yanxd | fd5747f4dc | |
z9hang | 98ddd6940d | |
z9hang | f44c715cfb | |
z9hang | 6b6fd2906f | |
sw | 59a5541e45 | |
sw | 9da70f9a20 | |
sw | 9472a7eb5c | |
z9hang | e1c7aaa220 | |
z9hang | fcdfeae326 | |
z9hang | 3dfcc90574 | |
nwb | 48e2d8ecee | |
nwb | 6d698cb5d8 | |
yanxd | 2be5041d0d | |
sw | 4f2298fd22 | |
nwb | 9b3ffc90ba | |
nwb | 6688ba61dd | |
sw | bed662c2e5 | |
z9hang | b4dd8409eb | |
sw | 86adfaecce | |
sw | 51ef3fa5a1 | |
sw | 7bcb1cbe2e | |
sw | 47ad20421e | |
yanxd | 056f86caad | |
sw | 39434766e3 | |
yanxd | 803e9cbdb5 | |
yanxd | e573438e43 | |
yanxd | 249ea19c0c | |
sw | a5518363c3 | |
sw | 65c137e617 | |
z9hang | 720c75478a | |
yanxd | 2ff24841fd | |
yanxd | 2b57e170ef | |
sw | 76db0e61c3 | |
sw | aec6d33db7 | |
sw | 41823fbddf | |
yanxd | 91eb7751da | |
Administrator | 6082eca117 | |
z9hang | 4d75fbfcb8 | |
z9hang | 9634046d11 | |
yanxd | 0998438e67 | |
yanxd | 4259f63fbf | |
z9hang | fd71435b30 | |
yanxd | 38b3e86e62 | |
z9hang | b87abf1f68 | |
yanxd | 449b87e38d | |
z9hang | 4c6fb2a266 | |
xianbo | 25ee1d8672 | |
z9hang | 0fa552c8d3 | |
z9hang | b4bf320c2e | |
z9hang | 5e3a763776 | |
yanxd | 4dbe149b42 | |
yanxd | ab03962e9a | |
yanxd | aca63146e9 |
46
Gemfile
46
Gemfile
|
@ -1,4 +1,4 @@
|
|||
source 'https://rubygems.org'
|
||||
source 'http://ruby.taobao.org'
|
||||
|
||||
unless RUBY_PLATFORM =~ /w32/
|
||||
# unix-like only
|
||||
|
@ -19,19 +19,34 @@ 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'
|
||||
gem "shoulda", "~> 3.5.0"
|
||||
gem "mocha", "~> 1.1.0"
|
||||
gem 'capybara', '~> 2.4.1'
|
||||
gem 'nokogiri', '~> 1.6.3'
|
||||
gem 'factory_girl', '~> 4.4.0'
|
||||
gem 'selenium-webdriver', '~> 2.42.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", '~> 0.5.3'
|
||||
gem 'spork-testunit', '~> 0.0.8'
|
||||
gem 'guard-spork', '~> 1.5.1'
|
||||
gem 'guard-test', '~> 1.0.0'
|
||||
gem 'ruby-prof', '~> 0.15.1' unless RUBY_PLATFORM =~ /w32/
|
||||
gem 'pry'
|
||||
gem 'pry-nav'
|
||||
end
|
||||
|
||||
|
||||
|
@ -53,15 +68,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"
|
||||
|
|
148
Gemfile.lock
148
Gemfile.lock
|
@ -19,6 +19,7 @@ PATH
|
|||
rails
|
||||
|
||||
GEM
|
||||
remote: http://ruby.taobao.org/
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (3.2.13)
|
||||
|
@ -50,55 +51,113 @@ 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)
|
||||
capybara (2.4.1)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
selenium-webdriver (~> 2.0)
|
||||
xpath (~> 1.0.0)
|
||||
xpath (~> 2.0)
|
||||
celluloid (0.15.2)
|
||||
timers (~> 1.1.0)
|
||||
childprocess (0.5.3)
|
||||
ffi (~> 1.0, >= 1.0.11)
|
||||
climate_control (0.0.3)
|
||||
activesupport (>= 3.0)
|
||||
cocaine (0.5.4)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
coderay (1.0.9)
|
||||
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)
|
||||
factory_girl (4.4.0)
|
||||
activesupport (>= 3.0.0)
|
||||
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.3)
|
||||
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)
|
||||
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)
|
||||
mocha (0.13.3)
|
||||
method_source (0.8.2)
|
||||
mime-types (1.25.1)
|
||||
mini_portile (0.6.0)
|
||||
mocha (1.1.0)
|
||||
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-x86-mingw32)
|
||||
polyglot (0.3.3)
|
||||
nokogiri (1.6.3)
|
||||
mini_portile (= 0.6.0)
|
||||
nokogiri (1.6.3-x86-mingw32)
|
||||
mini_portile (= 0.6.0)
|
||||
paperclip (3.5.4)
|
||||
activemodel (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
cocaine (~> 0.5.3)
|
||||
mime-types
|
||||
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-ssl (1.3.3)
|
||||
rack-raw-upload (1.1.1)
|
||||
multi_json
|
||||
rack-ssl (1.3.4)
|
||||
rack
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
|
@ -118,12 +177,24 @@ 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
|
||||
mime-types
|
||||
paperclip
|
||||
rack-raw-upload
|
||||
rails (>= 3.2.0)
|
||||
sass-rails
|
||||
rmagick (2.13.2)
|
||||
ruby-openid (2.1.8)
|
||||
rubyzip (1.1.4)
|
||||
sass (3.2.14)
|
||||
rubyzip (1.1.6)
|
||||
sass (3.3.10)
|
||||
sass-rails (3.2.6)
|
||||
railties (~> 3.2.0)
|
||||
sass (>= 3.1.10)
|
||||
|
@ -139,25 +210,36 @@ 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)
|
||||
xpath (1.0.0)
|
||||
win32console (1.3.2-x86-mingw32)
|
||||
xpath (2.0.0)
|
||||
nokogiri (~> 1.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
x86-mingw32
|
||||
|
||||
DEPENDENCIES
|
||||
|
@ -166,23 +248,35 @@ DEPENDENCIES
|
|||
acts-as-taggable-on (= 2.4.1)
|
||||
better_errors!
|
||||
builder (= 3.0.0)
|
||||
capybara (~> 2.0.0)
|
||||
capybara (~> 2.4.1)
|
||||
coderay (~> 1.0.6)
|
||||
coffee-rails (~> 3.2.1)
|
||||
factory_girl (~> 4.4.0)
|
||||
fastercsv (~> 1.5.0)
|
||||
guard-rails (~> 0.5.3)
|
||||
guard-spork (~> 1.5.1)
|
||||
guard-test (~> 1.0.0)
|
||||
htmlentities
|
||||
i18n (~> 0.6.0)
|
||||
jquery-rails (~> 2.0.2)
|
||||
mocha (~> 0.13.3)
|
||||
kaminari
|
||||
mocha (~> 1.1.0)
|
||||
mysql2 (= 0.3.11)
|
||||
net-ldap (~> 0.3.1)
|
||||
nokogiri (< 1.6.0)
|
||||
nokogiri (~> 1.6.3)
|
||||
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)
|
||||
sass-rails (~> 3.2.3)
|
||||
seems_rateable!
|
||||
shoulda (> 3.3.2)
|
||||
selenium-webdriver (~> 2.42.0)
|
||||
shoulda (~> 3.5.0)
|
||||
spork-testunit (~> 0.0.8)
|
||||
therubyracer
|
||||
uglifier (>= 1.0.3)
|
||||
|
|
|
@ -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
|
19
ReadMe.txt
19
ReadMe.txt
|
@ -1,4 +1,4 @@
|
|||
patch:
|
||||
patch:
|
||||
用户姓名的部分,根据issues#655。
|
||||
为了修改方便
|
||||
alias:
|
||||
|
@ -50,4 +50,19 @@ app\controller\welcome_controller.rb
|
|||
0606:新坑
|
||||
user_scores表结构有问题,需要运行
|
||||
bundle exec rake db:migrate:down VERSION=20140410021724
|
||||
bundle exec rake db:migrate:up VERSION=20140410021724
|
||||
bundle exec rake db:migrate:up VERSION=20140410021724
|
||||
===============================================================================
|
||||
0708:CKEditor插件加载方法
|
||||
1.把插件文件夹拷入plugins文件夹,确保文件夹名为redmine_ckeditor
|
||||
2.运行 bundle install --without development test
|
||||
3.运行 rake redmine:plugins:migrate RAILS_ENV=production
|
||||
4.启动服务器
|
||||
5.配置CKEditor插件(Administration > Plugins > Configure)
|
||||
6.把文本格式 (Administration > Settings > General > Text formatting)改为CKEditor
|
||||
注意:一定要先配置CKEditor插件再见文本格式更改,不然,数据库不会生成对应记录,会报错。。
|
||||
===============================================================================
|
||||
0719:若遇到首页定制报错问题请尝试如下操作
|
||||
如果运行迁移文件有报错与‘sort_type’相关 先运行 bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202
|
||||
在按如下步骤执行,未报与之相关的则直接按如下步骤执行
|
||||
1.运行 bundle exec rake db:migrate:down version=20140719080032
|
||||
2.运行 bundle exec rake db:migrate:up version=20140719080032
|
|
@ -24,6 +24,7 @@ class AdminController < ApplicationController
|
|||
before_filter :require_admin
|
||||
helper :sort
|
||||
helper :Users
|
||||
helper :Settings
|
||||
include SortHelper
|
||||
|
||||
def index
|
||||
|
@ -35,15 +36,12 @@ class AdminController < ApplicationController
|
|||
|
||||
scope = Project.status(@status).order('lft')
|
||||
scope = scope.like(params[:name]) if params[:name].present?
|
||||
@projects = scope.all
|
||||
@projects = scope.where(project_type: Project::ProjectType_project).all
|
||||
|
||||
render :action => "projects", :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def users
|
||||
@project_type = params[:project_type]
|
||||
role = params[:role]
|
||||
|
||||
sort_init 'login', 'asc'
|
||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||
|
||||
|
@ -55,95 +53,14 @@ class AdminController < ApplicationController
|
|||
end
|
||||
|
||||
@status = params[:status] || 1
|
||||
has = {
|
||||
"show_changesets" => true
|
||||
}
|
||||
# @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count
|
||||
|
||||
scope = UserStatus.visible
|
||||
case role
|
||||
when 'teacher'
|
||||
scope = UserStatus.teacher
|
||||
when 'student'
|
||||
scope = UserStatus.student
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
scope = User.logged.status(@status)
|
||||
scope = User.like(params[:name]) if params[:name].present?
|
||||
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
||||
# scope.each do |user|
|
||||
# UserStatus.create(:changesets_count => user.changesets.count, :watchers_count => user.watcher_users.count, :user_id => user.id)
|
||||
# end
|
||||
|
||||
@user_count = scope.count
|
||||
@user_pages = Paginator.new @user_count, @limit, params['page']
|
||||
#@offset ||= @user_pages.offset
|
||||
#@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
|
||||
@user_base_tag = params[:id] ? 'base_users':'base'
|
||||
if params[:user_sort_type].present?
|
||||
case params[:user_sort_type]
|
||||
when '0'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 0
|
||||
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
||||
# @projects = @projects[@offset, @limit]
|
||||
when '1'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 1
|
||||
#sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count}
|
||||
#@users = @users[@offset, @limit]
|
||||
when '2'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 2
|
||||
#@users = @users[@offset, @limit]
|
||||
end
|
||||
|
||||
else
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 1
|
||||
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
||||
# @projects = @projects[@offset, @limit]
|
||||
end
|
||||
|
||||
@users = []
|
||||
@users_statuses.each do |obj|
|
||||
@users << User.find_by_id("#{obj.user_id}")
|
||||
end
|
||||
@offset ||= @user_pages.offset
|
||||
@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -208,24 +125,13 @@ class AdminController < ApplicationController
|
|||
end
|
||||
|
||||
@status = params[:status] || 1
|
||||
has = {
|
||||
"show_changesets" => true
|
||||
}
|
||||
scope = User.logged.status(@status)
|
||||
scope = scope.like(params[:name]) if params[:name].present?
|
||||
@user_count = scope.count
|
||||
@user_pages = Paginator.new @user_count, @limit, params['page']
|
||||
@user_base_tag = params[:id] ? 'base_users':'base'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users = scope.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users = scope.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
|
||||
@users = scope.offset(@user_pages.offset).limit(@user_pages.per_page)
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
@ -234,4 +140,103 @@ class AdminController < ApplicationController
|
|||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
#首页定制
|
||||
def first_page_made
|
||||
if request.get?
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
elsif request.post?
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
@first_page.web_title = params[:web_title]
|
||||
@first_page.description = params[:description]
|
||||
@first_page.title = params[:title]
|
||||
@first_page.sort_type = params[:sort_type]
|
||||
if @first_page.save
|
||||
respond_to do |format|
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
format.html {
|
||||
redirect_to admin_first_page_made_path
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
#format.json { render json: @first_page, status: :created, location: @first_page }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}"
|
||||
format.html {
|
||||
render :action => 'first_page_made'
|
||||
}
|
||||
format.api { render_validation_errors(@first_page) }
|
||||
#format.json { render json: @first_page.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def course_page_made
|
||||
if request.get?
|
||||
@course_page = FirstPage.where("page_type = 'course'").first
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
elsif request.post?
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
@course_page = FirstPage.where("page_type = 'course'").first
|
||||
@first_page.web_title = params[:web_title]
|
||||
@course_page.web_title = params[:web_title]
|
||||
@course_page.title = params[:course_title]
|
||||
@course_page.description = params[:course_description]
|
||||
if @first_page.save && @course_page.save
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to admin_course_page_made_path
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}\n\t#{@course_page.errors.full_messages[0]}"
|
||||
#flash.now[:error] = "#{l :label_first_page_create_fail}: #{@course_page.errors.full_messages[0]}"
|
||||
format.html {
|
||||
|
||||
render :action => 'course_page_made'
|
||||
}
|
||||
format.api { render_validation_errors(@first_page) }
|
||||
format.api { render_validation_errors(@course_page) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def contest_page_made
|
||||
if request.get?
|
||||
@contest_page = FirstPage.where("page_type = 'contest'").first
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
elsif request.post?
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
@contest_page = FirstPage.where("page_type = 'contest'").first
|
||||
@first_page.web_title = params[:web_title]
|
||||
@contest_page.web_title = params[:web_title]
|
||||
@contest_page.title = params[:contest_title]
|
||||
@contest_page.description = params[:contest_description]
|
||||
if @first_page.save && @contest_page.save
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to admin_contest_page_made_path
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}\n\t#{@contest_page.errors.full_messages[0]}"
|
||||
format.html {
|
||||
render :action => 'contest_page_made'
|
||||
}
|
||||
format.api { render_validation_errors(@first_page) }
|
||||
format.api { render_validation_errors(@contest_page) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,7 +6,8 @@ class AppliedProjectController < ApplicationController
|
|||
@project = Project.find(params[:project_id])
|
||||
@applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id])
|
||||
if @applieds.count == 0
|
||||
AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
|
||||
appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
|
||||
Mailer.applied_project(appliedproject).deliver
|
||||
end
|
||||
|
||||
#redirect_to project_path(params[:project_id])
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class AttachmentsController < ApplicationController
|
||||
layout "users_base"
|
||||
before_filter :find_project, :only => [:show, :download, :thumbnail, :destroy, :delete_homework]#, :except => [:upload, :autocomplete]
|
||||
before_filter :file_readable, :read_authorize, :only => [:show, :thumbnail]#Modified by young
|
||||
before_filter :delete_authorize, :only => :destroy
|
||||
|
@ -23,6 +24,7 @@ class AttachmentsController < ApplicationController
|
|||
|
||||
before_filter :login_without_softapplication, only: [:download]
|
||||
accept_api_auth :show, :download, :upload
|
||||
require 'iconv'
|
||||
|
||||
def show
|
||||
respond_to do |format|
|
||||
|
@ -49,16 +51,40 @@ class AttachmentsController < ApplicationController
|
|||
end
|
||||
|
||||
def download
|
||||
if true || @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project)
|
||||
# modify by nwb
|
||||
# 下载添加权限设置
|
||||
candown = false
|
||||
if @attachment.container.has_attribute?(:project) && @attachment.container.project
|
||||
project = @attachment.container.project
|
||||
candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1)
|
||||
elsif @attachment.container.is_a?(Project)
|
||||
project = @attachment.container
|
||||
candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1)
|
||||
elsif @attachment.container.has_attribute?(:course) && @attachment.container.course
|
||||
course = @attachment.container.course
|
||||
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
|
||||
elsif @attachment.container.is_a?(Course)
|
||||
course = @attachment.container
|
||||
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
|
||||
candown = true
|
||||
else
|
||||
candown = @attachment.is_public == 1
|
||||
end
|
||||
if candown || User.current.admin?
|
||||
@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
|
||||
render_403 :message => :notice_not_authorized
|
||||
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
|
||||
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
|
||||
end
|
||||
|
@ -75,6 +101,25 @@ class AttachmentsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 更新文件密级
|
||||
def updateFileDense
|
||||
@attachment = Attachment.find(params[:attachmentid])
|
||||
if @attachment != nil
|
||||
filedense = params[:newtype].to_s
|
||||
# d = Iconv.conv("unicodebig","utf-8",filedense)
|
||||
if filedense == "%E5%85%AC%E5%BC%80" #l(:field_is_public)
|
||||
@attachment.is_public = 1
|
||||
else
|
||||
@attachment.is_public = 0
|
||||
end
|
||||
@attachment.save
|
||||
@newfiledense = filedense
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def thumbnail
|
||||
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
|
||||
if stale?(:etag => thumbnail)
|
||||
|
@ -89,6 +134,7 @@ class AttachmentsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def upload
|
||||
# Make sure that API users get used to set this content type
|
||||
# as it won't trigger Rails' automatic parsing of the request body for parameters
|
||||
|
@ -127,7 +173,7 @@ class AttachmentsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
# modify by nwb
|
||||
if @attachment.container_type == 'Course'
|
||||
if @attachment.container.is_a?(Course) || @attachment.container.course
|
||||
if @course.nil?
|
||||
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
|
||||
else
|
||||
|
@ -240,6 +286,8 @@ private
|
|||
raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename
|
||||
if @attachment.container_type == 'Course'
|
||||
@course = @attachment.course
|
||||
elsif @attachment.container.course
|
||||
@course = @attachment.container.course
|
||||
else
|
||||
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication'
|
||||
@project = @attachment.project
|
||||
|
|
|
@ -2,7 +2,7 @@ class AvatarController < ApplicationController
|
|||
|
||||
|
||||
#before_filter :set_cache_buster
|
||||
include AvatarHelper
|
||||
include AvatarHelper
|
||||
|
||||
def upload
|
||||
# Make sure that API users get used to set this content type
|
||||
|
@ -77,6 +77,40 @@ class AvatarController < ApplicationController
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
#add by zjc
|
||||
#删除图片
|
||||
def delete_image
|
||||
@source_type = params[:source_type]
|
||||
@source_id = params[:source_id]
|
||||
@source = nil #eval(@source_type).find(@source_id)
|
||||
c = Object.const_get(@source_type)
|
||||
if c.respond_to?(:find)
|
||||
@source = c.find(@source_id)
|
||||
end
|
||||
|
||||
diskfile=disk_filename(@source_type,@source_id)
|
||||
unless diskfile.nil? || diskfile == ""
|
||||
path = File.dirname(diskfile)
|
||||
if File.directory?(path) && File.exist?(diskfile)
|
||||
File.delete(diskfile)
|
||||
end
|
||||
end
|
||||
rescue e do
|
||||
logger.info e.message
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.api {
|
||||
if saved
|
||||
render :action => 'upload', :status => :created
|
||||
else
|
||||
render_validation_errors(@avatar)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class BidsController < ApplicationController
|
|||
# end
|
||||
before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ]
|
||||
|
||||
before_filter :memberAccess, only: :show_project
|
||||
#before_filter :memberAccess, only: :show_project
|
||||
|
||||
helper :watchers
|
||||
helper :attachments
|
||||
|
@ -375,11 +375,9 @@ class BidsController < ApplicationController
|
|||
@option = []
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
membership.member_roles.each{|role|
|
||||
if(role.role_id == 3)
|
||||
@option << membership.project
|
||||
end
|
||||
}
|
||||
if membership.user.allowed_to?(:quote_project,membership.project)
|
||||
@option << membership.project
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -451,17 +449,9 @@ class BidsController < ApplicationController
|
|||
# 显示作业课程
|
||||
# add by nwb
|
||||
def show_courseEx
|
||||
if (User.current.logged? && User.current.member_of_course?(@bid.courses.first))
|
||||
if (User.current.logged? && (User.current.member_of_course?(@bid.courses.first) || User.current.admin?))
|
||||
# flash[:notice] = ""
|
||||
@membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
@option = []
|
||||
@membership.each do |membership|
|
||||
membership.member_roles.each{|role|
|
||||
if(role.role_id == 3)
|
||||
@option << membership.course
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
@user = @bid.author
|
||||
@bidding_project = @bid.biding_projects.all
|
||||
|
@ -492,7 +482,7 @@ class BidsController < ApplicationController
|
|||
#ended
|
||||
end
|
||||
|
||||
if @bid.homework_type == 1
|
||||
if @bid.homework_type
|
||||
@homework = HomeworkAttach.new
|
||||
#@homework_list = @bid.homeworks
|
||||
#增加作业按评分排序,
|
||||
|
@ -990,7 +980,7 @@ class BidsController < ApplicationController
|
|||
return true if current_user.admin?
|
||||
#return 0 if @bid.courses.first.project_type == Project::ProjectType_project
|
||||
currentUser = User.current
|
||||
render_403 unless currentUser.member_of_cousrse?(@bid.courses.first)
|
||||
render_403 unless currentUser.member_of_course?(@bid.courses.first)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -70,7 +70,7 @@ class BoardsController < ApplicationController
|
|||
@message = Message.new(:board => @board)
|
||||
#modify by nwb
|
||||
if @project
|
||||
render :action => 'show', :layout => !request.xhr?
|
||||
render :action => 'show', :layout => 'base_projects'
|
||||
elsif @course
|
||||
render :action => 'show', :layout => 'base_courses'
|
||||
end
|
||||
|
@ -140,7 +140,11 @@ private
|
|||
end
|
||||
|
||||
def find_board_if_available
|
||||
@board = @project.boards.find(params[:id]) if params[:id]
|
||||
if @project
|
||||
@board = @project.boards.find(params[:id]) if params[:id]
|
||||
elsif @course
|
||||
@board = @course.boards.find(params[:id]) if params[:id]
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# fq
|
||||
# class BidsController < ApplicationController
|
||||
class ContestsController < ApplicationController
|
||||
layout "contest_base"
|
||||
menu_item :respond
|
||||
menu_item :project, :only => :show_project
|
||||
menu_item :application, :only => :show_softapplication
|
||||
|
@ -77,6 +78,10 @@ class ContestsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def search
|
||||
redirect_to action: 'index',name:params[:name]
|
||||
end
|
||||
|
||||
def homework
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@bids = @course.homeworks.order('deadline DESC')
|
||||
|
@ -232,12 +237,7 @@ class ContestsController < ApplicationController
|
|||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
#membership.member_roles.each{|role|
|
||||
# if(role.role_id == 3)
|
||||
# @option << membership.project
|
||||
# end
|
||||
#}
|
||||
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
if User.current.allowed_to?(:quote_project, membership.project)
|
||||
@option << membership.project
|
||||
end
|
||||
end
|
||||
|
@ -326,13 +326,8 @@ class ContestsController < ApplicationController
|
|||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
#membership.member_roles.each{|role|
|
||||
#if(role.role_id == 3)
|
||||
#@option << membership.project
|
||||
#end
|
||||
#}
|
||||
#拥有编辑项目权限的可将该项目参赛
|
||||
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
if User.current.allowed_to?(:quote_project, membership.project)
|
||||
@option << membership.project
|
||||
end
|
||||
end
|
||||
|
|
|
@ -155,7 +155,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base'
|
||||
render :layout => 'course_base'
|
||||
scope = Course
|
||||
unless params[:closed]
|
||||
scope = scope.active
|
||||
|
@ -172,7 +172,7 @@ class CoursesController < ApplicationController
|
|||
## 有角色参数的才是课程,没有的就是项目
|
||||
@render_file = 'member_list'
|
||||
@teachers= searchTeacherAndAssistant(@course)
|
||||
@canShowCode = isCourseTeacher(User.current.id)
|
||||
@canShowCode = isCourseTeacher(User.current.id,@course)
|
||||
case params[:role]
|
||||
when '1'
|
||||
@subPage_title = l :label_teacher_list
|
||||
|
@ -217,7 +217,7 @@ class CoursesController < ApplicationController
|
|||
@issue_category ||= IssueCategory.new
|
||||
@member ||= @course.members.new
|
||||
@trackers = Tracker.sorted.all
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
if User.current.user_extensions.identity
|
||||
|
@ -239,18 +239,18 @@ class CoursesController < ApplicationController
|
|||
@trackers = Tracker.sorted.all
|
||||
|
||||
if User.current.user_extensions.identity == 0
|
||||
if @course.save
|
||||
if @course.save
|
||||
#unless User.current.admin?
|
||||
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.project_id = -1
|
||||
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)
|
||||
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)
|
||||
end
|
||||
@course.members << m
|
||||
@course.course_infos << course
|
||||
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.project_id = -1
|
||||
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)
|
||||
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)
|
||||
end
|
||||
@course.members << m
|
||||
@course.course_infos << course
|
||||
#end
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
@ -272,7 +272,7 @@ class CoursesController < ApplicationController
|
|||
format.api { render_validation_errors(@course) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
|
@ -643,7 +649,7 @@ class CoursesController < ApplicationController
|
|||
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
||||
#
|
||||
@teachers= searchTeacherAndAssistant(@course)
|
||||
@canShowRealName = isCourseTeacher(User.current.id)
|
||||
@canShowRealName = isCourseTeacher(User.current.id,@course)
|
||||
|
||||
if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
|
||||
@user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
|
||||
|
@ -656,9 +662,10 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
|
||||
#判断指定用户是否为课程教师
|
||||
def isCourseTeacher(id)
|
||||
def isCourseTeacher(id,course)
|
||||
result = false
|
||||
if @teachers && @teachers.find_by_user_id(id) != nil
|
||||
user = User.find(id)
|
||||
if user.nil? && user.allowed_to?(:as_teacher,course)#@teachers && @teachers.count != 0 && @teachers.find_by_user_id(id) != nil
|
||||
result = true
|
||||
end
|
||||
result
|
||||
|
@ -708,4 +715,4 @@ class CoursesController < ApplicationController
|
|||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,19 +23,27 @@ 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
|
||||
|
||||
def index
|
||||
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
||||
documents = @project.documents.includes(:attachments, :category).all
|
||||
temp = @project.documents.includes(:attachments, :category).all
|
||||
documents = []
|
||||
temp.each do |doc|
|
||||
if doc.has_right?(@project)
|
||||
documents << doc
|
||||
end
|
||||
end
|
||||
case @sort_by
|
||||
when 'date'
|
||||
@grouped = documents.group_by {|d| d.updated_on.to_date }
|
||||
when 'title'
|
||||
@grouped = documents.group_by {|d| d.title.first.upcase}
|
||||
when 'author'
|
||||
@grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
|
||||
# @grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
|
||||
@grouped = documents.group_by {|d| d.user.name }
|
||||
else
|
||||
@grouped = documents.group_by(&:category)
|
||||
end
|
||||
|
@ -100,4 +108,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 == nil || (@document != nil && @document.is_public==1))
|
||||
render_403 :message => :notice_not_authorized
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -163,7 +163,7 @@ class FilesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 返回制定资源类型的资源列表
|
||||
# 返回指定资源类型的资源列表
|
||||
# added by nwb
|
||||
def getattachtype
|
||||
sort_init 'created_on', 'desc'
|
||||
|
|
|
@ -50,14 +50,14 @@ class ForumsController < ApplicationController
|
|||
|
||||
def index
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@forums_all = Forum.all
|
||||
@forums_all = Forum.where('1=1')
|
||||
@forums_count = @forums_all.count
|
||||
@forums_pages = Paginator.new @forums_count, @limit, params['page']
|
||||
|
||||
|
||||
@offset ||= @forums_pages.offset
|
||||
# @forums = @forums_all.offset(@offset).limit(@limit).all
|
||||
@forums = Forum.all
|
||||
@forums = @forums_all.offset(@offset).limit(@limit).all
|
||||
#@forums = Forum.all
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @forums }
|
||||
|
@ -166,10 +166,10 @@ class ForumsController < ApplicationController
|
|||
|
||||
def search_forum
|
||||
# @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'")
|
||||
name = params[:name]
|
||||
(redirect_to forums_path, :notice => l(:label_sumbit_empty);return) if name.blank?
|
||||
q = "%#{params[:name].strip}%"
|
||||
(redirect_to forums_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@forums_all = Forum.where("name LIKE '%#{params[:name]}%'")
|
||||
@forums_all = Forum.where("name LIKE ?", q)
|
||||
@forums_count = @forums_all.count
|
||||
@forums_pages = Paginator.new @forums_count, @limit, params['page']
|
||||
|
||||
|
@ -185,11 +185,13 @@ class ForumsController < ApplicationController
|
|||
end
|
||||
|
||||
def search_memo
|
||||
q = "%#{params[:name].strip}%"
|
||||
|
||||
limit = PageLimit
|
||||
@memo = Memo.new
|
||||
@offset, @limit = api_offset_and_limit({:limit => limit})
|
||||
@forum = Forum.find(params[:id])
|
||||
@memos_all = @forum.topics.where("subject LIKE '%#{params[:name]}%'")
|
||||
@memos_all = @forum.topics.where("subject LIKE ?", q)
|
||||
@topic_count = @memos_all.count
|
||||
@topic_pages = Paginator.new @topic_count, @limit, params['page']
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class HomeworkAttachController < ApplicationController
|
||||
layout "course_base"
|
||||
include CoursesHelper
|
||||
###############################
|
||||
#判断当前角色权限时需先找到当前操作的project
|
||||
|
@ -169,7 +170,15 @@ class HomeworkAttachController < ApplicationController
|
|||
#users:该作业所有成员
|
||||
#q:模糊匹配的用户的昵称
|
||||
def members_for_homework homework,users,q
|
||||
homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id not in (:users)", {:role_id => [5, 10],:users => users}).joins(:user).where("users.login like '%#{q}%'")
|
||||
#homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id not in (:users)", {:role_id => [5, 10],:users => users}).joins(:user).where("users.login like '%#{q}%'")
|
||||
unpartin_users = homework.bid.courses.first.members.where("user_id not in (:users)", {:users => users}).joins(:user).where("users.login like '%#{q}%'")
|
||||
canpartin_users = []
|
||||
unpartin_users.each do |m|
|
||||
if m.user.allowed_to?(:paret_in_homework,homework.bid.courses.first)
|
||||
canpartin_users << m
|
||||
end
|
||||
end
|
||||
canpartin_users
|
||||
end
|
||||
|
||||
def edit
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class IssueCategoriesController < ApplicationController
|
||||
layout "project_base"
|
||||
menu_item :settings
|
||||
model_object IssueCategory
|
||||
before_filter :find_model_object, :except => [:index, :new, :create]
|
||||
|
|
|
@ -119,6 +119,7 @@ class IssuesController < ApplicationController
|
|||
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
|
||||
|
||||
@project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young
|
||||
@available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
@ -194,6 +195,30 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
|
||||
if saved
|
||||
|
||||
#修改界面增加跟踪者
|
||||
watcherlist = @issue.watcher_users
|
||||
select_users = []
|
||||
if params[:issue]
|
||||
if params[:issue][:watcher_user_ids]
|
||||
params[:issue][:watcher_user_ids].each do |user_id|
|
||||
select_users << User.find(user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
select_users.each do |user|
|
||||
if watcherlist.include? user
|
||||
else
|
||||
@issue.add_watcher user
|
||||
end
|
||||
end
|
||||
watcherlist.each do |user|
|
||||
if select_users.include? user
|
||||
else
|
||||
@issue.remove_watcher user
|
||||
end
|
||||
end
|
||||
|
||||
render_attachment_warning_if_needed(@issue)
|
||||
reply_id = params[:reference_user_id].to_i
|
||||
if reply_id > 0
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# -*coding:utf-8 -*-
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
|
@ -14,14 +15,17 @@
|
|||
# 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.
|
||||
|
||||
class MembersController < ApplicationController
|
||||
model_object Member
|
||||
before_filter :find_model_object, :except => [:index, :create, :autocomplete]
|
||||
before_filter :find_model_object, :except => [:index, :create, :autocomplete,:gitlabautocomplete]
|
||||
#before_filter :find_model_object_contest, :except => [:index, :create, :autocomplete]
|
||||
before_filter :find_project_from_association, :except => [:index, :create, :autocomplete]
|
||||
before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete]
|
||||
before_filter :authorize
|
||||
accept_api_auth :index, :show, :create, :update, :destroy
|
||||
before_filter :find_project_from_association, :except => [:index, :create, :autocomplete,:gitlabautocomplete]
|
||||
before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete,:gitlabautocomplete]
|
||||
before_filter :authorize, :except => [:gitlabautocomplete]
|
||||
accept_api_auth :index, :show, :create, :update, :destroy
|
||||
|
||||
include GitlabHelper
|
||||
|
||||
def index
|
||||
@offset, @limit = api_offset_and_limit
|
||||
|
@ -76,8 +80,10 @@ class MembersController < ApplicationController
|
|||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
||||
user_grades << UserGrade.new(:user_id => user_id, :project_id => @project.id)
|
||||
## added by nie
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id)
|
||||
|
||||
if (params[:membership][:role_ids])
|
||||
role = Role.find(params[:membership][:role_ids][0])
|
||||
project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id) if role.allowed_to?(:is_manager)
|
||||
# ProjectInfo.create(:name => "test", :user_id => 123)
|
||||
end
|
||||
## end
|
||||
|
@ -86,8 +92,9 @@ class MembersController < ApplicationController
|
|||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
|
||||
user_grades << UserGrade.new(:user_id => params[:membership][:user_id], :project_id => @project.id)
|
||||
## added by nie
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
project_info << ProjectInfo.new(:project_id => @project.id, :user_id => params[:membership][:user_id])
|
||||
if (params[:membership][:role_ids])
|
||||
role = Role.find(params[:membership][:role_ids][0])
|
||||
project_info << ProjectInfo.new(:project_id => @project.id, :user_id => params[:membership][:user_id]) if role.allowed_to?(:is_manager)
|
||||
end
|
||||
## end
|
||||
end
|
||||
|
@ -99,6 +106,7 @@ class MembersController < ApplicationController
|
|||
end
|
||||
if members.present? && members.all? { |m| m.valid? }
|
||||
members.each do |member|
|
||||
add_trustie_user(@project.id,member.user_id)
|
||||
AppliedProject.deleteappiled(member.user_id, @project.id)
|
||||
end
|
||||
end
|
||||
|
@ -121,16 +129,24 @@ class MembersController < ApplicationController
|
|||
attrs = params[:membership].dup
|
||||
user_ids = attrs.delete(:user_ids)
|
||||
user_ids.each do |user_id|
|
||||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
||||
member = Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
||||
role = Role.find_by_id(params[:membership][:role_ids])
|
||||
# 这里的判断只能通过角色名,可以弄成常量
|
||||
if role.name == "学生"
|
||||
StudentsForCourse.create(:student_id => user_id, :course_id =>@course.id)
|
||||
end
|
||||
members << member
|
||||
#user_grades << UserGrade.new(:user_id => user_id, :course_id => @course.id)
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
course_info << CourseInfo.new(:user_id => user_id, :course_id => @course.id)
|
||||
if (params[:membership][:role_ids])
|
||||
role = Role.find(params[:membership][:role_ids][0])
|
||||
course_info << CourseInfo.new(:user_id => user_id, :course_id => @course.id) if role.allowed_to?(:is_manager)
|
||||
end
|
||||
end
|
||||
else
|
||||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
course_info << CourseInfo.new(:course_id => @course.id, :user_id => params[:membership][:user_id])
|
||||
if (params[:membership][:role_ids])
|
||||
role = Role.find(params[:membership][:role_ids][0])
|
||||
course_info << CourseInfo.new(:course_id => @course.id, :user_id => params[:membership][:user_id]) if role.allowed_to?(:is_manager)
|
||||
end
|
||||
end
|
||||
@course.members << members
|
||||
|
@ -162,14 +178,17 @@ class MembersController < ApplicationController
|
|||
@member.role_ids = params[:membership][:role_ids]
|
||||
|
||||
#added by nie
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
@projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id)
|
||||
@projectInfo.save
|
||||
else
|
||||
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
||||
if user_admin.size > 0
|
||||
user_admin.each do |user|
|
||||
user.destroy
|
||||
if (params[:membership][:role_ids])
|
||||
role = Role.find(params[:membership][:role_ids][0])
|
||||
if role.allowed_to?(:is_manager)
|
||||
@projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id)
|
||||
@projectInfo.save
|
||||
else
|
||||
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
||||
if user_admin.size > 0
|
||||
user_admin.each do |user|
|
||||
user.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -191,14 +210,26 @@ class MembersController < ApplicationController
|
|||
if params[:membership]
|
||||
@member.role_ids = params[:membership][:role_ids]
|
||||
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
@courseInfo = CourseInfos.new(:user_id => @member.user_id, :course_id => @course.id)
|
||||
@courseInfo.save
|
||||
else
|
||||
user_admin = CourseInfos.where("user_id = ? and course_id = ?", @member.user_id, @course.id)
|
||||
if user_admin.size > 0
|
||||
user_admin.each do |user|
|
||||
user.destroy
|
||||
if (params[:membership][:role_ids])
|
||||
role = Role.find(params[:membership][:role_ids][0])
|
||||
# 这里的判断只能通过角色名,可以弄成常量
|
||||
if role.name == "学生"
|
||||
StudentsForCourse.create(:student_id => @member.user_id, :course_id =>@course.id)
|
||||
else
|
||||
joined = StudentsForCourse.where('student_id = ? and course_id = ?', @member.user_id,@course.id)
|
||||
joined.each do |join|
|
||||
join.delete
|
||||
end
|
||||
end
|
||||
if role.allowed_to?(:is_manager)
|
||||
@courseInfo = CourseInfos.new(:user_id => @member.user_id, :course_id => @course.id)
|
||||
@courseInfo.save
|
||||
else
|
||||
user_admin = CourseInfos.where("user_id = ? and course_id = ?", @member.user_id, @course.id)
|
||||
if user_admin.size > 0
|
||||
user_admin.each do |user|
|
||||
user.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -225,6 +256,8 @@ class MembersController < ApplicationController
|
|||
#课程成员删除修改
|
||||
if @project
|
||||
if request.delete? && @member.deletable?
|
||||
# 删除gitlab用户
|
||||
delete_trustie_user(@project.id,@member.user_id)
|
||||
@member.destroy
|
||||
# end
|
||||
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
||||
|
@ -260,6 +293,11 @@ class MembersController < ApplicationController
|
|||
user.destroy
|
||||
end
|
||||
end
|
||||
joined = StudentsForCourse.where('student_id = ? and course_id = ?', @member.user_id,@course.id)
|
||||
joined.each do |join|
|
||||
join.delete
|
||||
end
|
||||
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_settings_in_courses }
|
||||
|
@ -281,6 +319,7 @@ class MembersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def redirect_to_settings_in_projects
|
||||
|
|
|
@ -77,6 +77,9 @@ class MessagesController < ApplicationController
|
|||
|
||||
# Reply to a topic
|
||||
def reply
|
||||
if params[:reply][:content] == ""
|
||||
(redirect_to board_message_path(@board, @topic, :r => @reply), :notice => l(:label_reply_empty);return)
|
||||
end
|
||||
@reply = Message.new
|
||||
@reply.author = User.current
|
||||
@reply.board = @board
|
||||
|
@ -112,10 +115,19 @@ class MessagesController < ApplicationController
|
|||
(render_403; return false) unless @message.destroyable_by?(User.current)
|
||||
r = @message.to_param
|
||||
@message.destroy
|
||||
if @message.parent
|
||||
redirect_to board_message_path(@board, @message.parent, :r => r)
|
||||
else
|
||||
redirect_to project_board_path(@project, @board)
|
||||
# modify by nwb
|
||||
if @project
|
||||
if @message.parent
|
||||
redirect_to board_message_path(@board, @message.parent, :r => r)
|
||||
else
|
||||
redirect_to project_board_path(@project, @board)
|
||||
end
|
||||
elsif @course
|
||||
if @message.parent
|
||||
redirect_to board_message_path(@board, @message.parent, :r => r)
|
||||
else
|
||||
redirect_to course_board_path(@course, @board)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -98,10 +98,12 @@ class NewsController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@news = News.new(:project => @project, :author => User.current)
|
||||
@course_tag = @project.project_type
|
||||
if @course_tag
|
||||
render :layout => 'base_courses'
|
||||
#modify by nwb
|
||||
if @project
|
||||
@news = News.new(:project => @project, :author => User.current)
|
||||
elsif @course
|
||||
@news = News.new(:course => @course, :author => User.current)
|
||||
render :layout => 'base_courses'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -16,11 +16,10 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class PreviewsController < ApplicationController
|
||||
before_filter :find_project, :find_attachments, :find_contest, except: [:contestnotification]
|
||||
before_filter :find_project, :find_attachments, except: :contestnotification
|
||||
|
||||
def issue
|
||||
@issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
|
||||
@issue = @contest.issues.find_by_id(params[:id]) unless params[:id].blank?
|
||||
if @issue
|
||||
@description = params[:issue] && params[:issue][:description]
|
||||
if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
|
||||
|
@ -65,12 +64,4 @@ class PreviewsController < ApplicationController
|
|||
render :partial => 'common/preview'
|
||||
end
|
||||
|
||||
private
|
||||
def find_contest
|
||||
contest_id = (params[:issue] && params[:issue][:contest_id]) || params[:contest_id]
|
||||
@contest = Contest.find(contest_id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -77,6 +77,7 @@ class ProjectsController < ApplicationController
|
|||
helper :words
|
||||
### added by william
|
||||
include ActsAsTaggableOn::TagsHelper
|
||||
include GitlabHelper
|
||||
|
||||
def find_project_repository
|
||||
unless @project.repositories.nil?
|
||||
|
@ -490,11 +491,11 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
def create
|
||||
|
||||
@course_tag = params[:project][:project_type]
|
||||
if(@course_tag=="1")
|
||||
if User.current.user_extensions.identity#.include?(UserExtensions::TEACHER,UserExtensions::DEVELOPER)
|
||||
if User.current.user_extensions.identity#.include?(UserExtensions::TEACHER,UserExtensions::DEVELOPER)
|
||||
@course = Course.new
|
||||
@course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
|
||||
@course.safe_attributes = params[:project][:course]
|
||||
|
@ -513,11 +514,12 @@ class ProjectsController < ApplicationController
|
|||
@trackers = Tracker.sorted.all
|
||||
@project = Project.new
|
||||
@project.user_id = User.current.id
|
||||
@project.dts_test = params[:project][:dts_test]
|
||||
@project.safe_attributes = params[:project]
|
||||
if @course_tag == '1'
|
||||
@project.identifier = @course.extra
|
||||
end
|
||||
if @course_tag == '1'
|
||||
if @course_tag == '1'
|
||||
if User.current.user_extensions.identity == 0
|
||||
if@course.save
|
||||
if validate_parent_id && @project.save
|
||||
|
@ -528,7 +530,7 @@ class ProjectsController < ApplicationController
|
|||
m = Member.new(:user => User.current, :roles => [r])
|
||||
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
|
||||
user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
|
||||
if params[:project][:is_public] == '1'
|
||||
if params[:project][:is_public] == '1'
|
||||
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :project_type => @course_tag)
|
||||
end
|
||||
@project.members << m
|
||||
|
@ -541,7 +543,7 @@ class ProjectsController < ApplicationController
|
|||
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
|
||||
redirect_to new_project_path(attrs, :course => '0')
|
||||
#Added by young
|
||||
|
||||
|
||||
elsif params[:course_continue]
|
||||
redirect_to new_project_path(:course => '1')
|
||||
#Ended by young
|
||||
|
@ -574,10 +576,11 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
else
|
||||
#@project.memberships.create
|
||||
if validate_parent_id && @project.save
|
||||
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
||||
# Add current user as a project member if he is not admin
|
||||
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
|
||||
m = Member.new(:user => User.current, :roles => [r])
|
||||
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
|
||||
|
@ -587,7 +590,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
@project.members << m
|
||||
@project.project_infos << project
|
||||
end
|
||||
#end
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
|
@ -595,7 +598,7 @@ class ProjectsController < ApplicationController
|
|||
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
|
||||
redirect_to new_project_path(attrs, :course => '0')
|
||||
#Added by young
|
||||
|
||||
|
||||
elsif params[:course_continue]
|
||||
redirect_to new_project_path(:course => '1')
|
||||
#Ended by young
|
||||
|
@ -697,8 +700,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
|
||||
|
@ -729,8 +738,8 @@ class ProjectsController < ApplicationController
|
|||
@canShowRealName = isCourseTeacher(User.current.id)
|
||||
end
|
||||
|
||||
#勿删 real_name action为虚拟的该方法并不存在,用来辅助判断真名权限
|
||||
#勿删 @canShowRealName = User.current.allowed_to?({:controller => "projects", :action => "real_name"}, @project || @projects, :global => false)
|
||||
# real_name action为虚拟的该方法并不存在,用来辅助判断真名权限
|
||||
# @canShowRealName = User.current.allowed_to?({:controller => "projects", :action => "real_name"}, @project || @projects, :global => false)
|
||||
respond_to do |format|
|
||||
format.html{render :layout => 'base_courses' if @base_courses_tag==1}
|
||||
format.api
|
||||
|
@ -746,7 +755,7 @@ class ProjectsController < ApplicationController
|
|||
#Added by young
|
||||
# @course_tag = params[:course]
|
||||
# if @course_tag == '1'
|
||||
@course = Course.find_by_extra(@project.identifier)
|
||||
#@course = Course.find_by_extra(@project.identifier)
|
||||
# if @project.project_type == 1
|
||||
# render :layout => 'base_courses'
|
||||
# else
|
||||
|
@ -838,6 +847,7 @@ class ProjectsController < ApplicationController
|
|||
|
||||
def update
|
||||
@project.safe_attributes = params[:project]
|
||||
@project.dts_test = params[:project][:dts_test]
|
||||
if validate_parent_id && @project.save
|
||||
@course = Course.find_by_extra(@project.identifier)
|
||||
unless @course.nil?
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# 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.
|
||||
# GNU General Public License for more details. add_gitlab_user
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
|
@ -31,16 +31,17 @@ class RepositoriesController < ApplicationController
|
|||
|
||||
before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo]
|
||||
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
|
||||
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo]
|
||||
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo,:gitlabautocomplete,:add_gitlab_user]
|
||||
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
|
||||
before_filter :authorize , :except => [:newrepo,:newcreate,:fork]
|
||||
before_filter :authorize , :except => [:newrepo,:newcreate,:fork,:gitlabautocomplete,:add_gitlab_user]
|
||||
accept_rss_auth :revisions
|
||||
# hidden repositories filter // 隐藏代码过滤器
|
||||
before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ]
|
||||
helper :repositories
|
||||
include RepositoriesHelper
|
||||
helper :repositories
|
||||
include GitlabHelper
|
||||
#@root_path = RepositoriesHelper::ROOT_PATH
|
||||
|
||||
|
||||
|
||||
rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
|
||||
def new
|
||||
|
@ -58,6 +59,9 @@ class RepositoriesController < ApplicationController
|
|||
|
||||
|
||||
def newrepo
|
||||
# modify by nwb
|
||||
# 查找当前用户的gitlab账号
|
||||
@gitlab_user = GitlabUser.find_by_user_id(User.current.id)
|
||||
scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
|
||||
@repository = Repository.factory(scm)
|
||||
@repository.is_default = @project.repository.nil?
|
||||
|
@ -91,58 +95,129 @@ class RepositoriesController < ApplicationController
|
|||
render :action => 'show', :layout => 'base_projects'
|
||||
end
|
||||
|
||||
# 创建git版本库
|
||||
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 == 'Git'
|
||||
# add by nwb
|
||||
# 增加对gitlab版本库的支持
|
||||
user = User.current
|
||||
@gitlab_user = GitlabUser.find_by_user_id(user.id)
|
||||
|
||||
attrs = pickup_extra_info
|
||||
@repository = Repository.factory('Git')
|
||||
@repository.safe_attributes = params[:repository]
|
||||
if attrs[:attrs_extra].keys.any?
|
||||
@repository.merge_extra_info(attrs[:attrs_extra])
|
||||
end
|
||||
@repository.project = @project
|
||||
|
||||
# 数据检测
|
||||
if params[:repository][:identifier] == ""
|
||||
flash[:error] = l(:project_module_repository) + l(:blank)
|
||||
render :action => 'newrepo', :layout => 'base_projects'
|
||||
return
|
||||
elsif params[:repository][:gitlab_user] == ""
|
||||
flash[:error] = l(:label_user) + l(:blank)
|
||||
render :action => 'newrepo', :layout => 'base_projects'
|
||||
return
|
||||
elsif params[:repository][:gitlab_email] == ""
|
||||
flash[:error] = l(:field_mail) + l(:blank)
|
||||
render :action => 'newrepo', :layout => 'base_projects'
|
||||
return
|
||||
elsif params[:repository][:upassword] == ""
|
||||
flash[:error] = l(:label_password) + l(:blank)
|
||||
render :action => 'newrepo', :layout => 'base_projects'
|
||||
return
|
||||
end
|
||||
|
||||
# 判断gitlab用户是否存在,不存在则创建
|
||||
if @gitlab_user.nil?
|
||||
if !create_user(params[:repository][:gitlab_user],user.show_name,params[:repository][:upassword],params[:repository][:gitlab_email],user.id)
|
||||
# 创建gitlab用户失败
|
||||
# 验证gitlab是否可由指定的账号、密码登录
|
||||
if login_init_gitlab(params[:repository][:gitlab_email],params[:repository][:upassword],params[:repository][:gitlab_user],user.id)
|
||||
@gitlab_user = GitlabUser.find_by_user_id(user.id)
|
||||
else
|
||||
flash[:error] = l(:error_create_gitlab_user)
|
||||
render :action => 'newrepo', :layout =>'base_projects'
|
||||
return
|
||||
end
|
||||
end
|
||||
@gitlab_user = GitlabUser.find_by_user_id(user.id)
|
||||
end
|
||||
# 创建gitlab版本库
|
||||
repos = params[:repository][:identifier]
|
||||
temp = create_project_for_user(repos,@project.id,@gitlab_user.gitlab_user_id)
|
||||
if !temp[:result]
|
||||
# 创建gitlab项目失败
|
||||
flash[:error] = l(:error_create_gitlab_project)
|
||||
render :action => 'newrepo', :layout =>'base_projects'
|
||||
return
|
||||
end
|
||||
|
||||
# 连接创建成功后的gitlab版本库
|
||||
gitproject = GitlabProject.find_by_gitlab_project_id(temp[:gitprojectid])
|
||||
@repository.login = user.login
|
||||
@repository.url = gitproject.localfile_url
|
||||
@repository.root_url = gitproject.localfile_url
|
||||
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
|
||||
|
@ -177,6 +252,13 @@ class RepositoriesController < ApplicationController
|
|||
private :pickup_extra_info
|
||||
|
||||
def committers
|
||||
@gitlab_project = GitlabProject.find_by_localfile_url(@repository.url)
|
||||
if @gitlab_project
|
||||
# gitlab项目,获取当前项目的gitabuser列表
|
||||
@gitlabusers = get_project_users(@gitlab_project.gitlab_project_id)
|
||||
RepositoriesController.cur_gitlab_user= @gitlabusers
|
||||
end
|
||||
|
||||
@committers = @repository.committers
|
||||
@users = @project.users
|
||||
additional_user_ids = @committers.collect(&:last).collect(&:to_i) - @users.collect(&:id)
|
||||
|
@ -191,6 +273,38 @@ class RepositoriesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
def self.cur_gitlab_user=(users)
|
||||
Thread.current[:gitlab_user] = users
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
def self.cur_gitlab_user
|
||||
Thread.current[:gitlab_user] ||= nil
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
# gitlab成员管理界面搜索处理
|
||||
def gitlabautocomplete
|
||||
@gitlab_project = GitlabProject.find_by_gitlab_project_id(params[:gitlab_project_id])
|
||||
if @gitlab_project
|
||||
# gitlab项目,获取当前项目的gitabuser列表
|
||||
# gitlab不支持ajax发送http请求数据
|
||||
#@gitlabusers = get_project_users(@gitlab_project.gitlab_project_id)
|
||||
@gitlabusers = RepositoriesController.cur_gitlab_user
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
# 添加一个用户至gitlab项目
|
||||
def add_gitlab_user
|
||||
dd
|
||||
end
|
||||
|
||||
def destroy
|
||||
@root_path=RepositoriesHelper::ROOT_PATH
|
||||
@repo_name=User.current.login.to_s+"_"+@repository.identifier.to_s
|
||||
|
@ -200,15 +314,15 @@ class RepositoriesController < ApplicationController
|
|||
redirect_to settings_project_path(@project, :tab => 'repositories')
|
||||
if(@repository.type=="Repository::Git")
|
||||
logger.info "destory the repository value"+"root path"+@root_path+"repo_name"+@repo_name+
|
||||
"repository_name"+@repository_name+"user group"+@middle
|
||||
system "sed -i /"+@repo_name+"/{d} "+@root_path+"user.passwd"
|
||||
system "sed -i /"+@middle+"/{d} "+@root_path+"group.passwd"
|
||||
system "rm -r "+@root_path+"htdocs/"+@repository_name
|
||||
# if(@sed_user&&@sed_group&&@remove)
|
||||
# else
|
||||
# logger.info "An error occured when destory the repository"+"delete form passwd: \n"+
|
||||
# @sed_user+"delete from group"+@sed_group+"delete from file"+@remove
|
||||
# end
|
||||
"repository_name"+@repository_name+"user group"+@middle
|
||||
#system "sed -i /"+@repo_name+"/{d} "+@root_path+"user.passwd"
|
||||
#system "sed -i /"+@middle+"/{d} "+@root_path+"group.passwd"
|
||||
#system "rm -r "+@root_path+"htdocs/"+@repository_name
|
||||
|
||||
gitlabproject = GitlabProject.find_by_localfile_url(@repository.url)
|
||||
if gitlabproject
|
||||
gitlabproject.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -240,7 +354,7 @@ class RepositoriesController < ApplicationController
|
|||
@course_tag = params[:course]
|
||||
project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
|
||||
ip = RepositoriesHelper::REPO_IP_ADDRESS
|
||||
@repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip+
|
||||
@repos_url = @repository.repos_url#"http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+
|
||||
@repository.url.slice(project_path_cut, @repository.url.length).to_s
|
||||
if @course_tag == 1
|
||||
render :action => 'show', :layout => 'base_courses'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class SchoolController < ApplicationController
|
||||
|
||||
layout 'course_base'
|
||||
before_filter :require_admin, :only => :upload_logo
|
||||
|
||||
def upload
|
||||
|
@ -98,16 +98,18 @@ class SchoolController < ApplicationController
|
|||
end
|
||||
|
||||
def search_school
|
||||
if params[:province].nil? or params[:province] == "0"
|
||||
@school = School.where("name LIKE '%"+params[:key_word]+"%'");
|
||||
else
|
||||
@school = School.where("province = ? AND name LIKE '%"+params[:key_word]+"%'", params[:province]);
|
||||
end
|
||||
q = "%#{params[:key_word].strip}%"
|
||||
|
||||
@school = School.where("name LIKE ?", q)
|
||||
@school = @school.where("province = ?", params[:province]) if (params[:province] != '0' )
|
||||
|
||||
options = ""
|
||||
@school.each do |s|
|
||||
options << "<li style = 'width: 33%; float: left'> <a id=#{s.id} onclick='test(this.id)'>#{s.name}</a></li>"
|
||||
end
|
||||
|
||||
render :text => options
|
||||
|
||||
options = "<div class='flash error' id='flash_error'>#{l(:label_school_not_fount)}</div>" if options.blank?
|
||||
|
||||
render :text => options
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class SoftapplicationsController < ApplicationController
|
||||
layout "contest_base"
|
||||
before_filter :find_softapplication, only: [:edit, :update, :destroy]
|
||||
before_filter :editable, only: [:edit, :update]
|
||||
before_filter :destroyable, only: :destroy
|
||||
|
@ -18,20 +19,20 @@ class SoftapplicationsController < ApplicationController
|
|||
|
||||
#new added sort
|
||||
if params[:softapplication_sort_type].present?
|
||||
case params[:softapplication_sort_type]
|
||||
case params[:softapplication_sort_type]
|
||||
when '0'
|
||||
@softapplications = @softapplications[@offset, @limit]
|
||||
@softapplications = @softapplications[@offset, @limit]
|
||||
@s_state = 0
|
||||
when '1'
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
end
|
||||
else
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
else
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
end
|
||||
#new added end
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @softapplications }
|
||||
|
@ -108,14 +109,8 @@ class SoftapplicationsController < ApplicationController
|
|||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
#membership.member_roles.each{|role|
|
||||
# if(role.role_id == 3)
|
||||
# @option << membership.project
|
||||
# end
|
||||
#}
|
||||
|
||||
#拥有编辑项目权限的可操作该项目
|
||||
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
if User.current.allowed_to?(:quote_project,membership.project)
|
||||
@option << membership.project
|
||||
end
|
||||
end
|
||||
|
@ -145,13 +140,14 @@ class SoftapplicationsController < ApplicationController
|
|||
|
||||
#new changed created function
|
||||
def create
|
||||
#options = params[:softapplication]
|
||||
#options[:app_type_name] = params[:other_input] if options[:app_type_name] == "其他" && params[:other_input]
|
||||
@softapplication = Softapplication.new(params[:softapplication])
|
||||
@softapplication.user = User.current
|
||||
#@softapplication.deposit_project = params[:project]
|
||||
@softapplication.project = Project.find_by_id(params[:project])
|
||||
|
||||
@softapplication.app_type_name = params[:other_input] if params[:other_input] != ""
|
||||
@softapplication.save_attachments(params[:attachments])
|
||||
|
||||
respond_to do |format|
|
||||
if @softapplication.save
|
||||
ContestingSoftapplication.create(:contest_id => params[:contest_id], :softapplication_id => @softapplication.id)
|
||||
|
@ -180,8 +176,16 @@ class SoftapplicationsController < ApplicationController
|
|||
@softapplication.save_attachments(params[:attachments])
|
||||
#@softapplication.deposit_project = params[:project]
|
||||
@softapplication.project = Project.find_by_id(params[:project])
|
||||
|
||||
@softapplication.name = params[:softapplication][:name]
|
||||
@softapplication.android_min_version_available = params[:softapplication][:android_min_version_available]
|
||||
@softapplication.app_type_name = params[:other_input] == "" ? params[:softapplication][:app_type_name] : params[:other_input]
|
||||
@softapplication.description = params[:softapplication][:description]
|
||||
@softapplication.application_developers = params[:softapplication][:application_developers]
|
||||
#@softapplication.app_type_name = params[:other_input] if params[:other_input] != ""
|
||||
respond_to do |format|
|
||||
if @softapplication.update_attributes(params[:softapplication])
|
||||
#if @softapplication.update_attributes(params[:softapplication])
|
||||
if @softapplication.save
|
||||
format.html { redirect_to @softapplication, notice: l(:notice_softapplication_was_successfully_updated) }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
|
@ -212,19 +216,19 @@ class SoftapplicationsController < ApplicationController
|
|||
def new_message
|
||||
@jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
|
||||
if @jour
|
||||
user = @jour.user
|
||||
text = @jour.notes
|
||||
user = @jour.user
|
||||
text = @jour.notes
|
||||
else
|
||||
user = @softapplication.user
|
||||
text = @softapplication.description
|
||||
user = @softapplication.user
|
||||
text = @softapplication.description
|
||||
end
|
||||
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
||||
@content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> "
|
||||
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
@id = user.id
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
#新建评价
|
||||
def create_message
|
||||
|
|
|
@ -5,10 +5,10 @@ class StoresController < ApplicationController
|
|||
layout 'base_stores'
|
||||
|
||||
def search
|
||||
name = params[:name] ||= ''
|
||||
(redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if name.blank?
|
||||
q = "%#{params[:name].strip}%"
|
||||
(redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||
|
||||
result = find_public_attache name
|
||||
result = find_public_attache q
|
||||
@searched_attach = paginateHelper result
|
||||
@result_all_count = result.count;
|
||||
end
|
||||
|
@ -20,25 +20,27 @@ class StoresController < ApplicationController
|
|||
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%").
|
||||
reorder("created_on DESC")
|
||||
|
||||
result = resultSet.to_a.dup
|
||||
# result = resultSet.to_a.dup
|
||||
|
||||
resultSet.to_a.map { |res|
|
||||
if(res.container.nil? ||
|
||||
(res.container.class.to_s=="Project" && res.container.is_public == false) ||
|
||||
(res.container.has_attribute?(:project) && res.container.project.is_public == false) ||
|
||||
(res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
|
||||
false
|
||||
)
|
||||
result.delete(res)
|
||||
end
|
||||
}
|
||||
result
|
||||
# resultSet.to_a.map { |res|
|
||||
# if(res.container.nil? ||
|
||||
# (res.container.class.to_s=="Project" && res.container.is_public == false) ||
|
||||
# (res.container.has_attribute?(:project) && res.container.project.is_public == false) ||
|
||||
# (res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
|
||||
# false
|
||||
# )
|
||||
# result.delete(res)
|
||||
# end
|
||||
# }
|
||||
# result
|
||||
end
|
||||
|
||||
LIMIT = 12 unless const_defined?(:LIMIT)
|
||||
def index
|
||||
@projects_attach = project_classification(0).take(LIMIT)
|
||||
@courses_attach = project_classification(1).take(LIMIT)
|
||||
@courses_attach = Attachment.includes(:course).where("courses.is_public = 1").
|
||||
where(container_type: 'Course').
|
||||
limit(LIMIT)
|
||||
# @projects_attach = Attachment.includes(:project).where("projects.project_type=? AND projects.is_public = ?", 0, 1).
|
||||
# reorder("#{Attachment.table_name}.downloads DESC").
|
||||
# limit(LIMIT)
|
||||
|
|
|
@ -26,7 +26,7 @@ class TestController < ApplicationController
|
|||
end
|
||||
|
||||
def courselist
|
||||
@courses = Project.course_entities
|
||||
@courses = paginateHelper Course.includes(:homeworks).all, 10
|
||||
end
|
||||
|
||||
def ziping files_path
|
||||
|
|
|
@ -33,7 +33,7 @@ class UsersController < ApplicationController
|
|||
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info,
|
||||
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
|
||||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score]
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities]
|
||||
#edit has been deleted by huang, 2013-9-23
|
||||
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
|
||||
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
|
||||
|
@ -53,6 +53,7 @@ class UsersController < ApplicationController
|
|||
include CustomFieldsHelper
|
||||
include AvatarHelper
|
||||
include WordsHelper
|
||||
include GitlabHelper
|
||||
|
||||
# added by liuping 关注
|
||||
|
||||
|
@ -150,6 +151,9 @@ class UsersController < ApplicationController
|
|||
|
||||
# added by fq
|
||||
def user_activities
|
||||
redirect_to user_path(@user, type: params[:type], page: params[:page])
|
||||
return
|
||||
# useless abort.
|
||||
@watcher = User.watched_by_id(@user)
|
||||
events = []
|
||||
for user in @watcher
|
||||
|
@ -255,112 +259,63 @@ class UsersController < ApplicationController
|
|||
|
||||
#end
|
||||
def index
|
||||
|
||||
@project_type = params[:project_type]
|
||||
role = params[:role]
|
||||
|
||||
@status = params[:status] || 1
|
||||
sort_init 'login', 'asc'
|
||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||
|
||||
# Deprecation
|
||||
@project_type = params[:project_type]
|
||||
|
||||
case params[:format]
|
||||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit({:limit => 15})
|
||||
else
|
||||
@limit = 15#per_page_option
|
||||
@limit = 15
|
||||
end
|
||||
|
||||
@status = params[:status] || 1
|
||||
has = {
|
||||
"show_changesets" => true
|
||||
}
|
||||
# @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count
|
||||
|
||||
# retrieve all users
|
||||
scope = UserStatus.visible
|
||||
case role
|
||||
|
||||
# if role has something, change scope.
|
||||
case params[:role]
|
||||
when 'teacher'
|
||||
scope = UserStatus.teacher
|
||||
when 'student'
|
||||
scope = UserStatus.student
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
# unknow
|
||||
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
||||
# scope.each do |user|
|
||||
# UserStatus.create(:changesets_count => user.changesets.count, :watchers_count => user.watcher_users.count, :user_id => user.id)
|
||||
# end
|
||||
|
||||
# pagination
|
||||
@user_count = scope.count
|
||||
@user_pages = Paginator.new @user_count, @limit, params['page']
|
||||
#@offset ||= @user_pages.offset
|
||||
#@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
|
||||
@user_base_tag = params[:id] ? 'base_users':'base'
|
||||
if params[:user_sort_type].present?
|
||||
case params[:user_sort_type]
|
||||
when '0'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 0
|
||||
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
||||
# @projects = @projects[@offset, @limit]
|
||||
when '1'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 1
|
||||
#sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count}
|
||||
#@users = @users[@offset, @limit]
|
||||
when '2'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 2
|
||||
#@users = @users[@offset, @limit]
|
||||
end
|
||||
|
||||
# users classify
|
||||
case params[:user_sort_type]
|
||||
when '0'
|
||||
@s_type = 0
|
||||
@us_ordered = scope.
|
||||
joins("LEFT JOIN users ON user_statuses.user_id = users.id").
|
||||
reorder('users.created_on DESC')
|
||||
when '1'
|
||||
@s_type = 1
|
||||
@us_ordered = scope.reorder('user_statuses.grade DESC')
|
||||
when '2'
|
||||
@s_type = 2
|
||||
@us_ordered = scope.reorder('user_statuses.watchers_count DESC')
|
||||
else
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 1
|
||||
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
||||
# @projects = @projects[@offset, @limit]
|
||||
@s_type = 1
|
||||
@us_ordered = scope.reorder('user_statuses.grade DESC')
|
||||
end
|
||||
|
||||
@users = []
|
||||
@users_statuses.each do |obj|
|
||||
@users << User.find_by_id("#{obj.user_id}")
|
||||
end
|
||||
|
||||
|
||||
# limit and offset
|
||||
@users_statuses = @us_ordered.offset(@user_pages.offset).limit(@user_pages.per_page)
|
||||
# get users ActiveRecord
|
||||
@users = @users_statuses.includes(:user).map(&:user)
|
||||
|
||||
@user_base_tag = params[:id] ? 'base_users':'users_base'
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@groups = Group.all.sort
|
||||
|
@ -378,7 +333,7 @@ class UsersController < ApplicationController
|
|||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit({:limit => 15})
|
||||
else
|
||||
@limit = 15#per_page_option
|
||||
@limit = 15#per_page_option
|
||||
end
|
||||
|
||||
@status = params[:status] || 1
|
||||
|
@ -389,7 +344,7 @@ class UsersController < ApplicationController
|
|||
scope = scope.like(params[:name]) if params[:name].present?
|
||||
@user_count = scope.count
|
||||
@user_pages = Paginator.new @user_count, @limit, params['page']
|
||||
@user_base_tag = params[:id] ? 'base_users':'base'
|
||||
@user_base_tag = params[:id] ? 'base_users':'users_base'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users = scope.offset(@offset).limit(@limit).all.reverse
|
||||
|
@ -520,7 +475,7 @@ class UsersController < ApplicationController
|
|||
def new
|
||||
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
||||
@auth_sources = AuthSource.all
|
||||
render :layout => "base"
|
||||
render :layout => "users_base"
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -555,7 +510,7 @@ class UsersController < ApplicationController
|
|||
@user.password = @user.password_confirmation = nil
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new' }
|
||||
format.html { render :action => 'new',:layout => "users_base" }
|
||||
format.api { render_validation_errors(@user) }
|
||||
end
|
||||
end
|
||||
|
@ -631,7 +586,7 @@ class UsersController < ApplicationController
|
|||
def destroy
|
||||
@user.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_default(users_path) }
|
||||
format.html { redirect_back_or_default(admin_users_path) }
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
@ -690,9 +645,9 @@ class UsersController < ApplicationController
|
|||
return
|
||||
end
|
||||
if @obj.save
|
||||
## 执行成功的操作。
|
||||
logger.debug "#{__FILE__}:#{__LINE__} ===> #{@obj.to_json}"
|
||||
else
|
||||
#捕获异常
|
||||
logger.error "#{__FILE__}:#{__LINE__} ===> #{@obj.errors.try(:full_messages)}"
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
|
|
@ -16,11 +16,44 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class WelcomeController < ApplicationController
|
||||
include ApplicationHelper
|
||||
include WelcomeHelper
|
||||
caches_action :robots
|
||||
# before_filter :fake, :only => [:index, :course]
|
||||
before_filter :entry_select, :only => [:index]
|
||||
|
||||
def index
|
||||
@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
|
||||
|
||||
|
@ -30,6 +63,7 @@ class WelcomeController < ApplicationController
|
|||
end
|
||||
|
||||
def course
|
||||
@course_page = FirstPage.where("page_type = 'course'").first
|
||||
if params[:school_id]
|
||||
@school_id = params[:school_id]
|
||||
elsif User.current.logged? && User.current.user_extensions.school
|
||||
|
@ -41,13 +75,24 @@ class WelcomeController < ApplicationController
|
|||
|
||||
|
||||
def logolink()
|
||||
@course_page = FirstPage.where("page_type = 'course'").first
|
||||
logo = get_avatar?(@course_page)
|
||||
id = params[:school_id]
|
||||
logo_link = ""
|
||||
if id.nil? and User.current.user_extensions.school.nil?
|
||||
logo_link = '/images/transparent.png'
|
||||
if id.nil? && User.current.user_extensions.school.nil?
|
||||
if logo
|
||||
logo_link = url_to_avatar(@course_page)
|
||||
else
|
||||
logo_link = '/images/transparent.png'
|
||||
end
|
||||
|
||||
else
|
||||
if id == "0"
|
||||
logo_link = '/images/transparent.png'
|
||||
if logo
|
||||
logo_link = url_to_avatar(@course_page)
|
||||
else
|
||||
logo_link = '/images/transparent.png'
|
||||
end
|
||||
else
|
||||
if id.nil?
|
||||
if School.find(User.current.user_extensions.school.id).logo_link.nil?
|
||||
|
@ -66,13 +111,18 @@ class WelcomeController < ApplicationController
|
|||
|
||||
|
||||
def contest
|
||||
|
||||
@contest_page = FirstPage.where("page_type = 'contest'").first
|
||||
end
|
||||
|
||||
def search
|
||||
search_condition = params[:q]
|
||||
search_type = params[:search_type].to_sym unless search_condition.blank?
|
||||
|
||||
if search_type.nil? && params[:contests_search] && params[:name] != ""
|
||||
search_type = :contests
|
||||
search_condition = params[:name]
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html{
|
||||
case search_type
|
||||
|
@ -81,6 +131,8 @@ class WelcomeController < ApplicationController
|
|||
:project_type => Project::ProjectType_project)
|
||||
when :courses
|
||||
redirect_to courses_search_path(:name => search_condition)
|
||||
when :contests
|
||||
redirect_to contests_path(:name => search_condition)
|
||||
when :users
|
||||
redirect_to users_search_path(:name => search_condition)
|
||||
when :users_teacher
|
||||
|
@ -96,7 +148,7 @@ class WelcomeController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
|
||||
def entry_select
|
||||
url = request.original_url
|
||||
if url.include?("course.trustie.net")
|
||||
|
@ -114,28 +166,6 @@ class WelcomeController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
|
||||
def entry_select_course
|
||||
if request.original_url.match(/course\.trustie\.net/)
|
||||
(course() and render :course and return 0)
|
||||
end
|
||||
end
|
||||
|
||||
def entry_select_contest
|
||||
if request.original_url.match(/contest\.trustie\.net/)
|
||||
contest
|
||||
render :contest
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
def entry_select_user
|
||||
if request.original_url.match(/user\.trustie\.net$/)
|
||||
redirect_to(:controller => "users", :action => "index")
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
# def render(*args)
|
||||
# _fake if @fake_filter
|
||||
# super
|
||||
|
|
|
@ -37,12 +37,22 @@ class ZipdownController < ApplicationController
|
|||
#下载某一学生的作业的所有文件
|
||||
def download_user_homework
|
||||
homework = HomeworkAttach.find params[:homework]
|
||||
if homework != nil && (User.current.admin? || User.current.member_of_course?(homework.bid.courses.first))
|
||||
zipfile = zip_homework_by_user homework
|
||||
send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile
|
||||
if User.current.admin? || User.current.member_of_course?(homework.bid.courses.first)
|
||||
if homework != nil
|
||||
if homework.attachments.count > 0
|
||||
zipfile = zip_homework_by_user homework
|
||||
send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if(zipfile)
|
||||
else
|
||||
render_403 :message => :no_file_dowmload
|
||||
end
|
||||
else
|
||||
render_403 :message =>:notice_file_not_found
|
||||
end
|
||||
else
|
||||
render_403 :message => :notice_not_authorized
|
||||
end
|
||||
rescue => e
|
||||
render file: 'public/file_not_found.html'
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -67,7 +77,9 @@ class ZipdownController < ApplicationController
|
|||
# 得到每一个人所有文件打包的zip文件
|
||||
# 并将每一个人的zip打包为一个并返回路径
|
||||
user_zip_paths = homeattaches.map do |homeattach|
|
||||
zip_homework_by_user homeattach
|
||||
if homeattach.attachments.count > 0
|
||||
zip_homework_by_user homeattach
|
||||
end
|
||||
end
|
||||
zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER
|
||||
|
||||
|
@ -81,15 +93,17 @@ class ZipdownController < ApplicationController
|
|||
end
|
||||
|
||||
def zip_homework_by_user(homeattach)
|
||||
homeworks_attach_path = []
|
||||
# 需要将所有homework.attachments遍历加入zip
|
||||
# 并且返回zip路径
|
||||
user_attaches_paths = homeattach.attachments.each do |attach|
|
||||
#length = attach.storage_path.length
|
||||
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
|
||||
end
|
||||
zipping "#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true
|
||||
#user_attaches_paths
|
||||
#if homeattach.attachments.count > 0
|
||||
homeworks_attach_path = []
|
||||
# 需要将所有homework.attachments遍历加入zip
|
||||
# 并且返回zip路径
|
||||
user_attaches_paths = homeattach.attachments.each do |attach|
|
||||
#length = attach.storage_path.length
|
||||
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
|
||||
end
|
||||
zipping("#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true)
|
||||
#user_attaches_paths
|
||||
#end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -256,8 +257,8 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def format_activity_description(text)
|
||||
h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')
|
||||
).gsub(/[\r\n]+/, "<br />").html_safe
|
||||
h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />").html_safe
|
||||
#h(truncate(text.to_s, :length => 120).gsub(/<\/?.*?>/,"")).html_safe
|
||||
end
|
||||
|
||||
def format_version_name(version)
|
||||
|
@ -334,7 +335,7 @@ module ApplicationHelper
|
|||
# set the project environment to please macros.
|
||||
@course = course
|
||||
if (ancestors.empty? )#|| course.is_descendant_of?(ancestors.last))
|
||||
s << "<ul class=courses'>\n"
|
||||
s << "<ul class=courses>\n"
|
||||
else
|
||||
ancestors.pop
|
||||
s << "</li>"
|
||||
|
@ -473,11 +474,25 @@ module ApplicationHelper
|
|||
def principals_check_box_tags_ex(name, principals)
|
||||
s = ''
|
||||
principals.each do |principal|
|
||||
if principal.has_attribute?(:userInfo)
|
||||
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal.userInfo }</label>\n"
|
||||
else
|
||||
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal}</label>\n"
|
||||
end
|
||||
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal.userInfo }</label>\n"
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
||||
#扩展的checkbox生成
|
||||
def principals_check_box_tags_style_ex(name, principals)
|
||||
s = ''
|
||||
principals.each do |principal|
|
||||
s << "<label style=' display:block'>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal.userInfo }</label>\n"
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
||||
#扩展的checkbox生成
|
||||
def principals_radio_box_tags_ex(name, principals)
|
||||
s = ''
|
||||
principals.each do |principal|
|
||||
s << "<label>#{ radio_button_tag name, principal.id, false, :id => nil } #{h principal.userInfo }</label>\n"
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
@ -625,10 +640,15 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def html_title(*args)
|
||||
first_page = FirstPage.where("page_type = 'project'").first
|
||||
if args.empty?
|
||||
title = @html_title || []
|
||||
title << @project.name if @project
|
||||
title << Setting.app_title unless Setting.app_title == title.last
|
||||
if first_page.nil? || first_page.web_title.nil?
|
||||
title << Setting.app_title unless Setting.app_title == title.last
|
||||
else
|
||||
title << first_page.web_title unless first_page.web_title == title.last
|
||||
end
|
||||
title.select {|t| !t.blank? }.join(' - ')
|
||||
else
|
||||
@html_title ||= []
|
||||
|
@ -1396,7 +1416,7 @@ module ApplicationHelper
|
|||
|
||||
# Returns the javascript tags that are included in the html layout head
|
||||
def javascript_heads
|
||||
tags = javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'application')
|
||||
tags = javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'application', 'jquery.colorbox-min')
|
||||
unless User.current.pref.warn_on_leaving_unsaved == '0'
|
||||
tags << "\n".html_safe + javascript_tag("$(window).load(function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });")
|
||||
end
|
||||
|
|
|
@ -109,8 +109,8 @@ module AttachmentsHelper
|
|||
domain = project.nil? ? attachAll : nobelong_attach
|
||||
|
||||
# 搜索到的资源
|
||||
searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
|
||||
searched_attach = private_filter searched_attach
|
||||
searched_attach = domain.where("is_public=1 and filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
|
||||
#searched_attach = private_filter searched_attach
|
||||
searched_attach = paginateHelper(searched_attach, 10)
|
||||
|
||||
s = content_tag('div', attachments_check_box_tags('attachment[attach][]', searched_attach), :id => 'attachments')
|
||||
|
@ -148,8 +148,8 @@ module AttachmentsHelper
|
|||
domain = course.nil? ? attachAll : nobelong_attach
|
||||
|
||||
# 搜索到的资源
|
||||
searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
|
||||
searched_attach = private_filter searched_attach
|
||||
searched_attach = domain.where("is_public=1 and filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
|
||||
#searched_attach = private_filter searched_attach
|
||||
searched_attach = paginateHelper(searched_attach, 10)
|
||||
|
||||
#testattach = Attachment.public_attachments
|
||||
|
|
|
@ -38,7 +38,7 @@ module AvatarHelper
|
|||
avatar_image(source)
|
||||
else
|
||||
File.join(relative_path,avatar_directory(source.class),'0')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_avatar?(source)
|
||||
|
|
|
@ -173,6 +173,18 @@ module ContestsHelper
|
|||
end
|
||||
tmp
|
||||
end
|
||||
|
||||
|
||||
#作品分类下拉框
|
||||
def work_type_opttion
|
||||
type = []
|
||||
#work_types = WorksCategory.all
|
||||
WorksCategory.all.each do |work_type|
|
||||
option = []
|
||||
option << work_type.category
|
||||
option << work_type.category
|
||||
type << option
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
end
|
|
@ -7,29 +7,30 @@ module CoursesHelper
|
|||
3. define search by roles
|
||||
4. define search member function
|
||||
=end
|
||||
TeacherRoles = [3, 4, 7, 9]
|
||||
StudentRoles = [5, 10]
|
||||
AllPeople = StudentRoles+TeacherRoles
|
||||
#TeacherRoles = [3, 4, 7, 9]
|
||||
#StudentRoles = [5, 10]
|
||||
#AllPeople = StudentRoles+TeacherRoles
|
||||
## return people count
|
||||
|
||||
# 返回x项目成员数量,即roles表中定义的所有成员
|
||||
def projectCount project
|
||||
searchCountByRoles project, AllPeople
|
||||
#searchCountByRoles project, AllPeople
|
||||
project.members.count
|
||||
end
|
||||
|
||||
# 返回教师数量,即roles表中定义的Manager
|
||||
def teacherCount project
|
||||
searchCountByRoles project, TeacherRoles
|
||||
searchTeacherAndAssistant(project).count
|
||||
# or
|
||||
# searchTeacherAndAssistant(project).count
|
||||
end
|
||||
|
||||
# 返回学生数量,即roles表中定义的Reporter
|
||||
def studentCount project
|
||||
searchCountByRoles project,StudentRoles
|
||||
#def studentCount project
|
||||
# searchStudent(project).count
|
||||
# or
|
||||
# searchStudent(project).count
|
||||
end
|
||||
# end
|
||||
|
||||
# 判断用户是否是课程的管理员
|
||||
# add by nwb
|
||||
|
@ -103,10 +104,25 @@ module CoursesHelper
|
|||
garble count
|
||||
end
|
||||
|
||||
alias studentCountOrigin studentCount
|
||||
# 注意:此方法有问题,速度慢且结果不准
|
||||
# alias studentCountOrigin studentCount
|
||||
#def studentCount course
|
||||
# count = studentCountOrigin course
|
||||
#garble count
|
||||
# end
|
||||
|
||||
# 学生人数计算
|
||||
# add by nwb
|
||||
def studentCount course
|
||||
count = studentCountOrigin course
|
||||
garble count
|
||||
count = course.student.count
|
||||
if count <= 5
|
||||
result = count.to_s
|
||||
elsif count < 10 && count > 5
|
||||
result = "5+"
|
||||
else
|
||||
result = (count-count % 10).to_s + "+"
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def eventToLanguageCourse event_type, course
|
||||
|
@ -133,29 +149,39 @@ module CoursesHelper
|
|||
# =====================================================================================
|
||||
# return people list
|
||||
def searchTeacherAndAssistant project
|
||||
searchPeopleByRoles(project, TeacherRoles)
|
||||
end
|
||||
|
||||
def searchStudent project
|
||||
searchPeopleByRoles(project, StudentRoles)
|
||||
end
|
||||
# =====================================================================================
|
||||
|
||||
def searchCountByRoles project, roles_id
|
||||
members = searchPeopleByRoles project, roles_id
|
||||
members.count
|
||||
end
|
||||
|
||||
def searchPeopleByRoles project, roles_id
|
||||
#searchPeopleByRoles(project, TeacherRoles)
|
||||
members = []
|
||||
begin
|
||||
members = project.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => roles_id})
|
||||
rescue Exception => e
|
||||
logger.error "[CoursesHelper] ===> #{e}"
|
||||
project.members.each do |m|
|
||||
members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
|
||||
end
|
||||
members
|
||||
end
|
||||
|
||||
def searchStudent project
|
||||
#searchPeopleByRoles(project, StudentRoles)
|
||||
members = []
|
||||
project.members.each do |m|
|
||||
members << m if m && m.user && m.user.allowed_to?(:as_student,project)
|
||||
end
|
||||
members
|
||||
end
|
||||
# =====================================================================================
|
||||
|
||||
#def searchCountByRoles project, roles_id
|
||||
# members = searchPeopleByRoles project, roles_id
|
||||
# members.count
|
||||
#end
|
||||
|
||||
#def searchPeopleByRoles project, roles_id
|
||||
# members = []
|
||||
# begin
|
||||
# members = project.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => roles_id})
|
||||
# rescue Exception => e
|
||||
# logger.error "[CoursesHelper] ===> #{e}"
|
||||
# end
|
||||
# members
|
||||
#end
|
||||
|
||||
def sort_courses(state)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
|
@ -186,15 +212,15 @@ module CoursesHelper
|
|||
end
|
||||
|
||||
#useless
|
||||
def searchMembersByRole project, role_id
|
||||
members = []
|
||||
begin
|
||||
members = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => role_id })
|
||||
rescue Exception => e
|
||||
logger.error "[CoursesHelper] ===> #{e}"
|
||||
end
|
||||
members
|
||||
end
|
||||
#def searchMembersByRole project, role_id
|
||||
# members = []
|
||||
# begin
|
||||
# members = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => role_id })
|
||||
# rescue Exception => e
|
||||
# logger.error "[CoursesHelper] ===> #{e}"
|
||||
# end
|
||||
# members
|
||||
#end
|
||||
|
||||
def sort_course(state, school_id)
|
||||
content = ''.html_safe
|
||||
|
@ -270,9 +296,10 @@ module CoursesHelper
|
|||
def find_by_extra_from_project extra
|
||||
Course.find_by_extra(try(extra))
|
||||
end
|
||||
#判断制定用户是不是当前课程的老师
|
||||
#判断指定用户是不是当前课程的老师
|
||||
def is_course_teacher (user,course)
|
||||
course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{user.id}", {:role_id => TeacherRoles}).count != 0
|
||||
#course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{user.id}", {:role_id => TeacherRoles}).count != 0
|
||||
user.allowed_to?(:as_teacher,course)
|
||||
#修改为根据用户是否有发布任务的权限来判断用户是否是课程的老师
|
||||
#is_teacher = false
|
||||
#@membership = user.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
|
@ -287,7 +314,8 @@ module CoursesHelper
|
|||
end
|
||||
#当前用户是不是指定课程的学生
|
||||
def is_cur_course_student course
|
||||
course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{User.current.id}", {:role_id => StudentRoles}).count != 0
|
||||
#course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{User.current.id}", {:role_id => StudentRoles}).count != 0
|
||||
!(User.current.allowed_to?(:as_teacher,course))
|
||||
#修改:能新建占位且不能新建任务的角色判定为学生
|
||||
#is_student = false
|
||||
#@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
|
@ -329,20 +357,44 @@ module CoursesHelper
|
|||
|
||||
#获取作业的互评得分
|
||||
def student_score_for_homework homework
|
||||
member = searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
|
||||
student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars")
|
||||
#member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
|
||||
#if member.nil?
|
||||
# return "0.00"
|
||||
#end
|
||||
#student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars")
|
||||
members = searchStudent(homework.bid.courses.first)
|
||||
user_ids = []
|
||||
members.each do |user|
|
||||
user_ids << user.user_id
|
||||
end
|
||||
student_stars = homework.rates(:quality).where("rater_id in (:user_ids)",{:user_ids => user_ids}).select("stars")
|
||||
student_stars_count = 0
|
||||
student_stars.each do |star|
|
||||
student_stars_count = student_stars_count + star.stars
|
||||
end
|
||||
return format("%.2f",student_stars_count / (student_stars.count == 0 ? 1 : student_stars.count))
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
#获取作业的教师评分
|
||||
#多个教师只获取一份教师评分
|
||||
def teacher_score_for_homework homework
|
||||
member = searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
|
||||
teacher_stars = homework.rates(:quality).where("rater_id = #{member.user_id}").select("stars").first
|
||||
return format("%.2f",teacher_stars == nil ? 0 : teacher_stars.stars)
|
||||
members = searchTeacherAndAssistant(homework.bid.courses.first)#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
|
||||
#if member.nil?
|
||||
# return "0.00"
|
||||
#end
|
||||
teacher_ids = []
|
||||
members.each do |user|
|
||||
teacher_ids << user.user_id
|
||||
end
|
||||
teacher_stars = homework.rates(:quality).where("rater_id in (:teacher_ids)",{:teacher_ids => teacher_ids}).select("stars")
|
||||
teacher_stars_count = 0
|
||||
teacher_stars.each do |star|
|
||||
teacher_stars_count = teacher_stars_count + star.stars
|
||||
end
|
||||
return format("%.2f",teacher_stars_count)
|
||||
end
|
||||
|
||||
#获取指定项目的得分
|
||||
|
|
|
@ -0,0 +1,460 @@
|
|||
# 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.gitlab_server
|
||||
REPO_IP_ADDRESS = "http://192.168.1.200"
|
||||
GITLAB_API = "/api/v3"
|
||||
# gitlab的默认登录用户(需管理员)
|
||||
LOGIN_USER = Setting.gitlab_login_user
|
||||
# gitlab的默认登录密码
|
||||
LOGIN_PASSWORD = Setting.gitlab_login_password
|
||||
# 新建用户的默认密码
|
||||
DEFAULT_PASSWOR="123456"
|
||||
|
||||
# 用户在项目中的权限级别
|
||||
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
|
||||
|
||||
def login_check
|
||||
if GitlabHelper.gitlab_token.nil?
|
||||
login_gitlab(LOGIN_USER,LOGIN_PASSWORD)
|
||||
end
|
||||
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
|
||||
logger.error "gitlab: error: #{err.message}"
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# 登录并初始化gitlab用户
|
||||
# 登录成功且本地未保存数据时保存
|
||||
# email:登录gitlab用户邮件,loginname:登录gitlab用户账号, password :登录gitlab用户密码
|
||||
# user_id:用户在trustie中的编号
|
||||
# add by nwb
|
||||
def login_init_gitlab(email,password,loginname,user_id)
|
||||
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)
|
||||
if temp['username'] == loginname
|
||||
# 保存数据
|
||||
gituser = GitlabUser.new
|
||||
gituser.user_id = user_id
|
||||
gituser.gitlab_user_id = temp['id']
|
||||
gituser.email = email
|
||||
gituser.password = password
|
||||
gituser.login =loginname
|
||||
gituser.save
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
rescue =>err
|
||||
logger.error "gitlab: error: #{err.message}"
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
# 创建项目
|
||||
# add by nwb
|
||||
def create_project(project_name,project_id)
|
||||
login_check
|
||||
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)
|
||||
#新创建项目的版本库地址
|
||||
repository_url = String.new(temp['http_url_to_repo'])
|
||||
repository_url['http://localhost'] = REPO_IP_ADDRESS
|
||||
# 新创建项目的web地址
|
||||
web_url = String.new(temp['web_url'])
|
||||
web_url['http://localhost'] = REPO_IP_ADDRESS
|
||||
# 新创建项目的本地文件路径
|
||||
localfile = String.new(temp['web_url'])
|
||||
localfile[REPO_IP_ADDRESS] = ROOT_PATH
|
||||
|
||||
# 保存数据
|
||||
gitproject =GitlabProject.new
|
||||
gitproject.project_id = project_id
|
||||
gitproject.gitlab_project_id = temp['id']
|
||||
gitproject.repository_url = repository_url
|
||||
gitproject.web_url = web_url
|
||||
gitproject.localfile_url = localfile
|
||||
gitproject.save
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
rescue =>err
|
||||
logger.error "gitlab: error: #{err.message}"
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# 为指定用户创建版本库
|
||||
# project_name:版本库名称 user_id:Gitlab版本库中的用户编号
|
||||
# project_id: 项目在trustie中的编号
|
||||
# add by nwb
|
||||
def create_project_for_user(project_name,project_id,user_id)
|
||||
login_check
|
||||
url = REPO_IP_ADDRESS + GITLAB_API + "/projects/user/" + user_id.to_s
|
||||
uri = URI.parse(url)
|
||||
data = {user_id:user_id, name:project_name,private_token:GitlabHelper.gitlab_token}
|
||||
tempResult = Hash.new
|
||||
begin
|
||||
res = Net::HTTP.post_form(uri, data)
|
||||
if res.code == '201'
|
||||
temp = ActiveSupport::JSON.decode(res.body)
|
||||
#新创建项目的版本库地址
|
||||
repository_url = String.new(temp['http_url_to_repo'])
|
||||
repository_url['http://localhost'] = REPO_IP_ADDRESS
|
||||
# 新创建项目的web地址
|
||||
web_url = String.new(temp['web_url'])
|
||||
web_url['http://localhost'] = REPO_IP_ADDRESS
|
||||
# 新创建项目的本地文件路径
|
||||
localfile = String.new(temp['web_url'])
|
||||
localfile['http://localhost'] = ROOT_PATH
|
||||
|
||||
# 保存数据
|
||||
gitproject = GitlabProject.new
|
||||
gitproject.project_id = project_id
|
||||
gitproject.gitlab_project_id = temp['id']
|
||||
gitproject.repository_url = repository_url
|
||||
gitproject.web_url = web_url
|
||||
gitproject.localfile_url = localfile
|
||||
gitproject.save
|
||||
tempResult[:result]= true
|
||||
tempResult[:gitprojectid]=gitproject.gitlab_project_id
|
||||
else
|
||||
tempResult[:result]= false
|
||||
end
|
||||
rescue =>err
|
||||
logger.error "gitlab: error: #{err.message}"
|
||||
tempResult[:result]= false
|
||||
end
|
||||
tempResult
|
||||
end
|
||||
|
||||
# 创建用户
|
||||
# loginname:登录名称(版本库路径包含) name:用户姓名
|
||||
# add by nwb
|
||||
def create_user (loginname,name,password,email,userid)
|
||||
login_check
|
||||
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用户编号(需保存)
|
||||
git_user_id = temp['id']
|
||||
|
||||
# 保存数据
|
||||
gituser = GitlabUser.new
|
||||
gituser.user_id = userid
|
||||
gituser.gitlab_user_id = git_user_id
|
||||
gituser.email = email
|
||||
gituser.password = password
|
||||
gituser.login =loginname
|
||||
gituser.save
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
rescue =>err
|
||||
logger.error "gitlab: error: #{err.message}"
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# 删除用户
|
||||
# user_id:用户在gitlab中的id
|
||||
# add by nwb
|
||||
def delete_user(user_id)
|
||||
login_check
|
||||
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)
|
||||
# 删除成功,更新数据
|
||||
gituser = GitlabUser.find_by_gitlab_user_id(user_id_)
|
||||
gituser.destroy
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
rescue =>err
|
||||
logger.error "gitlab: error: #{err.message}"
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# 获取指定gitlab项目用户列表
|
||||
# project_id:gitlab项目编号
|
||||
# add by nwb
|
||||
def get_project_users(project_id)
|
||||
login_check
|
||||
url = REPO_IP_ADDRESS + GITLAB_API + "/projects/" + project_id.to_s + "/members"
|
||||
uri = URI.parse(url)
|
||||
data = {id:project_id, private_token:GitlabHelper.gitlab_token}
|
||||
uri.query = URI.encode_www_form(params)
|
||||
http = Net::HTTP.new uri.host, uri.port
|
||||
#https协议额外解析
|
||||
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.form_data = data
|
||||
res = http.start { |http| http.request request }
|
||||
if res.code == '200'
|
||||
temp = ActiveSupport::JSON.decode(res.body)
|
||||
# 取gitlabuser集合
|
||||
gitlabusers = []
|
||||
temp.each do |gituser|
|
||||
gituser_id = gituser['id']
|
||||
gitlabuser = GitlabUser.find_by_gitlab_user_id(gituser_id)
|
||||
if gitlabuser
|
||||
gitlabuser.project_role_set(project_id, gituser['access_level'])
|
||||
gitlabusers << gitlabuser
|
||||
end
|
||||
end
|
||||
return gitlabusers
|
||||
else
|
||||
return nil
|
||||
end
|
||||
rescue =>err
|
||||
logger.error "gitlab: error: #{err.message}"
|
||||
return nil
|
||||
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)
|
||||
login_check
|
||||
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
|
||||
logger.error "gitlab: error: #{err.message}"
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# 将trustie用户添加进指定trustie项目的所有gitlab项目
|
||||
# project_id:trustie项目id user_id:用户在trustie中的id
|
||||
def add_trustie_user(project_id,user_id)
|
||||
respos = Repository.find_all_by_project_id(project_id)
|
||||
respos.each do |respo|
|
||||
# 循环删除所有版本库
|
||||
add_trustie_user_to_repos(user_id,respo.url)
|
||||
end
|
||||
end
|
||||
|
||||
# 将trustie用户添加进gitlab版本库
|
||||
# user_id:用户在trustie中的id local_file_url:gitlab版本库的本地路径
|
||||
def add_trustie_user_to_repos(user_id,local_file_url)
|
||||
# 找对应的Gitlab项目
|
||||
gitlab_project = GitlabProject.find_by_localfile_url(local_file_url)
|
||||
if gitlab_project.nil?
|
||||
return false
|
||||
end
|
||||
# 找对应的Gitlab用户,不存在则创建
|
||||
user = User.find(user_id)
|
||||
gitlab_user = GitlabUser.find_by_user_id(user_id)
|
||||
if gitlab_user.nil?
|
||||
if !create_user(user.login,user.show_name,DEFAULT_PASSWOR,user.mail,user.id)
|
||||
# 创建gitlab用户失败
|
||||
# 验证gitlab是否可由指定的账号、密码登录
|
||||
if login_init_gitlab(user.mail,DEFAULT_PASSWOR,user.login,user.id)
|
||||
gitlab_user = GitlabUser.find_by_user_id(user.id)
|
||||
else
|
||||
flash[:error] = l(:error_create_gitlab_user)
|
||||
return false
|
||||
end
|
||||
end
|
||||
gitlab_user = GitlabUser.find_by_user_id(user.id)
|
||||
end
|
||||
|
||||
access_level = DEVELOPER
|
||||
add_user_to_project(gitlab_project.gitlab_project_id,gitlab_user.gitlab_user_id,access_level)
|
||||
end
|
||||
|
||||
# 将trustie用户从指定trustie项目的所有gitlab项目中移除
|
||||
# project_id:trustie项目id user_id:用户在trustie中的id
|
||||
def delete_trustie_user(project_id,user_id)
|
||||
respos = Repository.find_all_by_project_id(project_id)
|
||||
respos.each do |respo|
|
||||
# 循环删除所有版本库
|
||||
delete_trustie_user_from_repos(user_id,respo.url)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# 将trustie用户从gitlab版本库移除
|
||||
# user_id:用户在trustie中的id local_file_url:gitlab版本库的本地路径
|
||||
def delete_trustie_user_from_repos(user_id,local_file_url)
|
||||
# 找对应的Gitlab项目
|
||||
gitlab_project = GitlabProject.find_by_localfile_url(local_file_url)
|
||||
if gitlab_project.nil?
|
||||
return false
|
||||
end
|
||||
# 找对应的Gitlab用户,不存在则创建
|
||||
user = User.find(user_id)
|
||||
gitlab_user = GitlabUser.find_by_user_id(user_id)
|
||||
if gitlab_user.nil?
|
||||
return false
|
||||
end
|
||||
delete_user_from_project(gitlab_project.gitlab_project_id,gitlab_user.gitlab_user_id)
|
||||
gitlab_user.destroy
|
||||
end
|
||||
|
||||
# 从项目中删除用户
|
||||
# project_id:项目在gitlab中的ids user_id:用户在gitlab中的id
|
||||
# add by nwb
|
||||
def delete_user_from_project(project_id,user_id)
|
||||
login_check
|
||||
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
|
||||
logger.error "gitlab: error: #{err.message}"
|
||||
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
|
||||
logger.error "gitlab: error: #{err.message}"
|
||||
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
|
||||
#https协议额外解析
|
||||
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
|
||||
logger.error "gitlab: error: #{err.message}"
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -50,6 +50,33 @@ module MembersHelper
|
|||
s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
def render_principals_for_gitlab(project,gitlabusers,gitlab_project)
|
||||
idlist = "("
|
||||
count = gitlabusers.count
|
||||
for i in 0...count
|
||||
gitlabuser = gitlabusers[i]
|
||||
idlist+="'" + gitlabuser.user_id.to_s + "'"
|
||||
if i != count-1
|
||||
idlist+=","
|
||||
end
|
||||
end
|
||||
idlist += ")"
|
||||
scope = Principal.active.where('users.id not in' + idlist).sorted.member_of(project).like(params[:q])
|
||||
principal_count = scope.count
|
||||
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page'] #by young
|
||||
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
|
||||
|
||||
s = content_tag('div', principals_check_box_tags_style_ex('membership[user_ids][]', principals), :id => 'principals')
|
||||
|
||||
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
|
||||
link_to text, gitlabautocomplete_project_repositories_path(project, parameters.merge(:q => params[:q],:gitlab_prject_id=>gitlab_project.project_id, :format => 'js')), :remote => true
|
||||
}
|
||||
|
||||
s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
|
||||
end
|
||||
|
||||
|
||||
|
||||
# 当前申请加入的成员名单
|
||||
def render_principals_for_applied_members(project)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
module RepositoriesHelper
|
||||
ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/"
|
||||
PROJECT_PATH_CUT = 40
|
||||
REPO_IP_ADDRESS = "repository.trustie.net"
|
||||
REPO_IP_ADDRESS = Setting.repository_domain
|
||||
|
||||
def format_revision(revision)
|
||||
if revision.respond_to? :format_identifier
|
||||
|
@ -46,6 +46,33 @@ module RepositoriesHelper
|
|||
end
|
||||
end
|
||||
|
||||
# 项目成员列表
|
||||
def render_principals_for_project(project,gitlabusers,gitlab_project)
|
||||
idlist = "("
|
||||
count = gitlabusers.count
|
||||
for i in 0...count
|
||||
gitlabuser = gitlabusers[i]
|
||||
idlist+="'" + gitlabuser.user_id.to_s + "'"
|
||||
if i != count-1
|
||||
idlist+=","
|
||||
end
|
||||
end
|
||||
idlist += ")"
|
||||
scope = Principal.active.where('users.id not in' + idlist).sorted.member_of(project).like(params[:q])
|
||||
principal_count = scope.count
|
||||
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page'] #by young
|
||||
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
|
||||
|
||||
s = content_tag('div', principals_check_box_tags_style_ex('membership[user_ids][]', principals), :id => 'principals')
|
||||
|
||||
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
|
||||
link_to text, gitlabautocomplete_project_repositories_path(project, parameters.merge(:q => params[:q],:gitlab_prject_id=>gitlab_project.project_id, :format => 'js')), :remote => true
|
||||
}
|
||||
|
||||
s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
|
||||
end
|
||||
|
||||
|
||||
def render_changeset_changes
|
||||
changes = @changeset.filechanges.limit(1000).reorder('path').all.collect do |change|
|
||||
case change.action
|
||||
|
|
|
@ -4,13 +4,8 @@ def options_from_select_project(user)
|
|||
@option = []
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
#membership.member_roles.each{|role|
|
||||
# if(role.role_id == 3)
|
||||
# @option << membership.project
|
||||
# end
|
||||
#}
|
||||
#拥有编辑项目权限的可操作该项目
|
||||
if user.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
#可被用户引用的项目
|
||||
if user.allowed_to?(:quote_project, membership.project)
|
||||
@option << membership.project
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,6 +13,19 @@ module SoftapplicationsHelper
|
|||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
end
|
||||
|
||||
#作品分类下拉框
|
||||
def work_type_opttion
|
||||
type = []
|
||||
#work_types = WorksCategory.all
|
||||
WorksCategory.all.each do |work_type|
|
||||
option = []
|
||||
option << work_type.category
|
||||
option << work_type.category
|
||||
type << option
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
# def select_option_helper option
|
||||
# tmp = Hash.new
|
||||
|
|
|
@ -16,6 +16,8 @@ module StoresHelper
|
|||
news_path(container)
|
||||
when 'Project'
|
||||
project_files_path(container)
|
||||
when 'Course'
|
||||
course_files_path(container)
|
||||
when 'Version'
|
||||
# version_path(container)
|
||||
project_files_path(container.project)
|
||||
|
@ -37,15 +39,23 @@ module StoresHelper
|
|||
|
||||
WORD_LIMIT = 100
|
||||
def come_from_local attachment
|
||||
|
||||
container = attachment.container
|
||||
case container.class.to_s
|
||||
when 'Message'
|
||||
# '项目 > zzz > 论坛 > 帖子xxx'
|
||||
# topic_str = container.project.project_type == 0 ? l(:label_board) : l(:label_new_course)
|
||||
topic_list = link_to l(:label_board), project_boards_path(container.project)
|
||||
topic_item = link_to container.subject.truncate(WORD_LIMIT, omission: '...'), board_message_path(container.board, container), title: container.subject
|
||||
project_link(container.project).push(topic_list, topic_item)
|
||||
|
||||
course = container.course
|
||||
project = container.project
|
||||
if course.nil? # container is belongs to Project
|
||||
topic_list = link_to l(:label_board), project_boards_path(container.project)
|
||||
topic_item = link_to container.subject.truncate(WORD_LIMIT, omission: '...'), board_message_path(container.board, container), title: container.subject
|
||||
project_link(container.project).push(topic_list, topic_item)
|
||||
else # container is belongs to Course
|
||||
topic_list = link_to l(:label_course_news), course_boards_path(course)
|
||||
topic_item = link_to container.try(:subject).to_s.truncate(WORD_LIMIT, omission: '...'), board_message_path(container.board, container), title: container.subject
|
||||
project_link(course).push(topic_list, topic_item)
|
||||
end
|
||||
when 'Issue'
|
||||
# '项目 > zzz > 缺陷 > 问题xxx'
|
||||
issue_list = link_to l(:label_project_issues), project_issues_path(container.project)
|
||||
|
@ -58,15 +68,26 @@ module StoresHelper
|
|||
project_link(container.project).push(doc_list, doc_item)
|
||||
when 'News'
|
||||
# '课程 > zzz > 新闻 > 新闻xxx'
|
||||
news_str = container.project.project_type == 0 ? l(:label_news) : l(:label_course_news)
|
||||
news_list = link_to news_str, project_news_index_path(container.project)
|
||||
news_item = link_to container.title.truncate(WORD_LIMIT, omission: '...'), news_path(container), title: container.title
|
||||
project_link(container.project).push(news_list, news_item)
|
||||
course = container.course
|
||||
project = container.project
|
||||
if course.nil? # container is belongs to Project
|
||||
news_list = link_to l(:label_news), project_news_index_path(container.project)
|
||||
news_item = link_to container.title.truncate(WORD_LIMIT, omission: '...'), news_path(container), title: container.title
|
||||
project_link(container.project).push(news_list, news_item)
|
||||
else # container is belongs to Course
|
||||
news_list = link_to l(:label_course_news), course_news_index_path(course)
|
||||
news_item = link_to container.title.truncate(WORD_LIMIT, omission: '...'), news_path(container), title: container.title
|
||||
project_link(course).push(news_list, news_item)
|
||||
end
|
||||
|
||||
when 'Project'
|
||||
# '项目 > zzz '
|
||||
file_str = container.project.project_type == 0 ? l(:project_module_files) : l(:label_course_file)
|
||||
files_list = link_to file_str, project_files_path(container.project)
|
||||
project_link(container).push(files_list)
|
||||
when 'Course'
|
||||
files_list = link_to l(:label_course_file), course_files_path(container)
|
||||
project_link(container).push(files_list)
|
||||
when 'Version'
|
||||
# '项目 > zzz > 里程碑 > xxx'
|
||||
ver_list = link_to l(:label_roadmap), project_roadmap_path(container.project)
|
||||
|
@ -91,7 +112,8 @@ module StoresHelper
|
|||
# '竞赛 > xxx '
|
||||
bid_link(container)
|
||||
else
|
||||
Rails.logger.error "ERROR: attachment type unkown"
|
||||
Rails.logger.error "ERROR: attachment type unkown. file:#{__FILE__}, line:#{__LINE__}"
|
||||
Rails.logger.error "#{container.class.to_s}"
|
||||
[link_to('unkown', '')]
|
||||
end
|
||||
rescue ActionController::RoutingError => e
|
||||
|
@ -99,20 +121,6 @@ module StoresHelper
|
|||
[link_to('unkown', '')]
|
||||
end
|
||||
|
||||
def project_link project
|
||||
if project.nil?
|
||||
Rails.logger.error "ERROR: attachment type unkown #project_link project.nil?"
|
||||
return [link_to('unkown', '')]
|
||||
end
|
||||
project_list = nil
|
||||
if project.project_type == 0
|
||||
project_list = link_to l(:label_project_plural), projects_path
|
||||
else
|
||||
project_list = link_to l(:label_new_course), course_path
|
||||
end
|
||||
project_item = link_to project.to_s, project_path(project)
|
||||
[project_list, project_item]
|
||||
end
|
||||
|
||||
def bid_link bid
|
||||
bid_list = nil
|
||||
|
@ -129,7 +137,7 @@ module StoresHelper
|
|||
Rails.logger.error "ERROR: attachment type unkown #bid_link/when 3"
|
||||
return [link_to('unkown', '#')]
|
||||
end
|
||||
bid_list = link_to l(:label_homework), project_homework_path(bid.courses.first)
|
||||
bid_list = link_to l(:label_homework), homework_course_path(bid.courses.first)
|
||||
bid_item = link_to bid.name, respond_path(bid)
|
||||
return project_link(bid.courses.first).push(bid_list, bid_item)
|
||||
else
|
||||
|
@ -137,4 +145,28 @@ module StoresHelper
|
|||
end
|
||||
[bid_list, bid_item]
|
||||
end
|
||||
|
||||
|
||||
def project_link project
|
||||
if project.nil?
|
||||
Rails.logger.error "ERROR: attachment type unkown #project_link project.nil? file: #{__FILE__}, line: #{__LINE__}"
|
||||
return [link_to('unkown', '')]
|
||||
end
|
||||
project_list = nil
|
||||
klass = project.class.to_s
|
||||
case klass
|
||||
when "Project"
|
||||
project_list = link_to l(:label_project_plural), projects_path
|
||||
project_item = link_to project.to_s, project_path(project)
|
||||
[project_list, project_item]
|
||||
when "Course"
|
||||
course_list = link_to l(:label_new_course), courses_path
|
||||
course_item = link_to project.name, course_path(project)
|
||||
[course_list, course_item]
|
||||
else
|
||||
Rails.logger.error "[StoresHelper]: #{klass} ======================================="
|
||||
[]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -228,16 +228,10 @@ module UserScoreHelper
|
|||
isManager = 0
|
||||
members = Member.where('user_id = ?', user.id)
|
||||
members.each do |m|
|
||||
#roles = m.member_roles
|
||||
#roles.each do |r|
|
||||
# if r.role_id == 3
|
||||
# isManager = 1
|
||||
# end
|
||||
#end
|
||||
@membership = m.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
@membership.each do |membership|
|
||||
#拥有编辑项目权限的可操作该项目
|
||||
if m.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
if m.allowed_to?(:is_manager, membership.project, :global => false)
|
||||
isManager = 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -258,4 +258,24 @@ module UsersHelper
|
|||
end
|
||||
return result
|
||||
end
|
||||
|
||||
#获取用户参与的公开的课程列表
|
||||
def user_public_course_list user
|
||||
membership = user.coursememberships.all#@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||
memberships = []
|
||||
membership.collect { |e|
|
||||
memberships.push(e)
|
||||
}
|
||||
## 判断课程是否过期 [需封装]
|
||||
memberships_doing = []
|
||||
memberships_done = []
|
||||
memberships.map { |e|
|
||||
if course_endTime_timeout?(e.course)
|
||||
memberships_done.push e
|
||||
else
|
||||
memberships_doing.push e
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -208,7 +208,7 @@ module WelcomeHelper
|
|||
#c1 = find_new_project(sum).to_a.dup
|
||||
#c2 = find_all_hot_project(sum).to_a.dup
|
||||
#(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
|
||||
|
||||
def find_new_course limit=15
|
||||
|
@ -433,7 +433,7 @@ module WelcomeHelper
|
|||
# FROM projects AS p LEFT OUTER JOIN (
|
||||
# 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 ")
|
||||
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
|
||||
|
||||
def sort_bid_by_hot_rails reward_type, limit = 10
|
||||
|
|
|
@ -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}.*",
|
||||
|
@ -196,6 +199,21 @@ class Attachment < ActiveRecord::Base
|
|||
suffix
|
||||
end
|
||||
|
||||
# 文件密级的字符描述
|
||||
def file_dense_str
|
||||
if self.is_public == 1
|
||||
dense = l(:field_is_public)
|
||||
else
|
||||
dense = l(:field_is_private)
|
||||
end
|
||||
dense
|
||||
end
|
||||
|
||||
# 文件可设置的密级列表
|
||||
def file_dense_list
|
||||
denselist = [l(:field_is_public),l(:field_is_private)]
|
||||
end
|
||||
|
||||
def suffixArr
|
||||
@@SuffixArr
|
||||
end
|
||||
|
@ -209,7 +227,8 @@ class Attachment < ActiveRecord::Base
|
|||
def file=(incoming_file)
|
||||
unless incoming_file.nil?
|
||||
@temp_file = incoming_file
|
||||
if @temp_file.size > 0
|
||||
# 允许上传文件大小为0的文件
|
||||
#if @temp_file.size > 0
|
||||
if @temp_file.respond_to?(:original_filename)
|
||||
self.filename = @temp_file.original_filename
|
||||
self.filename.force_encoding("UTF-8") if filename.respond_to?(:force_encoding)
|
||||
|
@ -221,7 +240,7 @@ class Attachment < ActiveRecord::Base
|
|||
self.content_type = Redmine::MimeType.of(filename)
|
||||
end
|
||||
self.filesize = @temp_file.size
|
||||
end
|
||||
#end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -237,7 +256,8 @@ class Attachment < ActiveRecord::Base
|
|||
# Copies the temporary file to its final location
|
||||
# and computes its MD5 hash
|
||||
def files_to_final_location
|
||||
if @temp_file && (@temp_file.size > 0)
|
||||
# # 允许上传文件大小为0的文件
|
||||
if @temp_file# && (@temp_file.size > 0)
|
||||
self.disk_directory = target_directory
|
||||
self.disk_filename = Attachment.disk_filename(filename, disk_directory)
|
||||
logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)")
|
||||
|
|
|
@ -21,7 +21,7 @@ class Course < ActiveRecord::Base
|
|||
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :homework_for_courses, :dependent => :destroy
|
||||
has_many :student, :through => :students_for_courses, :source => :user
|
||||
has_many :student, :class_name => 'StudentsForCourse', :source => :user
|
||||
has_many :course_infos, :class_name => 'CourseInfos',:dependent => :destroy
|
||||
has_many :enabled_modules, :dependent => :delete_all
|
||||
has_many :boards, :dependent => :destroy, :order => "position ASC"
|
||||
|
@ -34,12 +34,12 @@ class Course < ActiveRecord::Base
|
|||
acts_as_attachable :view_permission => :view_files,
|
||||
:delete_permission => :manage_files
|
||||
|
||||
validates_presence_of :password, :term,:name
|
||||
validates_format_of :class_period, :with =>/^[1-9]\d*$/
|
||||
validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/
|
||||
validates_presence_of :password, :term,:name ,:class_period
|
||||
validates_format_of :class_period, :with =>/^\d*$/
|
||||
#validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/
|
||||
|
||||
before_save :self_validate
|
||||
after_save :create_board_sync
|
||||
after_create :create_board_sync
|
||||
before_destroy :delete_all_members
|
||||
|
||||
safe_attributes 'extra',
|
||||
|
@ -90,9 +90,38 @@ class Course < ActiveRecord::Base
|
|||
false
|
||||
end
|
||||
|
||||
# Returns the mail adresses of users that should be always notified on project events
|
||||
def recipients
|
||||
notified_users.collect {|user| user.mail}
|
||||
end
|
||||
|
||||
# Returns the users that should be notified on project events
|
||||
def notified_users
|
||||
# TODO: User part should be extracted to User#notify_about?
|
||||
members.select {|m| m.principal.present? && (m.mail_notification? || m.principal.mail_notification == 'all')}.collect {|m| m.principal}
|
||||
end
|
||||
|
||||
|
||||
# 课程的短描述信息
|
||||
def short_description(length = 255)
|
||||
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
end
|
||||
|
||||
# 课程的短名称信息
|
||||
def short_name(length = 8)
|
||||
name.gsub(/<\/?.*?>/,"").html_safe if name
|
||||
end
|
||||
|
||||
def strip_html(html)
|
||||
return html if html.empty? || !html.include?('<')
|
||||
output = ""
|
||||
tokenizer = HTML::Tokenizer.new(html)
|
||||
while token = tokenizer.next
|
||||
node = HTML::Node.parse(nil, 0, 0, token, false)
|
||||
output += token unless (node.kind_of? HTML::Tag) or (token =~ /^<!/)
|
||||
end
|
||||
return output
|
||||
end
|
||||
|
||||
def extra_frozen?
|
||||
|
@ -112,6 +141,7 @@ class Course < ActiveRecord::Base
|
|||
@attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ])
|
||||
end
|
||||
|
||||
|
||||
# 获取资源后缀名列表
|
||||
def contenttypes
|
||||
attachmenttypes
|
||||
|
@ -275,7 +305,7 @@ class Course < ActiveRecord::Base
|
|||
end
|
||||
|
||||
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
|
||||
def name
|
||||
read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
|
||||
end
|
||||
#def name
|
||||
# read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
|
||||
#end
|
||||
end
|
||||
|
|
|
@ -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,12 +40,16 @@ 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)
|
||||
end
|
||||
|
||||
def has_right?(project,user=User.current)
|
||||
user.admin? || user.member_of?(project) || self.is_public==1
|
||||
end
|
||||
|
||||
def initialize(attributes=nil, *args)
|
||||
super
|
||||
if new_record?
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class FirstPage < ActiveRecord::Base
|
||||
attr_accessible :description, :title, :web_title,:page_type,:sort_type
|
||||
validates_presence_of :web_title, :title, :description,:page_type
|
||||
validates_length_of :web_title,:title, maximum: 30
|
||||
validates_length_of :description, maximum: 100
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class GitlabProject < ActiveRecord::Base
|
||||
attr_accessible :project_id
|
||||
|
||||
validates_uniqueness_of :localfile_url
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
class GitlabUser < ActiveRecord::Base
|
||||
attr_accessible :user_id
|
||||
|
||||
belongs_to :user
|
||||
|
||||
# 获取用户在Gitlab项目中的角色
|
||||
def project_role gitlab_project_id
|
||||
@project_role[gitlab_project_id]
|
||||
end
|
||||
|
||||
def project_role_set(gitlab_project_id,role)
|
||||
if @project_role.nil?
|
||||
@project_role = []
|
||||
end
|
||||
@project_role[gitlab_project_id] = role
|
||||
end
|
||||
|
||||
validates_uniqueness_of :gitlab_user_id
|
||||
end
|
|
@ -562,6 +562,12 @@ class Issue < ActiveRecord::Base
|
|||
@workflow_rule_by_attribute = result if user.nil?
|
||||
result
|
||||
end
|
||||
# 缺陷的短描述信息
|
||||
def short_description(length = 255)
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
end
|
||||
|
||||
private :workflow_rule_by_attribute
|
||||
|
||||
def done_ratio
|
||||
|
@ -1513,4 +1519,6 @@ class Issue < ActiveRecord::Base
|
|||
def be_user_score_new_issue
|
||||
UserScore.project(:post_issue, User.current,self, { issue_id: self.id })
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -141,6 +141,19 @@ class Mailer < ActionMailer::Base
|
|||
:subject => s
|
||||
end
|
||||
|
||||
# 用户申请加入项目邮件通知
|
||||
def applied_project(applied)
|
||||
@project =applied.project
|
||||
redmine_headers 'Project' => @project,
|
||||
'User' => applied.user
|
||||
@user = applied.user
|
||||
recipients = @project.manager_recipients
|
||||
s = l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name)
|
||||
@applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members')
|
||||
mail :to => recipients,
|
||||
:subject => s
|
||||
end
|
||||
|
||||
def reminder(user, issues, days)
|
||||
set_language_if_valid user.language
|
||||
@issues = issues
|
||||
|
@ -177,25 +190,45 @@ class Mailer < ActionMailer::Base
|
|||
added_to_url = ''
|
||||
@author = attachments.first.author
|
||||
case container.class.name
|
||||
when 'Project'
|
||||
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
|
||||
added_to = "#{l(:label_project)}: #{container}"
|
||||
recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail}
|
||||
when 'Version'
|
||||
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
|
||||
added_to = "#{l(:label_version)}: #{container.name}"
|
||||
recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail}
|
||||
when 'Document'
|
||||
added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id)
|
||||
added_to = "#{l(:label_document)}: #{container.title}"
|
||||
recipients = container.recipients
|
||||
when 'Project'
|
||||
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
|
||||
added_to = "#{l(:label_project)}: #{container}"
|
||||
recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
|
||||
when 'Course'
|
||||
added_to_url = url_for(:controller => 'files', :action => 'index', :course_id => container)
|
||||
added_to = "#{l(:label_course)}: #{container}"
|
||||
recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
|
||||
when 'Version'
|
||||
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
|
||||
added_to = "#{l(:label_version)}: #{container.name}"
|
||||
recipients = container.project.notified_users.select { |user| user.allowed_to?(:view_files, container.project) }.collect { |u| u.mail }
|
||||
when 'Document'
|
||||
added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id)
|
||||
added_to = "#{l(:label_document)}: #{container.title}"
|
||||
recipients = container.recipients
|
||||
end
|
||||
if container.class.name == 'Course'
|
||||
redmine_headers 'Course' => container.id
|
||||
@attachments = attachments
|
||||
@added_to = added_to
|
||||
@added_to_url = added_to_url
|
||||
mail :to => recipients,
|
||||
:subject => "[#{container.name}] #{l(:label_attachment_new)}"
|
||||
elsif container.class.name == 'Project'
|
||||
redmine_headers 'Project' => container.id
|
||||
@attachments = attachments
|
||||
@added_to = added_to
|
||||
@added_to_url = added_to_url
|
||||
mail :to => recipients,
|
||||
:subject => "[#{container.name}] #{l(:label_attachment_new)}"
|
||||
else
|
||||
redmine_headers 'Project' => container.project.identifier
|
||||
@attachments = attachments
|
||||
@added_to = added_to
|
||||
@added_to_url = added_to_url
|
||||
mail :to => recipients,
|
||||
:subject => "[#{container.project.name}] #{l(:label_attachment_new)}"
|
||||
end
|
||||
redmine_headers 'Project' => container.project.identifier
|
||||
@attachments = attachments
|
||||
@added_to = added_to
|
||||
@added_to_url = added_to_url
|
||||
mail :to => recipients,
|
||||
:subject => "[#{container.project.name}] #{l(:label_attachment_new)}"
|
||||
end
|
||||
|
||||
# Builds a Mail::Message object used to email recipients of a news' project when a news item is added.
|
||||
|
|
|
@ -74,6 +74,13 @@ class News < ActiveRecord::Base
|
|||
visible(user).includes([:author, :project]).order("#{News.table_name}.created_on DESC").limit(count).all
|
||||
end
|
||||
|
||||
# 新闻的短描述信息
|
||||
def short_description(length = 255)
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
#description
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_author_as_watcher
|
||||
|
|
|
@ -85,6 +85,9 @@ class OpenSourceProject < ActiveRecord::Base
|
|||
|
||||
def short_description(length = 255)
|
||||
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
#description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
# 不再使用短描述
|
||||
# description
|
||||
end
|
||||
|
||||
def applied_by?(user)
|
||||
|
|
|
@ -41,7 +41,7 @@ class Project < ActiveRecord::Base
|
|||
has_many :principals, :through => :member_principals, :source => :principal
|
||||
has_many :enabled_modules, :dependent => :delete_all
|
||||
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
||||
has_many :issues, :dependent => :destroy, :include => [:status, :tracker] , :order => "id ASC"
|
||||
has_many :issues, :dependent => :destroy, :include => [:status, :tracker]
|
||||
has_many :issue_changes, :through => :issues, :source => :journals
|
||||
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
|
||||
has_many :time_entries, :dependent => :delete_all
|
||||
|
@ -56,13 +56,12 @@ class Project < ActiveRecord::Base
|
|||
#added by xianbo for delete biding_project
|
||||
has_many :biding_projects, :dependent => :destroy
|
||||
has_many :contesting_projects, :dependent => :destroy
|
||||
has_many :projecting_softapplications, :dependent => :destroy
|
||||
has_many :softapplications, :through => :projecting_softapplications
|
||||
#ended by xianbo
|
||||
# added by fq
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :homework_for_courses, :dependent => :destroy
|
||||
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
||||
#has_many :homework_for_courses, :dependent => :destroy
|
||||
#has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
||||
has_many :shares, :dependent => :destroy
|
||||
# has_many :students_for_courses, :dependent => :destroy
|
||||
has_many :student, :through => :students_for_courses, :source => :user
|
||||
|
@ -127,7 +126,7 @@ class Project < ActiveRecord::Base
|
|||
after_save :update_position_under_parent, :if => Proc.new {|project| project.name_changed?}
|
||||
after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?}
|
||||
# 创建project之后默认创建一个board,之后的board去掉了board的概念
|
||||
after_save :create_board_sync
|
||||
after_create :create_board_sync
|
||||
before_destroy :delete_all_members
|
||||
def remove_references_before_destroy
|
||||
return if self.id.nil?
|
||||
|
@ -156,7 +155,7 @@ class Project < ActiveRecord::Base
|
|||
where(nil)
|
||||
else
|
||||
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
|
||||
}
|
||||
scope :project_entities, -> { where(project_type: ProjectType_project) }
|
||||
|
@ -207,6 +206,12 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
# end
|
||||
|
||||
# 管理员的邮件列表
|
||||
def manager_recipients
|
||||
notified = project.project_infos.collect(&:user)
|
||||
notified.collect(&:mail)
|
||||
end
|
||||
|
||||
def initialize(attributes=nil, *args)
|
||||
super
|
||||
|
||||
|
@ -623,7 +628,8 @@ class Project < ActiveRecord::Base
|
|||
|
||||
# Returns a short description of the projects (first lines)
|
||||
def short_description(length = 255)
|
||||
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
end
|
||||
|
||||
def css_classes
|
||||
|
@ -1131,13 +1137,13 @@ class Project < ActiveRecord::Base
|
|||
# 创建项目后在项目下同步创建一个讨论区
|
||||
def create_board_sync
|
||||
@board = self.boards.build
|
||||
self.name=" #{l(:label_borad_course) }"
|
||||
self.name=" #{l(:label_borad_project) }"
|
||||
@board.name = self.name
|
||||
@board.description = self.name.to_s
|
||||
if @board.save
|
||||
logger.debug "[Course Model] ===> #{@board.to_json}"
|
||||
logger.debug "[Project Model] ===> #{@board.to_json}"
|
||||
else
|
||||
logger.error "[Course Model] ===> Auto create board when Course saved, because #{@board.full_messages}"
|
||||
logger.error "[Project Model] ===> Auto create board when Project saved, because #{@board.full_messages}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -135,6 +135,37 @@ class Repository < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# 获取版本库地址
|
||||
def repos_url
|
||||
if self.scm_name=="Git"
|
||||
gitlabproject = GitlabProject.find_by_localfile_url(self.url)
|
||||
if gitlabproject.nil?
|
||||
# 兼容老git模式
|
||||
ip = Setting.gitlab_server
|
||||
if ip.nil?
|
||||
self.url
|
||||
else
|
||||
project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
|
||||
"http://" + self.login.to_s + self.identifier.to_s + ip + self.url.slice(project_path_cut, self.url.length)
|
||||
end
|
||||
else
|
||||
gitlabproject.repository_url
|
||||
end
|
||||
else
|
||||
self.url
|
||||
end
|
||||
end
|
||||
|
||||
# 版本库的web管理地址
|
||||
def web_url
|
||||
gitlabproject = GitlabProject.find_by_localfile_url(self.url)
|
||||
if gitlabproject
|
||||
gitlabproject.web_url
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
def <=>(repository)
|
||||
if is_default?
|
||||
-1
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -10,7 +10,6 @@ class Softapplication < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :project
|
||||
has_many :contests, :through => :contesting_softapplications
|
||||
belongs_to :project
|
||||
|
||||
def add_jour(user, notes, reference_user_id = 0, options = {})
|
||||
if options.count == 0
|
||||
|
|
|
@ -209,10 +209,6 @@ class User < Principal
|
|||
|
||||
|
||||
# ======================================================================
|
||||
# 集中处理 User 扩展表为空的问题
|
||||
# 合并 user_score 属性
|
||||
validate :valid_user_extensions
|
||||
after_save :save_user_extensions
|
||||
|
||||
def extensions
|
||||
self.user_extensions ||= UserExtensions.new
|
||||
|
@ -222,49 +218,6 @@ class User < Principal
|
|||
self.user_score ||= UserScore.new
|
||||
end
|
||||
|
||||
alias_method :ori_respond_to?, :respond_to?
|
||||
def respond_to?(m, include_private = false)
|
||||
flag = false
|
||||
flag = ori_respond_to? m.to_sym unless flag
|
||||
flag = UserExtensions.new.respond_to? m.to_sym unless flag
|
||||
flag = UserScore.new.respond_to? m.to_sym unless flag
|
||||
|
||||
flag
|
||||
end
|
||||
|
||||
def method_missing m, *args, &block
|
||||
if extensions.respond_to? m.to_sym
|
||||
self.class.send(:define_method, "_meta_#{m}".to_sym) do |*args, &block|
|
||||
self.extensions.__send__ m.to_sym, *args
|
||||
end
|
||||
__send__ "_meta_#{m}".to_sym, *args, &block
|
||||
|
||||
elsif user_score_attr.respond_to? m.to_sym
|
||||
self.class.send(:define_method, "_meta_#{m}".to_sym) do |*args, &block|
|
||||
self.user_score_attr.__send__ m.to_sym, *args
|
||||
end
|
||||
__send__ "_meta_#{m}".to_sym, *args, &block
|
||||
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def valid_user_extensions
|
||||
if !self.extensions.valid?
|
||||
self.extensions.errors.messages.each do |key, values|
|
||||
values.each do |value|
|
||||
self.errors.add key, value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def save_user_extensions
|
||||
self.extensions.save
|
||||
self.user_score_attr.save
|
||||
end
|
||||
# 集中处理 User 扩展表为空的问题 < end
|
||||
# ======================================================================
|
||||
|
||||
#选择项目成员时显示的用户信息文字
|
||||
|
@ -1043,4 +996,4 @@ class AnonymousUser < User
|
|||
def destroy
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class UserStatus < ActiveRecord::Base
|
||||
attr_accessible :changesets_count, :user_id, :watchers_count
|
||||
belongs_to :users
|
||||
belongs_to :user
|
||||
belongs_to :watchers
|
||||
belongs_to :changesets
|
||||
validates_presence_of :user_id
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class WorksCategory < ActiveRecord::Base
|
||||
attr_accessible :category
|
||||
end
|
|
@ -1,3 +1,8 @@
|
|||
<% @nav_dispaly_home_path_label = 1
|
||||
@nav_dispaly_main_course_label = 1
|
||||
@nav_dispaly_main_project_label = 1
|
||||
@nav_dispaly_main_contest_label = 1 %>
|
||||
<% @nav_dispaly_forum_label = 1%>
|
||||
<%= call_hook :view_account_login_top %>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
<% @nav_dispaly_home_path_label = 1
|
||||
@nav_dispaly_main_course_label = 1
|
||||
@nav_dispaly_main_project_label = 1
|
||||
@nav_dispaly_main_contest_label = 1 %>
|
||||
<% @nav_dispaly_forum_label = 1%>
|
||||
<h3><%=l(:label_password_lost)%></h3>
|
||||
|
||||
<%= form_tag(lost_password_path) do %>
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
<% @nav_dispaly_home_path_label = 1
|
||||
@nav_dispaly_main_course_label = 1
|
||||
@nav_dispaly_main_project_label = 1
|
||||
@nav_dispaly_main_contest_label = 1 %>
|
||||
<% @nav_dispaly_forum_label = 1%>
|
||||
<!-- added by bai 增加地区-->
|
||||
<script type="text/javascript" language="javascript">
|
||||
function showcity(province, cityField) {
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<h3><%=l(:label_first_page_made)%></h3>
|
||||
|
||||
<%= form_tag(:controller => 'admin', :action => 'contest_page_made') do%>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='web_title'><%= l(:label_web_title) %>:</label>
|
||||
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</p>
|
||||
<div class="tabs">
|
||||
<ul>
|
||||
<li><%= link_to l(:label_project_first_page), {:action => 'first_page_made'} %></li>
|
||||
<li><%= link_to l(:label_course_first_page), {:action => 'course_page_made'} %></li>
|
||||
<li><%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} , :class => 'selected'%></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h4><%=l(:label_contest_first_page)%></h4>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='attachments_fields'> <%= l(:label_site_image) %>:</label>
|
||||
</p>
|
||||
<div style="margin-left: 82px;" id="avatar">
|
||||
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@contest_page} %>
|
||||
</div>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='contest_title'> <%= l(:label_site_title) %>:</label>
|
||||
<%= text_field_tag 'contest_title', params[:label_site_title], :value => @contest_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</p>
|
||||
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='contest_description' style="vertical-align: top"> <%= l(:label_site_description)%>:</label>
|
||||
<%= text_area_tag 'contest_description',@contest_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</p>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label> <%= link_to l(:label_notification), '#',
|
||||
:onclick => '$("#notification").slideToggle(400); ' %></label>
|
||||
|
||||
</p>
|
||||
<div style="margin-left:60px;padding-right: 20px;" id="notification">
|
||||
<label for='contest_description' style="vertical-align: top"> </label>
|
||||
<% labelled_form_for %>
|
||||
<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
|
||||
</div>
|
||||
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
|
||||
<% end %>
|
||||
<div>
|
||||
|
||||
|
||||
|
||||
</div>
|
|
@ -0,0 +1,37 @@
|
|||
<h3><%=l(:label_first_page_made)%></h3>
|
||||
|
||||
<%= form_tag(:controller => 'admin', :action => 'course_page_made') do %>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='web_title'><%= l(:label_web_title) %>:</label>
|
||||
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</p>
|
||||
<div class="tabs">
|
||||
<ul>
|
||||
<li><%= link_to l(:label_project_first_page), {:action => 'first_page_made'} %></li>
|
||||
<li><%= link_to l(:label_course_first_page), {:action => 'course_page_made'}, :class => 'selected' %></li>
|
||||
<li><%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} %></li>
|
||||
</ul>
|
||||
</div>
|
||||
<h4><%=l(:label_course_first_page)%></h4>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='attachments_fields'> <%= l(:label_site_image) %>:</label>
|
||||
</p>
|
||||
<div style="margin-left: 82px;" id="avatar">
|
||||
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@course_page} %>
|
||||
</div>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='course_title'> <%= l(:label_site_title) %>:</label>
|
||||
<%= text_field_tag 'course_title', params[:label_site_title], :value => @course_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</p>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='course_description' style="vertical-align: top"> <%= l(:label_site_description)%>:</label>
|
||||
<%= text_area_tag 'course_description',@course_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</p>
|
||||
|
||||
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
|
||||
<% end %>
|
||||
<div>
|
||||
|
||||
|
||||
|
||||
</div>
|
|
@ -0,0 +1,46 @@
|
|||
<h3><%=l(:label_first_page_made)%></h3>
|
||||
|
||||
<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='web_title'><%= l(:label_web_title) %>:</label>
|
||||
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</p>
|
||||
<div class="tabs">
|
||||
<ul>
|
||||
<li><%= link_to l(:label_project_first_page), {:action => 'first_page_made'}, :class => 'selected' %></li>
|
||||
<li><%= link_to l(:label_course_first_page), {:action => 'course_page_made'} %></li>
|
||||
<li><%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} %></li>
|
||||
</ul>
|
||||
</div>
|
||||
<h4><%=l(:label_project_first_page)%></h4>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='attachments_fields'> <%= l(:label_site_image) %>:</label>
|
||||
</p>
|
||||
<div style="margin-left: 82px;" id="avatar">
|
||||
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
|
||||
</div>
|
||||
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='title'> <%= l(:label_site_title) %>:</label>
|
||||
<%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</p>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<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;" %>
|
||||
</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 %>
|
||||
<% end %>
|
||||
<div>
|
||||
|
||||
|
||||
|
||||
</div>
|
|
@ -0,0 +1,31 @@
|
|||
<h3><%=l(:label_first_page_made)%></h3>
|
||||
|
||||
<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='web_title'><%= l(:label_web_title) %>:</label>
|
||||
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</p>
|
||||
<h4><%=l(:label_project_first_page)%></h4>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='attachments_fields'> <%= l(:label_site_image) %>:</label>
|
||||
</p>
|
||||
<div style="margin-left: 82px;">
|
||||
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
|
||||
</div>
|
||||
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='title'> <%= l(:label_site_title) %>:</label>
|
||||
<%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</p>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<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;" %>
|
||||
</p>
|
||||
|
||||
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
|
||||
<% end %>
|
||||
<div>
|
||||
|
||||
|
||||
|
||||
</div>
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<h3><%= l(:label_user_plural)%></h3>
|
||||
|
||||
<%= form_tag(:controller => 'admin', :action => 'search', :method => :get) do %>
|
||||
<%= form_tag(:controller => 'admin', :action => 'search') do %>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<%= l(:label_filter_plural) %>
|
||||
|
@ -51,7 +51,7 @@
|
|||
<td class="created_on" align="center"><%= format_time(user.created_on) %></td>
|
||||
<td class="last_login_on" align="center"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
|
||||
<td class="buttons"> <%= change_status_link(user) %>
|
||||
<%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %> </td>
|
||||
<%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %> </td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
</tbody>
|
||||
|
@ -65,4 +65,4 @@
|
|||
|
||||
<% html_title(l(:label_user_plural)) -%>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<h3><%= l(:label_user_plural)%></h3>
|
||||
|
||||
<%= form_tag(:controller => 'admin', :action => 'search', :method => :get) do %>
|
||||
<%= form_tag(:controller => 'admin', :action => 'search') do %>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<%= l(:label_filter_plural) %>
|
||||
|
@ -51,7 +51,7 @@
|
|||
<td class="created_on" align="center"><%= format_time(user.created_on) %></td>
|
||||
<td class="last_login_on" align="center"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
|
||||
<td class="buttons"> <%= change_status_link(user) %>
|
||||
<%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %> </td>
|
||||
<%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %> </td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
</tbody>
|
||||
|
@ -66,4 +66,4 @@
|
|||
<% html_title(l(:label_user_plural)) -%>
|
||||
<%else %>
|
||||
|
||||
<% end%>
|
||||
<% end%>
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
<% container.attachments.each_with_index do |attachment, i| %>
|
||||
<span id="attachments_p<%= i %>" class="attachment">
|
||||
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
|
||||
|
||||
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") +
|
||||
link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
|
||||
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
|
||||
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, :class => 'is_public')%>
|
||||
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
@ -35,3 +35,5 @@
|
|||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag 'attachments' %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
$('#edit-file-dense-form-<%= @attachment.id.to_s%>').hide();
|
||||
$('#field_file_dense_id_label<%= @attachment.id.to_s%>').show();
|
||||
$('#edit_box_dense<%= @attachment.id.to_s%>').show();
|
||||
<%if @attachment.is_public == 1%>
|
||||
$('#field_file_dense_id_label<%= @attachment.id.to_s%>').html('公开');
|
||||
<%else%>
|
||||
$('#field_file_dense_id_label<%= @attachment.id.to_s%>').html('私有');
|
||||
<%end%>
|
||||
// 下面2种写法都没起作用,暂时使用上面的非本地化模式
|
||||
// <%if @attachment.is_public == 1%>
|
||||
// $('#field_file_dense_id_label<%= @attachment.id.to_s%>').html('<%l(:field_is_public)%>');
|
||||
// <%else%>
|
||||
// $('#field_file_dense_id_label<%= @attachment.id.to_s%>').html('<%l(:field_is_private)%>');
|
||||
// <%end%>
|
||||
// $('#field_file_dense_id_label<%= @attachment.id.to_s%>').html(<%=@newfiledense%>);
|
|
@ -1,3 +1,4 @@
|
|||
<div id="avatardiv">
|
||||
<style type="text/css">
|
||||
a, a:hover {text-decoration:none;}
|
||||
.btn_addPic
|
||||
|
@ -42,9 +43,11 @@
|
|||
<div id="upload_progressbar" style="height:14px; margin-bottom: 10px;display: block"></div>
|
||||
</div>
|
||||
</span>
|
||||
<a href="javascript:void(0);" class="btn_addPic" style="text-decoration:none;">
|
||||
<%= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "btn_addPic", :style => "text-decoration:none;" %>
|
||||
<a href="javascript:void(0);" class="btn_addPic" style="text-decoration:none;">
|
||||
<span><%= l(:button_upload_photo) %></span>
|
||||
</a>
|
||||
<!-- :accept => 'image/png,image/gif,image/jpeg', -->
|
||||
<span class="add_avatar" style="margin-left: -55px;width: 70px">
|
||||
<%= file_field_tag 'avatar[image]',
|
||||
:id => nil,
|
||||
|
@ -57,6 +60,8 @@
|
|||
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
||||
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
||||
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
||||
:file_type => Redmine::Configuration['pic_types'].to_s,
|
||||
:type_support_message => l(:error_pic_type),
|
||||
:upload_path => upload_avatar_path(:format => 'js'),
|
||||
:description_placeholder => nil ,# l(:label_optional_description)
|
||||
:source_type => source.class.to_s,
|
||||
|
@ -67,3 +72,4 @@
|
|||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag 'avatars' %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -0,0 +1,5 @@
|
|||
var avatardiv = $('#avatardiv');
|
||||
avatardiv.replaceWith("<%= escape_javascript(render :partial=>'avatar/avatar_form',:style => 'display:inline',:locals=> {source:@source}) %>");
|
||||
//var imgSpan = $('#avatar_image');
|
||||
|
||||
//imgSpan.attr({"src":'<#%= @urlfile.to_s << "?" << Time.now.to_s%>'});
|
|
@ -33,7 +33,7 @@
|
|||
<p><%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;" %><%= calendar_for('bid_deadline')%>
|
||||
</p>
|
||||
<!--
|
||||
<p><%= f.select :homework_type, homework_type_option %>
|
||||
<p><%#= f.select :homework_type, homework_type_option %>
|
||||
</p>
|
||||
-->
|
||||
<p><%= f.select :is_evaluation, is_evaluation_option %>
|
||||
|
|
|
@ -8,10 +8,7 @@
|
|||
<table width="100%" valign="center">
|
||||
<tr>
|
||||
<td ><span style="margin-left:0px"><%= l(:label_task_plural)%>(<%= @homework_list.count%>)</span>
|
||||
<%#= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(
|
||||
User.current.admin? ||
|
||||
!(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) ||
|
||||
(Rails.env.development?) %>
|
||||
<%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(is_teacher && @bid.homeworks.count > 0) %>
|
||||
</td>
|
||||
<td align="right">
|
||||
<div class="project-search">
|
||||
|
@ -86,10 +83,12 @@
|
|||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<td style="width: 300px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
<strong>开发项目</strong>:
|
||||
<% if homework.project != nil %>
|
||||
<span title="<%= homework.project.name %>">
|
||||
<%= link_to homework.project.name,project_path(homework.project.id)%>
|
||||
</span>
|
||||
<% else %>
|
||||
暂无
|
||||
<% end %>
|
||||
|
@ -115,9 +114,9 @@
|
|||
</td>
|
||||
<td>
|
||||
<strong>互评得分:
|
||||
<% student_homework_score = student_score_for_homework(homework) %>
|
||||
<span style="color:<%= student_homework_score == "0.00"? "#727272" : "#EC6300"%>;">
|
||||
<% score = student_homework_score == "0.00"? "N/A" : student_homework_score %>
|
||||
<%# student_homework_score = student_score_for_homework(homework) %>
|
||||
<span style="color:<%= homework.s_score.nil? ? "#727272" : "#EC6300"%>;">
|
||||
<% score = homework.s_score.nil? ? "N/A" : format("%.2f",homework.s_score) %>
|
||||
<%= score %>
|
||||
</span>
|
||||
<% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%>
|
||||
|
@ -134,7 +133,8 @@
|
|||
</td>
|
||||
<td>
|
||||
<strong>终评得分:
|
||||
<% totle_homework_score = score_for_homework(homework) %>
|
||||
<%# totle_homework_score = score_for_homework(homework) %>
|
||||
<% totle_homework_score = format("%.2f",(homework.t_score.nil? ? 0.00 : homework.t_score) * (@bid.proportion * 1.0 / 100) + (homework.s_score.nil? ? 0.00 : homework.s_score) * (1 - @bid.proportion * 1.0 / 100)) %>
|
||||
<span style="color:<%= totle_homework_score == "0.00"? "#727272" : "#EC6300"%> ;">
|
||||
<% score = totle_homework_score == "0.00"? "N/A" : totle_homework_score %>
|
||||
<%= score %>
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
<%
|
||||
@nav_dispaly_contest_label = 1
|
||||
@nav_dispaly_store_all_label = 1
|
||||
@nav_dispaly_forum_label = 1
|
||||
%>
|
||||
<!-- fq -->
|
||||
<!-- modified by huang -->
|
||||
<div class="top-content">
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
<%
|
||||
@nav_dispaly_contest_label = 1
|
||||
@nav_dispaly_store_all_label = 1
|
||||
@nav_dispaly_forum_label = 1
|
||||
%>
|
||||
<!-- fq -->
|
||||
<h3><%=l(:label_new_call)%></h3>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% if @bid.homework_type == Bid::HomeworkFile %>
|
||||
<% if @bid.homework_type %>
|
||||
<!-- 提交文件类型 -->
|
||||
<%= render :partial => 'homework' %>
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<!-- <%= course_board_breadcrumb(@board) %> -->
|
||||
<!-- <%#= course_board_breadcrumb(@board) %> -->
|
||||
|
||||
<!--new and follow-->
|
||||
<!-- <div class="content-title-top">
|
||||
<%= link_to l(:label_message_new),
|
||||
<%#= link_to l(:label_message_new),
|
||||
new_board_message_path(@board),
|
||||
:class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %> -->
|
||||
<!-- <%= watcher_link(@board, User.current) %> -->
|
||||
<!-- <%#= watcher_link(@board, User.current) %> -->
|
||||
<!-- </div> -->
|
||||
<div id="add-message" class="add_frame" style="display:none;">
|
||||
<% if User.current.logged? %>
|
||||
|
|
|
@ -1,33 +1,35 @@
|
|||
<!-- <%= board_breadcrumb(@board) %> -->
|
||||
<!-- <%#= board_breadcrumb(@board) %> -->
|
||||
|
||||
<!--new and follow-->
|
||||
<!-- <div class="content-title-top">
|
||||
<%= link_to l(:label_message_new),
|
||||
<%#= link_to l(:label_message_new),
|
||||
new_board_message_path(@board),
|
||||
:class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %> -->
|
||||
<!-- <%= watcher_link(@board, User.current) %> -->
|
||||
<!-- <%#= watcher_link(@board, User.current) %> -->
|
||||
<!-- </div> -->
|
||||
<div id="add-message" class="add_frame" style="display:none;">
|
||||
<% if User.current.logged? %>
|
||||
<h3><%= link_to h(@board.name), project_board_path(@project, @board) %> » <%= l(:label_message_new) %></h3>
|
||||
<div class="add_frame_header" >
|
||||
|
||||
<div class="add_frame_header">
|
||||
<%= l(:label_message_new) %>
|
||||
</div>
|
||||
<%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||
<%= render :partial => 'messages/form', :locals => {:f => f} %>
|
||||
<p><%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
|
||||
<%= preview_link(preview_board_message_path(@board), 'message-form' ,target='preview',{:class => 'whiteButton m3p10'} )%> |
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;' ,:class => 'whiteButton m3p10' %></p>
|
||||
<%= preview_link(preview_board_message_path(@board), 'message-form', target='preview', {:class => 'whiteButton m3p10'}) %>
|
||||
|
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;', :class => 'whiteButton m3p10' %></p>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!--display the board-->
|
||||
<div class="borad-title"><%=h @board.name %></div>
|
||||
<div class="borad-title"><%= h @board.name %></div>
|
||||
|
||||
<% if !User.current.logged?%>
|
||||
<% if !User.current.logged? %>
|
||||
<div style="font-size: 14px;margin:20px;">
|
||||
<% if @project.project_type == 1 %>
|
||||
<%= l(:label_user_login_course_board) %>
|
||||
|
@ -39,15 +41,17 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- <div class="borad-description"><%=h @board.description %></div> -->
|
||||
<!-- <div class="borad-description"><%= h @board.description %></div> -->
|
||||
<div class="borad-setitle">
|
||||
<span class="borad-topic-count">共有 <%=link_to @topics.count %> 个贴子</span>
|
||||
<span>
|
||||
<%= link_to l(:label_message_new),
|
||||
new_board_message_path(@board),
|
||||
:class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %>
|
||||
</span>
|
||||
<span class="borad-topic-count">共有 <%= link_to @topics.count %> 个贴子</span>
|
||||
<% if @project.enabled_modules.where("name = 'boards'").count > 0 %>
|
||||
<span>
|
||||
<%= link_to l(:label_message_new),
|
||||
new_board_message_path(@board),
|
||||
:class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div style="padding-top: 10px">
|
||||
<% if @topics.any? %>
|
||||
|
@ -63,18 +67,29 @@
|
|||
<% @topics.each do |topic| %>
|
||||
<table class="content-text-list">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) %></td>
|
||||
<td colspan="2" valign="top" width="50"><%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) %></td>
|
||||
<td>
|
||||
<table width="640px" border="0">
|
||||
<tr>
|
||||
<td valign="top" width="500px" class=" <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"><%= link_to h(topic.subject), board_message_path(@board, topic) %></td>
|
||||
<td align="right" rowspan="3"><table class="borad-count"><tr><td align="center" class="borad-count-digit"><%=link_to (topic.replies_count), board_message_path(@board, topic) %></td></tr>
|
||||
<tr><td align="center">回答</td></tr>
|
||||
</table></td>
|
||||
<td align="right" rowspan="3">
|
||||
<table class="borad-count">
|
||||
<tr>
|
||||
<td align="center" class="borad-count-digit"><%= link_to (topic.replies_count), board_message_path(@board, topic) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">回答</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- <tr><td colspan="2" ><span class="font_description">标签</span></td></tr> -->
|
||||
<tr><td align="left" colspan="2" ><span class="font_lighter"><%= authoring topic.created_on, topic.author %><br /></span></td></tr>
|
||||
</table></td>
|
||||
<tr>
|
||||
<td align="left" colspan="2">
|
||||
<span class="font_lighter"><%= authoring topic.created_on, topic.author %><br/></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<%= stylesheet_link_tag 'scm' %>
|
||||
<% end %>
|
||||
|
||||
<% html_title(l(:label_news_plural)) -%>
|
||||
<% html_title(l(:label_contest_notification)) -%>
|
||||
</div>
|
||||
|
||||
<script type='text/javascript'>
|
||||
|
|
|
@ -2,11 +2,19 @@
|
|||
<% contests.each do |contest|%>
|
||||
<table width="95%" border="0" style="padding-left: 10px; padding-top: 10px;">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50" ><%= link_to(image_tag(url_to_avatar(contest.author), :class => 'avatar'), user_path(contest.author), :class => "avatar") %></td>
|
||||
<td colspan="2" valign="top" width="50" >
|
||||
<% unless contest.author.nil? %>
|
||||
<%= link_to(image_tag(url_to_avatar(contest.author), :class => 'avatar'), user_path(contest.author), :class => "avatar") %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<table width="100%" border="0">
|
||||
<tr>
|
||||
<td colspan="2" valign="top"><strong><%= link_to(contest.author, user_path(contest.author), :class => 'bid_user') %>: <%= link_to(contest.name, show_contest_contest_path(contest), :class => 'bid_path', :target => "_blank") %></strong></td>
|
||||
<td colspan="2" valign="top"><strong>
|
||||
<% unless contest.author.nil? %>
|
||||
<%= link_to(contest.author, user_path(contest.author), :class => 'bid_user') %>:
|
||||
<% end %>
|
||||
<%= link_to(contest.name, contest_contestnotifications_path(contest), :class => 'bid_path', :target => "_blank") %></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="500">
|
||||
|
|
|
@ -60,6 +60,21 @@
|
|||
$("#put-project-form").hide();
|
||||
}
|
||||
|
||||
function selectChange(obj)
|
||||
{
|
||||
if(obj.value=="其他")
|
||||
{
|
||||
//document.getElementById("a").style.display = ""
|
||||
$("#other_span").show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#other_span").hide();
|
||||
$("#other_input").val("");
|
||||
//document.getElementById("a").style.display = "none"
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<%= render_flash_messages %>
|
||||
<!--参赛步骤-->
|
||||
|
@ -87,83 +102,91 @@
|
|||
<div id="put-project-form" style="display: none; padding-left: 83px; width: 88%">
|
||||
<%= form_for Softapplication.new, :url => softapplications_path do |f| %>
|
||||
<fieldset class="contes-new-box" style="padding-left: 36px; line-height: 8px; margin-left: 1px" >
|
||||
<%= hidden_field_tag 'contest_id', @contest.id %>
|
||||
<tr style="width:700px; margin-left: -10px;">
|
||||
<span><%= l(:label_work_name) %></span>
|
||||
<span class="contest-star"> * </span>:
|
||||
<td><%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %></td>
|
||||
<span style="font-size: 10px">(<%= l(:label_workname_lengthlimit) %>)</span>
|
||||
</tr>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<%= hidden_field_tag 'contest_id', @contest.id %>
|
||||
<tr style="width:700px; margin-left: -10px;">
|
||||
<span><%= l(:label_work_name) %></span>
|
||||
<span class="contest-star"> * </span>:
|
||||
<td><%= f.text_field :name, :required => true, :size => 60, :style => "width:350px;" %></td>
|
||||
<span style="font-size: 10px">(<%= l(:label_workname_lengthlimit) %>)</span>
|
||||
</tr>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<tr style="width:800px;">
|
||||
<span><%= l(:label_running_platform) %></span>
|
||||
<span class="contest-star"> * </span>:
|
||||
<td style="width: 100px"><%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %></td>
|
||||
<tr style="width:800px;">
|
||||
<span><%= l(:label_running_platform) %></span>
|
||||
<span class="contest-star"> * </span>:
|
||||
<td style="width: 100px"><%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:350px;" %></td>
|
||||
|
||||
</tr>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
</tr>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<tr style="width:800px;">
|
||||
<span><%= l(:label_work_type) %></span>
|
||||
<tr style="width:800px;">
|
||||
<span><%= l(:label_work_type) %></span>
|
||||
<span class="contest-star"> * </span>:
|
||||
<td style="width: 100px">
|
||||
<span>
|
||||
<%#= select_tag 'app_type_name', work_type_opttion, {:name => 'app_type_name',:style => "width:358px;"} %>
|
||||
</span>
|
||||
<%= f.select :app_type_name,work_type_opttion, {},{:style => "width:358px;",:onchange => "selectChange(this)"} %>
|
||||
<%#= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %>
|
||||
</td>
|
||||
<span style="font-size: 10px;display: none" id="other_span">
|
||||
<%#= f.text_field :other_input, :required => true, :size => 60, :style => "width:100px;" %>
|
||||
<input type="text" style="width: 100px;" id="other_input" name = "other_input"/>
|
||||
</span>
|
||||
</tr>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<span class="contest-star"> * </span>:
|
||||
<td style="width: 100px"><%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %></td>
|
||||
<tr style="width:800px;">
|
||||
<span><%= l(:label_work_description) %></span>
|
||||
<span class="contest-star"> * </span>:
|
||||
<td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:350px;" %></td>
|
||||
<span style="font-size: 10px">(<%= l(:label_workdescription_lengthlimit) %>)</span>
|
||||
</tr>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
</tr>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<tr style="width:800px;">
|
||||
<span><%= l(:label_softapplication_developers) %></span>
|
||||
<span class="contest-star"> * </span>:
|
||||
<td style="width: 100px"><%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:350px;" %></td>
|
||||
|
||||
<tr style="width:800px;">
|
||||
<span><%= l(:label_work_description) %></span>
|
||||
<span class="contest-star"> * </span>:
|
||||
<td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %></td>
|
||||
<span style="font-size: 10px">(<%= l(:label_workdescription_lengthlimit) %>)</span>
|
||||
</tr>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
</tr>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<tr style="width:800px;">
|
||||
<span><%= l(:label_softapplication_developers) %></span>
|
||||
<span class="contest-star"> * </span>:
|
||||
<td style="width: 100px"><%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:400px;" %></td>
|
||||
<tr style="width:800px;">
|
||||
<span><%= l(:label_work_deposit_project) %>:</span>
|
||||
<span style="padding-left: 4px"><%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:358px;" %></span>
|
||||
<span><%= link_to l(:label_create_new_projects),{:controller => 'projects',:action => 'new',course: 0, project_type: 0,host: Setting.project_domain}, :target => '_blank' %></span><!-- new_project_path(course: 0, project_type: 0) -->
|
||||
</tr>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
</tr>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<fieldset style="width: 500px; padding-top: 10px">
|
||||
<legend>
|
||||
<%= l(:label_upload_softworkpacket_photo) %>
|
||||
</legend>
|
||||
<%#= render_flash_messages %>
|
||||
<p id="put-bid-form-partial">
|
||||
<%= render :partial => 'attachments/form' %>
|
||||
</p>
|
||||
|
||||
<tr style="width:800px;">
|
||||
<span><%= l(:label_work_deposit_project) %>:</span>
|
||||
<span style="padding-left: 4px"><%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2' %></span>
|
||||
<span><%= link_to l(:label_create_new_projects), new_project_path(course: 0, project_type: 0), :target => '_blank' %></span>
|
||||
</tr>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<p style="font-size: 11px">
|
||||
1、<%= l(:label_upload_softapplication_packets_mustpacketed) %> <br/>
|
||||
<br>
|
||||
2、<%= l(:label_upload_softapplication_photo_condition) %>
|
||||
</p>
|
||||
|
||||
<fieldset style="width: 500px; padding-top: 10px">
|
||||
<legend>
|
||||
<%= l(:label_upload_softworkpacket_photo) %>
|
||||
</legend>
|
||||
<%#= render_flash_messages %>
|
||||
<p id="put-bid-form-partial">
|
||||
<%= render :partial => 'attachments/form' %>
|
||||
</p>
|
||||
|
||||
<p style="font-size: 11px">
|
||||
1、<%= l(:label_upload_softapplication_packets_mustpacketed) %> <br/>
|
||||
<br>
|
||||
2、<%= l(:label_upload_softapplication_photo_condition) %>
|
||||
</p>
|
||||
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
</fieldset></br>
|
||||
<div class="align-center" style="padding-top: -3px; padding-bottom: 8px">
|
||||
<%= submit_tag l(:button_create) %>
|
||||
|
@ -251,7 +274,10 @@
|
|||
<div style="padding-left: 68px">
|
||||
<tr>
|
||||
<td><%= l(:label_profile) %>:</td>
|
||||
<td> <%= c_project.project.description.truncate(90, omission: '...') %> </td>
|
||||
<td>
|
||||
<%#= c_project.project.description.truncate(90, omission: '...') %>
|
||||
<%= c_project.project.description %>
|
||||
</td>
|
||||
</tr>
|
||||
</br>
|
||||
</div>
|
||||
|
@ -261,9 +287,9 @@
|
|||
<span style="padding-left: 240px"><strong><%= l(:label_attendingcontest_spoksman) %>
|
||||
<!-- modified by zjc 添加超链接 -->
|
||||
<% unless c_project.nil? || c_project.user.nil? %>
|
||||
:</strong><%= link_to c_project.user.name,user_path(c_project.user) %></span>
|
||||
:</strong><%= link_to c_project.user.name,user_path(c_project.user) %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="padding-left: 68px">
|
||||
|
||||
|
@ -287,7 +313,10 @@
|
|||
<div style="padding-left: 68px; padding-top: 5px">
|
||||
<tr>
|
||||
<td><strong><%= l(:label_profile) %>:</strong></td>
|
||||
<td> <%= c_softapplication.softapplication.description.truncate(90, omission: '...') %> </td>
|
||||
<td>
|
||||
<%#= c_softapplication.softapplication.description.truncate(90, omission: '...') %>
|
||||
<%= c_softapplication.softapplication.description %>
|
||||
</td>
|
||||
</tr>
|
||||
</br>
|
||||
</div>
|
||||
|
@ -298,9 +327,9 @@
|
|||
<span style="padding-left: 240px"><strong><%= l(:label_attendingcontest_spoksman) %>
|
||||
<!-- modified by zjc 添加超链接 -->
|
||||
<% unless c_softapplication.nil? || c_softapplication.softapplication.nil? || c_softapplication.softapplication.user.nil? %>
|
||||
:</strong><%= link_to c_softapplication.softapplication.user.name,user_path(c_softapplication.softapplication.user) %></span>
|
||||
:</strong><%= link_to c_softapplication.softapplication.user.name,user_path(c_softapplication.softapplication.user) %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--获奖及教师评奖-->
|
||||
<div style="padding-left: 18px; padding-bottom: 5px">
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<%= content_tag('span', "#{l(:label_institution_name)}:", :class => "course-font")%>
|
||||
<% @admin = @course.course_infos%>
|
||||
<%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%>
|
||||
<!-- <%= @admin.first.user.user_extensions.occupation %> -->
|
||||
<!-- <%#= @admin.first.user.user_extensions.occupation %> -->
|
||||
<% unless @course.teacher.user_extensions.school.nil? %>
|
||||
<%= link_to @course.teacher.user_extensions.school.try(:name), school_course_list_path(@course.teacher.user_extensions.school) %>
|
||||
<% end %>
|
||||
|
@ -28,7 +28,7 @@
|
|||
<%= content_tag('a', @admin.collect{|u| link_to(u.user.lastname+u.user.firstname, user_path(u.user_id))}.join(", ").html_safe) %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="information_for_course" >
|
||||
|
@ -43,7 +43,8 @@
|
|||
</p>
|
||||
<p class="stats">
|
||||
<%= content_tag('span', "#{garble @course.members.count}", :class => "info") %>
|
||||
<%= content_tag('span', l(:label_x_member, :count => @course.members.count)) %>
|
||||
<%#= content_tag('span', l(:label_x_member, :count => @course.members.count)) %>
|
||||
<%= content_tag('span', l(:label_x_member, :count => studentCount(@course)+teacherCount(@course))) %>
|
||||
</p>
|
||||
|
||||
<!--gcm-->
|
||||
|
@ -76,6 +77,10 @@
|
|||
|
||||
<div class="add-info" style="margin-left: 30px; margin-top: -20px">
|
||||
<%= content_tag "span", "#{l(:label_course_brief_introduction)}:", :class => "course-font" %>
|
||||
<%# desc = course.short_description.nil? ? "" : course.short_description%>
|
||||
<!--<#div class="brief_introduction" title="<%#= desc.html_safe%>">
|
||||
<%#= desc.html_safe%>
|
||||
</div>-->
|
||||
<%= content_tag "div", course.short_description, :class => "brief_introduction", :title => course.short_description %>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
<script type="text/javascript">
|
||||
function get_options(value){
|
||||
$.ajax({
|
||||
type :"POST",
|
||||
url :'/school/get_options/'+encodeURIComponent(value),
|
||||
data :'text',
|
||||
success: function(data){
|
||||
$("#occupation").html(data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
function get_options(value){
|
||||
$.ajax({
|
||||
type :"POST",
|
||||
url :'/school/get_options/'+encodeURIComponent(value),
|
||||
data :'text',
|
||||
success: function(data){
|
||||
$("#occupation").html(data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<% object = [] %>
|
||||
|
@ -23,68 +23,68 @@
|
|||
|
||||
<!--[form:course]-->
|
||||
<% unless @course.new_record? %>
|
||||
<p><%= render :partial=>"avatar/avatar_form",:locals=> {source:@course} %></p>
|
||||
<p><%= render :partial=>"avatar/avatar_form",:locals=> {source:@course} %></p>
|
||||
<% end %>
|
||||
<!-- <p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;" %></p> -->
|
||||
<!-- <p><%#= f.text_field :name, :required => true, :size => 60, :style => "width:490px;" %></p> -->
|
||||
<p><label for="course_name" style="font-size: 13px;" ><%=l(:label_tags_course_name)%><span class="required" > * </span></label><input id="course_name" type="text" value="<%=@course.name%>" style="width:490px;" size="60" name="course[name]"></p>
|
||||
|
||||
<!-- <p><%= f.text_field :extra, :required => true, :size => 60, :style => "width:488px;", :disabled => @course.extra_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %>
|
||||
<% unless @course.extra_frozen? %>
|
||||
<em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_course_identifier_info).html_safe %></em>
|
||||
<% end %></p> -->
|
||||
<!-- <p><%#= f.text_field :extra, :required => true, :size => 60, :style => "width:488px;", :disabled => @course.extra_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %>
|
||||
<%# unless @course.extra_frozen? %>
|
||||
<em class="info"><%#= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%#= l(:text_course_identifier_info).html_safe %></em>
|
||||
<%# end %></p> -->
|
||||
|
||||
<!-- added by bai 新增开课时间、结课时间、课时 -->
|
||||
|
||||
<%= f.fields_for @course do |m| %>
|
||||
<!-- added by bai 新增开课时间、结课时间、课时 -->
|
||||
|
||||
<%= f.fields_for @course do |m| %>
|
||||
|
||||
|
||||
|
||||
<!-- added by bai 新增开课时间、结课时间、课时 -->
|
||||
<!--
|
||||
<% unless @course.nil?%>
|
||||
<p><table><tr><td><span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:20px"><%= l(:label_setup_time) %><span class="required"> * </span></span>
|
||||
<span class="info" style="width: 10px"><%= text_field_tag :setup_time, @course.setup_time, :placeholder => "在此选择开课日期" %></span>
|
||||
<span><%= calendar_for('setup_time')%></span>
|
||||
|
||||
<!-- added by bai 新增开课时间、结课时间、课时 -->
|
||||
<!--
|
||||
<%# unless @course.nil?%>
|
||||
<p><table><tr><td><span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:20px"><%#= l(:label_setup_time) %><span class="required"> * </span></span>
|
||||
<span class="info" style="width: 10px"><%#= text_field_tag :setup_time, @course.setup_time, :placeholder => "在此选择开课日期" %></span>
|
||||
<span><%#= calendar_for('setup_time')%></span>
|
||||
</td></tr></table></p>
|
||||
<% else %>
|
||||
<p><table><tr><td><span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:20px"><%= l(:label_setup_time) %><span class="required"> * </span></span>
|
||||
<span class="info" style="width: 10px"><%= text_field_tag :setup_time, nil, :placeholder => "在此选择开课日期" %></span>
|
||||
<span><%= calendar_for('setup_time')%></span>
|
||||
<%# else %>
|
||||
<p><table><tr><td><span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:20px"><%#= l(:label_setup_time) %><span class="required"> * </span></span>
|
||||
<span class="info" style="width: 10px"><%#= text_field_tag :setup_time, nil, :placeholder => "在此选择开课日期" %></span>
|
||||
<span><%#= calendar_for('setup_time')%></span>
|
||||
</td></tr></table></p>
|
||||
<% end %>
|
||||
|
||||
<% unless @course.nil?%>
|
||||
<p><table><tr><td><span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:20px"><%= l(:label_endup_time) %><span class="required"> * </span></span>
|
||||
<span class="info" style="width: 10px"><%= text_field_tag :endup_time, @course.endup_time, :placeholder => "在此选择结课日期" %></span>
|
||||
<span><%= calendar_for('endup_time')%></span>
|
||||
<%# end %>
|
||||
|
||||
<%# unless @course.nil?%>
|
||||
<p><table><tr><td><span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:20px"><%#= l(:label_endup_time) %><span class="required"> * </span></span>
|
||||
<span class="info" style="width: 10px"><%#= text_field_tag :endup_time, @course.endup_time, :placeholder => "在此选择结课日期" %></span>
|
||||
<span><%#= calendar_for('endup_time')%></span>
|
||||
</td></tr></table></p>
|
||||
<% else %>
|
||||
<p><table><tr><td><span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:20px"><%= l(:label_endup_time) %><span class="required"> * </span></span>
|
||||
<span class="info" style="width: 10px"><%= text_field_tag :endup_time, nil, :placeholder => "在此选择结课日期" %></span>
|
||||
<span><%= calendar_for('endup_time')%></span>
|
||||
<%# else %>
|
||||
<p><table><tr><td><span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:20px"><%#= l(:label_endup_time) %><span class="required"> * </span></span>
|
||||
<span class="info" style="width: 10px"><%#= text_field_tag :endup_time, nil, :placeholder => "在此选择结课日期" %></span>
|
||||
<span><%#= calendar_for('endup_time')%></span>
|
||||
</td></tr></table></p>
|
||||
<% end %>
|
||||
-->
|
||||
<% unless @course.nil?%>
|
||||
<p><table><tr><td><span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:22px"><%= l(:label_class_period) %><span class="required"> * </span></span>
|
||||
<span class="info" style="width: 10px"><%= text_field_tag :class_period, @course.class_period, :placeholder => "在此输入课时" %></span> <span> <strong><%= l(:label_class_hour)%></strong></span>
|
||||
</td></tr></table></p>
|
||||
<% else %>
|
||||
<p><table><tr><td><span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:22px"><%= l(:label_class_period) %><span class="required"> * </span></span>
|
||||
<span class="info" style="width: 10px"><%= text_field_tag :class_period, nil, :placeholder => "在此输入课时" %></span><strong><%= l(:label_class_hour)%></strong>
|
||||
</td></tr></table></p>
|
||||
<% end %>
|
||||
|
||||
<!-- end -->
|
||||
|
||||
<!-- added by bai 增加了“年度”和“学期” -->
|
||||
<p><table><tr><td>
|
||||
|
||||
<% unless @course.nil? %>
|
||||
<% if @course.time == 2008 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px; margin-left:20px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008' selected='selected'>2008</option>
|
||||
<%# end %>
|
||||
-->
|
||||
<% unless @course.nil?%>
|
||||
<p><table><tr><td><span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:22px"><%= l(:label_class_period) %><span class="required"> * </span></span>
|
||||
<span class="info" style="width: 10px"><%= text_field_tag :class_period, @course.class_period, :placeholder => "在此输入课时" %></span> <span> <strong><%= l(:label_class_hour)%></strong></span>
|
||||
</td></tr></table></p>
|
||||
<% else %>
|
||||
<p><table><tr><td><span class="info" align="right" style="width: 90px; font-weight: bold ;margin-left:22px"><%= l(:label_class_period) %><span class="required"> * </span></span>
|
||||
<span class="info" style="width: 10px"><%= text_field_tag :class_period, nil, :placeholder => "在此输入课时" %></span><strong><%= l(:label_class_hour)%></strong>
|
||||
</td></tr></table></p>
|
||||
<% end %>
|
||||
|
||||
<!-- end -->
|
||||
|
||||
<!-- added by bai 增加了“年度”和“学期” -->
|
||||
<p><table><tr><td>
|
||||
|
||||
<% unless @course.nil? %>
|
||||
<% if @course.time == 2008 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px; margin-left:20px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008' selected='selected'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
|
@ -94,12 +94,12 @@
|
|||
<option value = '2015'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table>
|
||||
</p>
|
||||
|
||||
<% elsif @course.time == 2009 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
</p>
|
||||
|
||||
<% elsif @course.time == 2009 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009' selected='selected'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
|
@ -109,11 +109,11 @@
|
|||
<option value = '2015'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.time == 2010 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
|
||||
<% elsif @course.time == 2010 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010' selected='selected'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
|
@ -123,11 +123,11 @@
|
|||
<option value = '2015'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.time == 2011 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
|
||||
<% elsif @course.time == 2011 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011' selected='selected'>2011</option>
|
||||
|
@ -137,12 +137,12 @@
|
|||
<option value = '2015'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
|
||||
<% elsif @course.time == 2012 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
|
||||
|
||||
<% elsif @course.time == 2012 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
|
@ -152,11 +152,11 @@
|
|||
<option value = '2015'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.time == 2013 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
|
||||
<% elsif @course.time == 2013 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
|
@ -165,67 +165,12 @@
|
|||
<option value = '2014'>2014</option>
|
||||
<option value = '2015'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.time == 2014 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
<option value = '2012'>2012</option>
|
||||
<option value = '2013'>2013</option>
|
||||
<option value = '2014' selected='selected'>2014</option>
|
||||
<option value = '2015'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.time == 2015 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
<option value = '2012'>2012</option>
|
||||
<option value = '2013'>2013</option>
|
||||
<option value = '2014'>2014</option>
|
||||
<option value = '2015' selected='selected'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.time == 2016 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
<option value = '2012'>2012</option>
|
||||
<option value = '2013'>2013</option>
|
||||
<option value = '2014'>2014</option>
|
||||
<option value = '2015'>2015</option>
|
||||
<option value = '2016' selected='selected'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.time == 2017 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
<option value = '2012'>2012</option>
|
||||
<option value = '2013'>2013</option>
|
||||
<option value = '2014'>2014</option>
|
||||
<option value = '2015'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017' selected='selected'>2017</option>".html_safe %></td></tr></table></p>
|
||||
<% else %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.time == 2014 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
|
@ -235,72 +180,136 @@
|
|||
<option value = '2015'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% unless @course.nil? %>
|
||||
<% if @course.term == l(:label_spring) %>
|
||||
<p><table><tr>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'term', "<option value = '#{l(:label_spring)}' selected='selected'>#{l(:label_spring)}</option>
|
||||
|
||||
<% elsif @course.time == 2015 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
<option value = '2012'>2012</option>
|
||||
<option value = '2013'>2013</option>
|
||||
<option value = '2014'>2014</option>
|
||||
<option value = '2015' selected='selected'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.time == 2016 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
<option value = '2012'>2012</option>
|
||||
<option value = '2013'>2013</option>
|
||||
<option value = '2014'>2014</option>
|
||||
<option value = '2015'>2015</option>
|
||||
<option value = '2016' selected='selected'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.time == 2017 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
<option value = '2012'>2012</option>
|
||||
<option value = '2013'>2013</option>
|
||||
<option value = '2014'>2014</option>
|
||||
<option value = '2015'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017' selected='selected'>2017</option>".html_safe %></td></tr></table></p>
|
||||
<% else %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'time', "<option value = '2008'>2008</option>
|
||||
<option value = '2009'>2009</option>
|
||||
<option value = '2010'>2010</option>
|
||||
<option value = '2011'>2011</option>
|
||||
<option value = '2012'>2012</option>
|
||||
<option value = '2013'>2013</option>
|
||||
<option value = '2014' selected='selected'>2014</option>
|
||||
<option value = '2015'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% unless @course.nil? %>
|
||||
<% if @course.term == l(:label_spring) %>
|
||||
<p><table><tr>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'term', "<option value = '#{l(:label_spring)}' selected='selected'>#{l(:label_spring)}</option>
|
||||
<option value = '#{l(:label_autumn)}'>#{l(:label_autumn)}</option>
|
||||
".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.term == l(:label_summer)%>
|
||||
<p><table><tr>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'term', "<option value = '#{l(:label_spring)}'>#{l(:label_spring)}</option>
|
||||
|
||||
<% elsif @course.term == l(:label_summer)%>
|
||||
<p><table><tr>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'term', "<option value = '#{l(:label_spring)}'>#{l(:label_spring)}</option>
|
||||
<option value = '#{l(:label_autumn)}'>#{l(:label_autumn)}</option>
|
||||
".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.term == l(:label_autumn)%>
|
||||
<p><table><tr>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'term', "<option value = '#{l(:label_spring)}'>#{l(:label_spring)}</option>
|
||||
|
||||
<% elsif @course.term == l(:label_autumn)%>
|
||||
<p><table><tr>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'term', "<option value = '#{l(:label_spring)}'>#{l(:label_spring)}</option>
|
||||
<option value = '#{l(:label_autumn)}' selected='selected'>#{l(:label_autumn)}</option>
|
||||
".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.term == l(:label_winter)%>
|
||||
<p><table><tr>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'term', "<option value = '#{l(:label_spring)}'>#{l(:label_spring)}</option>
|
||||
<option value = '#{l(:label_autumn)}'>#{l(:label_autumn)}</option>
|
||||
".html_safe %></td></tr></table></p>
|
||||
|
||||
<% else %>
|
||||
<p><table><tr>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'term', "<option value = '#{l(:label_spring)}'>#{l(:label_spring)}</option>
|
||||
<option value = '#{l(:label_autumn)}'>#{l(:label_autumn)}</option>
|
||||
".html_safe %></td></tr></table></p>
|
||||
|
||||
<% end %>
|
||||
|
||||
<% end %></td></tr></table>
|
||||
</p>
|
||||
<!-- end -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!--added by Wen -->
|
||||
|
||||
|
||||
<!-- end -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <p style="margin-left:-10px;"><%#= m.text_field :password, :required => true, :size => 60, :style => "width:488px;margin-left: 10px;" %></p> -->
|
||||
<p style="margin-left:-10px;"><label for="course[course]_password" style="font-size: 13px;" ><%=l(:label_new_course_password)%><span class="required"> *</span></label><input id="course_course_password" type="text" style="width:488px;margin-left: 10px;" value="<%=@course.password %>" size="60" name="course[password]"></p>
|
||||
<em class="info" style="margin-left:95px;"><%= l(:text_command) %></em>
|
||||
<% end %>
|
||||
|
||||
<% elsif @course.term == l(:label_winter)%>
|
||||
<p><table><tr>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'term', "<option value = '#{l(:label_spring)}'>#{l(:label_spring)}</option>
|
||||
<option value = '#{l(:label_autumn)}'>#{l(:label_autumn)}</option>
|
||||
".html_safe %></td></tr></table></p>
|
||||
|
||||
<% else %>
|
||||
<p><table><tr>
|
||||
<td class="info" style="width: 10px">
|
||||
<%= select_tag 'term', "<option value = '#{l(:label_spring)}'>#{l(:label_spring)}</option>
|
||||
<option value = '#{l(:label_autumn)}'>#{l(:label_autumn)}</option>
|
||||
".html_safe %></td></tr></table></p>
|
||||
|
||||
<% end %>
|
||||
|
||||
<% end %></td></tr></table>
|
||||
</p>
|
||||
<!-- end -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!--added by Wen -->
|
||||
|
||||
|
||||
<!-- end -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <p style="margin-left:-10px;"><%#= m.text_field :password, :required => true, :size => 60, :style => "width:488px;margin-left: 10px;" %></p> -->
|
||||
<p style="margin-left:-10px;"><label for="course[course]_password" style="font-size: 13px;" ><%=l(:label_new_course_password)%><span class="required"> *</span></label><input id="course_course_password" type="text" style="width:488px;margin-left: 10px;" value="<%=@course.password %>" size="60" name="course[password]"></p>
|
||||
<em class="info" style="margin-left:95px;"><%= l(:text_command) %></em>
|
||||
<% end %>
|
||||
|
||||
<!-- <p style="margin-left:-10px;padding-right: 20px;"><%#= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %></p> -->
|
||||
<p style="margin-left:-20px;padding-right: 20px;"><label for="course_description" style="font-size: 13px;"><%=l(:label_new_course_description)%></label><span class="jstEditor"><textarea id="course_description" class="wiki-edit" style="font-size:small;width:490px;margin-left:10px;" rows="8" name="course[description]" cols="40" ><%=@course.description%></textarea></span></p>
|
||||
<p style="padding-right: 20px;">
|
||||
<label for="course_description" style="font-size: 13px;">
|
||||
<%=l(:label_new_course_description)%>
|
||||
</label>
|
||||
<span class="jstEditor">
|
||||
<textarea id="course_description" class="wiki-edit" style="font-size:small;width:490px;margin-left:10px;" rows="8" name="course[description]" cols="40" >
|
||||
<%=@course.description%>
|
||||
</textarea>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
|
||||
<p style="margin-left:-10px;"><em style ="color: #888888;display: block;font-size: 90%;font-style: normal;"><%= f.check_box :is_public, :style => "margin-left:10px;" %><%= l(:label_course_public_info) %></em></p><!-- modified by bai -->
|
||||
|
@ -310,7 +319,7 @@
|
|||
<%= wikitoolbar_for 'course_description' %>
|
||||
|
||||
<% @course.custom_field_values.each do |value| %>
|
||||
<p><%= custom_field_tag_with_label :course, value %></p>
|
||||
<p><%= custom_field_tag_with_label :course, value %></p>
|
||||
<% end %>
|
||||
<%= call_hook(:view_courses_form, :course => @course, :form => f) %>
|
||||
|
||||
|
@ -319,8 +328,8 @@
|
|||
<!--[eoform:course]-->
|
||||
|
||||
<% unless @course.extra_frozen? %>
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag 'course_identifier' %>
|
||||
<% end %>
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag 'course_identifier' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
<% @nav_dispaly_course_all_label = 1
|
||||
@nav_dispaly_forum_label = 1
|
||||
@nav_dispaly_course_label = nil
|
||||
@nav_dispaly_store_all_label = 1 %>
|
||||
<% content_for :header_tags do %>
|
||||
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
|
||||
<% end %>
|
||||
|
@ -35,6 +39,8 @@
|
|||
<div id="courses-index">
|
||||
<%if @courses%>
|
||||
<%= render_course_hierarchy(@courses)%>
|
||||
<%#= render :partial => 'course', :locals => {:course => @courses.first}%>
|
||||
<%#= "<a herf = 'aaa'>hello</a>".html_safe %>
|
||||
<%end%>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
<%= labelled_form_for @course do |f| %>
|
||||
<% @nav_dispaly_course_all_label = 1
|
||||
@nav_dispaly_forum_label = 1
|
||||
@nav_dispaly_course_label = nil
|
||||
@nav_dispaly_store_all_label = 1 %>
|
||||
<h3><%=l(:label_course_new)%></h3>
|
||||
<%= labelled_form_for @course do |f| %>
|
||||
<div class="box tabular">
|
||||
<%= render :partial => 'course_form', :locals => { :f => f } %>
|
||||
<span style="padding-left: 60px"><%= submit_tag l(:button_create), :class => "enterprise"%></span>
|
||||
<!-- <%= submit_tag l(:button_create_and_continue), :name => 'course_continue' %> -->
|
||||
<!-- <%#= submit_tag l(:button_create_and_continue), :name => 'course_continue' %> -->
|
||||
<%= javascript_tag "$('#course_name').focus();" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
<p>
|
||||
<% roles.each do |role| %>
|
||||
<label><%= check_box_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
|
||||
<label><%= radio_button_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
|
||||
:disabled => member.member_roles.detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? } %> <%= h role %></label><br/>
|
||||
<% end %></p>
|
||||
<%= hidden_field_tag 'membership[role_ids][]', '' %>
|
||||
|
@ -82,7 +82,7 @@
|
|||
<p style="padding-top: 5px"><%= l(:label_role_plural) %>:
|
||||
<% roles.each do |role| %>
|
||||
|
||||
<label><%= check_box_tag 'membership[role_ids][]', role.id %> <%= h role %></label>
|
||||
<label><%= radio_button_tag 'membership[role_ids][]', role.id %> <%= h role %></label>
|
||||
<% end %></p>
|
||||
|
||||
<p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p>
|
||||
|
|
|
@ -58,39 +58,65 @@
|
|||
</div>
|
||||
|
||||
<% end -%>
|
||||
<% if (@events_pages.page == @events_pages.last_page) %>
|
||||
<div class="font_description">
|
||||
<table width="660">
|
||||
<tr>
|
||||
<td><%= image_tag(url_to_avatar(@user), :class => "avatar") %></td>
|
||||
<td colspan="2">
|
||||
<table width="580">
|
||||
<tr>
|
||||
<td>
|
||||
<% if @canShowRealName %>
|
||||
(<%= link_to_user(@user, @canShowRealName) %>
|
||||
)
|
||||
<% else %>
|
||||
<%= link_to_user(@user)%>
|
||||
<% end %>
|
||||
|
||||
<%= l(:label_user_create_project) %> <%= link_to @course.name %>
|
||||
<strong> !</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font_lighter" style="float: right"><%= l :label_create_time %>
|
||||
: <%= format_time(@course.created_at) %>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
</div>
|
||||
<%else%>
|
||||
<div class="font_description">
|
||||
<table width="660">
|
||||
<tr>
|
||||
<td><%= image_tag(url_to_avatar(@user), :class => "avatar") %></td>
|
||||
<td colspan="2">
|
||||
<table width="580">
|
||||
<tr>
|
||||
<td>
|
||||
<% if @canShowRealName %>
|
||||
(<%= link_to_user(@user, @canShowRealName) %>
|
||||
)
|
||||
<% else %>
|
||||
<%= link_to_user(@user)%>
|
||||
<% end %>
|
||||
|
||||
<%= l(:label_user_create_project) %> <%= link_to @course.name %>
|
||||
<strong> !</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font_lighter" style="float: right"><%= l :label_create_time %>
|
||||
: <%= format_time(@course.created_at) %>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="font_description">
|
||||
<table width="660">
|
||||
<tr>
|
||||
<td><%= image_tag(url_to_avatar(@user), :class => "avatar") %></td>
|
||||
<td colspan="2">
|
||||
<table width="580">
|
||||
<tr>
|
||||
<td>
|
||||
<%
|
||||
#判断是否显示真名
|
||||
if @canShowRealName
|
||||
%>
|
||||
<%= link_to (h @user.try(:name)), user_path(@user) if @user %>
|
||||
(<%= link_to (h @user.try(:realname)), user_path(@user) if @user %>)
|
||||
<% else %>
|
||||
<%= link_to (h @user.try(:name)), user_path(@user) if @user %>
|
||||
<% end %>
|
||||
<%= l(:label_user_create_project) %> <%= link_to @course.name %>
|
||||
<strong> !</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font_lighter" style="float: right"><%= l :label_create_time %>
|
||||
: <%= format_time(@course.created_at) %>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="pagination">
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
<% if @grouped.empty? %><p class="nodata"><%= l(:label_no_data) %></p><% end %>
|
||||
|
||||
<% @grouped.keys.sort.each do |group| %>
|
||||
<!-- <h3><%= group %></h3> -->
|
||||
<%= render :partial => 'documents/document', :collection => @grouped[group] %>
|
||||
<% end %>
|
||||
<!-- <h3><%= group %></h3> -->
|
||||
<%= render :partial => 'documents/document', :collection => @grouped[group] %>
|
||||
<% end %>
|
||||
|
||||
<% html_title(l(:label_document_plural)) -%>
|
||||
|
|
|
@ -11,20 +11,7 @@
|
|||
<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_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) %>
|
||||
|
||||
<% if attachmenttypes.any? %>
|
||||
|
||||
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
|
||||
<%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName"),
|
||||
:onchange => "course_attachmenttypes_searchex(this.value)" %>
|
||||
<% end %>
|
||||
<% if sufixtypes.any? %>
|
||||
|
||||
<label for="attach_sufix_browse_label"><%= l(:attachment_sufix_browse) %></label>
|
||||
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
|
||||
:onchange => "course_attachment_contenttypes_searchex(this.value)" %>
|
||||
<% end %>
|
||||
|
||||
<p></p>
|
||||
<div id="upload_file_div" class="relation_file_div hidden">
|
||||
<%= render :partial => 'course_new', locals: {course: @course} %>
|
||||
</div>
|
||||
|
@ -57,6 +44,21 @@
|
|||
<div class="line_under" style="margin:20px 0px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box" id="files-box">
|
||||
<label for="files-box" style="font-weight:bold;"> <%= l(:label_files_filter) %></label>
|
||||
<% if attachmenttypes.any? %>
|
||||
|
||||
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
|
||||
<%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName"),
|
||||
:onchange => "course_attachmenttypes_searchex(this.value)" %>
|
||||
<% end %>
|
||||
<% if sufixtypes.any? %>
|
||||
|
||||
<label for="attach_sufix_browse_label"><%= l(:attachment_sufix_browse) %></label>
|
||||
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
|
||||
:onchange => "course_attachment_contenttypes_searchex(this.value)" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:course_id => @course.id, :format => 'js') }')" %>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
||||
<% if file_dense_list.any? %>
|
||||
<div id="edit-file-dense-form-<%=attachment.id%>" class="hidden">
|
||||
<%= select_tag "file_dense",
|
||||
options_for_select(file_dense_list,attachment.file_dense_str), :onchange=>"file_dense_edit("+attachment.id.to_s + ",this.value)"%>
|
||||
</div>
|
||||
<%= link_to(image_tag('edit/edit.png'), 'javascript:void(0);',:style=>"white-space:nowrap;", :id=>"edit_box_dense"+attachment.id.to_s ,
|
||||
:onclick =>"$('#edit-file-dense-form-" +attachment.id.to_s+ "').show();
|
||||
$('#field_file_dense_id_label" +attachment.id.to_s+ "').hide();
|
||||
$('#edit_box_dense" +attachment.id.to_s+ "').hide();") if edit_allowed %>
|
||||
|
||||
<% end %>
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
|
||||
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
|
||||
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %>
|
||||
<%= sort_header_tag('field_file_dense', :caption => l(:field_file_dense), :default_order => 'desc', :scope => "col", :id => "vzebra-field_file_dense") %>
|
||||
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
|
||||
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
|
||||
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
|
||||
|
@ -34,6 +35,9 @@
|
|||
</tr>
|
||||
<% end -%>
|
||||
<% container.attachments.each do |file| %>
|
||||
<%if file.is_public == 0 && !User.current.member_of_course?(@course)%>
|
||||
<%next%>
|
||||
<%end%>
|
||||
<tr class="file <%= cycle("odd", "odd") %>">
|
||||
<td class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
|
||||
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
|
||||
|
@ -45,6 +49,14 @@
|
|||
</span>
|
||||
</td>
|
||||
<td class="content_type"><%= file.show_suffix_type %></td>
|
||||
<td class="field_file_dense">
|
||||
<span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span>
|
||||
|
||||
<span id="field_file_dense_id_edit<%= file.id %>" style="white-space:nowrap;">
|
||||
<%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
|
||||
:attachment => file} %>
|
||||
</span>
|
||||
</td>
|
||||
<td class="downloads"><%= file.downloads %></td>
|
||||
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
||||
<td align="center">
|
||||
|
|
|
@ -5,66 +5,78 @@
|
|||
<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
||||
<table class="list files" id="ver-zebra">
|
||||
<colgroup>
|
||||
<col class="vzebra-odd"/>
|
||||
<col class="vzebra-even"/>
|
||||
<col class="vzebra-odd"/>
|
||||
<col class="vzebra-even"/>
|
||||
<!-- <col class="vzebra-odd"/> -->
|
||||
</colgroup>
|
||||
<thead>
|
||||
<col class="vzebra-odd"/>
|
||||
<col class="vzebra-even"/>
|
||||
<col class="vzebra-odd"/>
|
||||
<col class="vzebra-even"/>
|
||||
<!-- <col class="vzebra-odd"/> -->
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %>
|
||||
<%#= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope => "col", :id => "vzebra-comedy") %>
|
||||
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
|
||||
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
|
||||
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%>
|
||||
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %>
|
||||
<%= sort_header_tag('field_file_dense', :caption => l(:field_file_dense), :default_order => 'desc', :scope => "col", :id => "vzebra-field_file_dense") %>
|
||||
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
|
||||
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
|
||||
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @containers.each do |container| %>
|
||||
<% next if container.attachments.empty? -%>
|
||||
<% container.attachments.each do |file| %>
|
||||
<% if isTypeOk(file,selAttachType,selContentType) %>
|
||||
<tr class="file <%= cycle("odd", "odd") %>">
|
||||
<td class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
|
||||
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
|
||||
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
||||
<td class="attach_type">
|
||||
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName %></span>
|
||||
|
||||
<% next if container.attachments.empty? -%>
|
||||
<% container.attachments.each do |file| %>
|
||||
<% if file.is_public == 0 && !User.current.member_of_course?(@course) %>
|
||||
<% next %>
|
||||
<% end %>
|
||||
<% if isTypeOk(file, selAttachType, selContentType) %>
|
||||
<tr class="file <%= cycle("odd", "odd") %>">
|
||||
<td class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
|
||||
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
|
||||
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
||||
<td class="attach_type">
|
||||
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName %></span>
|
||||
|
||||
<span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;">
|
||||
<%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes,
|
||||
:attachment => file,:contentype=>selContentType} %>
|
||||
:attachment => file, :contentype => selContentType} %>
|
||||
</span>
|
||||
</td>
|
||||
<td class="content_type"><%= file.show_suffix_type %></td>
|
||||
<td class="downloads"><%= file.downloads %></td>
|
||||
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
||||
<td align="center">
|
||||
<%= link_to(image_tag('delete.png'), attachment_path(file),
|
||||
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='description' colspan="6">
|
||||
<div class="tags_area">
|
||||
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
|
||||
<div class="tags_gradint"></div>
|
||||
</div>
|
||||
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<% reset_cycle %>
|
||||
<% end -%>
|
||||
<!-- %= h downloadAll(@containers) % -->
|
||||
<!-- %= link_to "download all file", (downloadAll(@containers)) % -->
|
||||
</td>
|
||||
<td class="content_type"><%= file.show_suffix_type %></td>
|
||||
<td class="field_file_dense">
|
||||
<span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span>
|
||||
|
||||
<span id="field_file_dense_id_edit<%= file.id %>" style="white-space:nowrap;">
|
||||
<%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
|
||||
:attachment => file} %>
|
||||
</span>
|
||||
</td>
|
||||
<td class="downloads"><%= file.downloads %></td>
|
||||
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
||||
<td align="center">
|
||||
<%= link_to(image_tag('delete.png'), attachment_path(file),
|
||||
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='description' colspan="6">
|
||||
<div class="tags_area">
|
||||
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
|
||||
<div class="tags_gradint"></div>
|
||||
</div>
|
||||
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<% reset_cycle %>
|
||||
<% end -%>
|
||||
<!-- %= h downloadAll(@containers) % -->
|
||||
<!-- %= link_to "download all file", (downloadAll(@containers)) % -->
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -11,19 +11,8 @@
|
|||
<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_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>
|
||||
|
||||
<% if attachmenttypes.any? %>
|
||||
|
||||
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
|
||||
<%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName"),
|
||||
:onchange => "attachmenttypes_searchex(this.value)" %>
|
||||
<% end %>
|
||||
<% if sufixtypes.any? %>
|
||||
|
||||
<label for="attach_sufix_browse_label"><%= l(:attachment_sufix_browse) %></label>
|
||||
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
|
||||
:onchange => "attachment_contenttypes_searchex(this.value)" %>
|
||||
<% end %>
|
||||
|
||||
<div id="upload_file_div" class="relation_file_div hidden">
|
||||
<%= render :partial => 'new', locals: {project: @project} %>
|
||||
|
@ -58,6 +47,21 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box" id="files-box">
|
||||
<label for="files-box" style="font-weight:bold;"> <%= l(:label_files_filter) %></label>
|
||||
<% if attachmenttypes.any? %>
|
||||
|
||||
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
|
||||
<%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName"),
|
||||
:onchange => "attachmenttypes_searchex(this.value)" %>
|
||||
<% end %>
|
||||
<% if sufixtypes.any? %>
|
||||
|
||||
<label for="attach_sufix_browse_label"><%= l(:attachment_sufix_browse) %></label>
|
||||
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
|
||||
:onchange => "attachment_contenttypes_searchex(this.value)" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:project_id => @project.id, :format => 'js') }')" %>
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
||||
<% if file_dense_list.any? %>
|
||||
<div id="edit-file-dense-form-<%=attachment.id%>" class="hidden">
|
||||
<%= select_tag "file_dense",
|
||||
options_for_select(file_dense_list,attachment.file_dense_str), :onchange=>"file_dense_edit("+attachment.id.to_s + ",this.value)"%>
|
||||
</div>
|
||||
<%= link_to(image_tag('edit/edit.png'), 'javascript:void(0);',:style=>"white-space:nowrap;", :id=>"edit_box_dense"+attachment.id.to_s ,
|
||||
:onclick =>"$('#edit-file-dense-form-" +attachment.id.to_s+ "').show();
|
||||
$('#field_file_dense_id_label" +attachment.id.to_s+ "').hide();
|
||||
$('#edit_box_dense" +attachment.id.to_s+ "').hide();") if edit_allowed %>
|
||||
|
||||
<% end %>
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
|
||||
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
|
||||
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %>
|
||||
<%= sort_header_tag('field_file_dense', :caption => l(:field_file_dense), :default_order => 'desc', :scope => "col", :id => "vzebra-field_file_dense") %>
|
||||
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
|
||||
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
|
||||
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
|
||||
|
@ -34,6 +35,9 @@
|
|||
</tr>
|
||||
<% end -%>
|
||||
<% container.attachments.each do |file| %>
|
||||
<%if file.is_public == 0 && !User.current.member_of?(@project)%>
|
||||
<%next%>
|
||||
<%end%>
|
||||
<tr class="file <%= cycle("odd", "odd") %>">
|
||||
<td class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
|
||||
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
|
||||
|
@ -45,6 +49,14 @@
|
|||
</span>
|
||||
</td>
|
||||
<td class="content_type"><%= file.show_suffix_type %></td>
|
||||
<td class="field_file_dense">
|
||||
<span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span>
|
||||
|
||||
<span id="field_file_dense_id_edit<%= file.id %>" style="white-space:nowrap;">
|
||||
<%= render :partial => 'project_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
|
||||
:attachment => file} %>
|
||||
</span>
|
||||
</td>
|
||||
<td class="downloads"><%= file.downloads %></td>
|
||||
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
||||
<td align="center">
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue