Merge branch 'master' into 442-mass_build
This commit is contained in:
commit
edcc0c996f
|
@ -14,3 +14,4 @@ public/downloads/*
|
|||
*.swp
|
||||
*.tmproj
|
||||
.sass-cache/
|
||||
dump.rdb
|
||||
|
|
28
Gemfile
28
Gemfile
|
@ -1,6 +1,6 @@
|
|||
source 'http://rubygems.org'
|
||||
|
||||
gem 'rails', '3.2.3' #, :git => 'git://github.com/rails/rails.git'
|
||||
gem 'rails', '3.2.6' #, :git => 'git://github.com/rails/rails.git'
|
||||
|
||||
gem 'pg', '~> 0.13.2'
|
||||
# gem 'silent-postgres', :git => 'git://github.com/dolzenko/silent-postgres.git' #'~> 0.1.1'
|
||||
|
@ -12,13 +12,15 @@ gem 'omniauth', '~> 1.0.3'
|
|||
gem 'omniauth-openid', '~> 1.0.1'
|
||||
gem 'cancan', '~> 1.6.7'
|
||||
|
||||
gem 'ancestry', '~> 1.2.5'
|
||||
gem 'paperclip', '~> 3.0.2'
|
||||
gem 'delayed_job_active_record', '~> 0.3.2'
|
||||
gem 'ancestry', '~> 1.3.0'
|
||||
gem 'paperclip', '~> 3.0.4'
|
||||
gem 'resque', '~> 1.20.0'
|
||||
gem 'resque-status', '~> 0.3.3'
|
||||
gem 'resque_mailer', '~> 2.1.0'
|
||||
gem 'perform_later', '~> 1.3.0' # should be after resque_mailer
|
||||
gem 'russian', '~> 0.6.0'
|
||||
gem 'highline', '~> 1.6.11'
|
||||
|
||||
gem 'jbuilder'
|
||||
gem 'state_machine'
|
||||
|
||||
# gem 'rugged', '~> 0.16.0'
|
||||
gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http'
|
||||
|
@ -35,11 +37,12 @@ gem 'rdiscount'
|
|||
gem 'RedCloth'
|
||||
gem 'wikicloth'
|
||||
|
||||
gem 'unicorn', '~> 4.2.1', :platforms => [:mri, :rbx]
|
||||
gem 'unicorn', '~> 4.3.1', :platforms => [:mri, :rbx]
|
||||
gem 'trinidad', '~> 1.0.2', :platforms => :jruby
|
||||
gem 'newrelic_rpm', '~> 3.3.3', :platforms => [:mri, :rbx]
|
||||
gem 'newrelic_rpm', '~> 3.3.5', :platforms => [:mri, :rbx]
|
||||
gem 'whenever', '~> 0.7.3', :require => false
|
||||
|
||||
gem 'jbuilder', '~> 0.4.0'
|
||||
gem 'rails3-jquery-autocomplete', '~> 1.0.7'
|
||||
gem 'will_paginate', '~> 3.0.3'
|
||||
gem 'meta-tags', '~> 1.2.5', :require => 'meta_tags'
|
||||
|
@ -51,16 +54,15 @@ gem 'rails-backbone', '~> 0.7.2'
|
|||
group :assets do
|
||||
gem 'sass-rails', '~> 3.2.5'
|
||||
gem 'coffee-rails', '~> 3.2.2'
|
||||
gem 'compass-rails', '~> 1.0.1'
|
||||
gem 'compass-rails', '~> 1.0.2'
|
||||
gem 'uglifier', '~> 1.2.4'
|
||||
gem 'therubyracer', '~> 0.10.1', :platforms => [:mri, :rbx]
|
||||
gem 'therubyrhino', '~> 1.73.1', :platforms => :jruby
|
||||
end
|
||||
|
||||
group :production do
|
||||
gem "airbrake", '~> 3.0.9'
|
||||
gem "airbrake", '~> 3.1.1'
|
||||
gem 'bluepill', '~> 0.0.60', :require => false
|
||||
gem 'daemons', '1.1.6' # Try to upgrade 1.1.8 to avoid tons DJ bugs?
|
||||
end
|
||||
|
||||
group :development do
|
||||
|
@ -76,8 +78,8 @@ group :development do
|
|||
end
|
||||
|
||||
group :test do
|
||||
gem 'rspec-rails', '~> 2.9.0', :group => 'development'
|
||||
gem 'factory_girl_rails', '~> 3.1.0'
|
||||
gem 'rspec-rails', '~> 2.10.1', :group => 'development'
|
||||
gem 'factory_girl_rails', '~> 3.4.0'
|
||||
gem 'rr', '~> 1.0.4'
|
||||
gem 'shoulda'
|
||||
end
|
||||
|
|
178
Gemfile.lock
178
Gemfile.lock
|
@ -25,40 +25,40 @@ GEM
|
|||
remote: http://rubygems.org/
|
||||
specs:
|
||||
RedCloth (4.2.9)
|
||||
actionmailer (3.2.3)
|
||||
actionpack (= 3.2.3)
|
||||
actionmailer (3.2.6)
|
||||
actionpack (= 3.2.6)
|
||||
mail (~> 2.4.4)
|
||||
actionpack (3.2.3)
|
||||
activemodel (= 3.2.3)
|
||||
activesupport (= 3.2.3)
|
||||
actionpack (3.2.6)
|
||||
activemodel (= 3.2.6)
|
||||
activesupport (= 3.2.6)
|
||||
builder (~> 3.0.0)
|
||||
erubis (~> 2.7.0)
|
||||
journey (~> 1.0.1)
|
||||
rack (~> 1.4.0)
|
||||
rack-cache (~> 1.2)
|
||||
rack-test (~> 0.6.1)
|
||||
sprockets (~> 2.1.2)
|
||||
activemodel (3.2.3)
|
||||
activesupport (= 3.2.3)
|
||||
sprockets (~> 2.1.3)
|
||||
activemodel (3.2.6)
|
||||
activesupport (= 3.2.6)
|
||||
builder (~> 3.0.0)
|
||||
activerecord (3.2.3)
|
||||
activemodel (= 3.2.3)
|
||||
activesupport (= 3.2.3)
|
||||
activerecord (3.2.6)
|
||||
activemodel (= 3.2.6)
|
||||
activesupport (= 3.2.6)
|
||||
arel (~> 3.0.2)
|
||||
tzinfo (~> 0.3.29)
|
||||
activeresource (3.2.3)
|
||||
activemodel (= 3.2.3)
|
||||
activesupport (= 3.2.3)
|
||||
activesupport (3.2.3)
|
||||
activeresource (3.2.6)
|
||||
activemodel (= 3.2.6)
|
||||
activesupport (= 3.2.6)
|
||||
activesupport (3.2.6)
|
||||
i18n (~> 0.6)
|
||||
multi_json (~> 1.0)
|
||||
airbrake (3.0.9)
|
||||
airbrake (3.1.1)
|
||||
activesupport
|
||||
builder
|
||||
albino (1.3.3)
|
||||
posix-spawn (>= 0.3.6)
|
||||
ancestry (1.2.5)
|
||||
activerecord (>= 2.2.2)
|
||||
ancestry (1.3.0)
|
||||
activerecord (>= 2.3.14)
|
||||
arel (3.0.2)
|
||||
bcrypt-ruby (3.0.1)
|
||||
blankslate (2.1.2.4)
|
||||
|
@ -87,20 +87,15 @@ GEM
|
|||
coffee-script (2.2.0)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.3.1)
|
||||
coffee-script-source (1.3.3)
|
||||
compass (0.12.1)
|
||||
chunky_png (~> 1.2)
|
||||
fssm (>= 0.2.7)
|
||||
sass (~> 3.1)
|
||||
compass-rails (1.0.1)
|
||||
compass (~> 0.12.0)
|
||||
compass-rails (1.0.2)
|
||||
compass (>= 0.12.0, < 0.14)
|
||||
creole (0.4.2)
|
||||
daemons (1.1.6)
|
||||
delayed_job (3.0.2)
|
||||
activesupport (~> 3.0)
|
||||
delayed_job_active_record (0.3.2)
|
||||
activerecord (> 2.1.0)
|
||||
delayed_job (~> 3.0.0)
|
||||
devise (2.0.4)
|
||||
bcrypt-ruby (~> 3.0)
|
||||
orm_adapter (~> 0.0.3)
|
||||
|
@ -111,13 +106,13 @@ GEM
|
|||
ejs (1.0.0)
|
||||
erubis (2.7.0)
|
||||
eventmachine (0.12.10)
|
||||
execjs (1.3.0)
|
||||
execjs (1.4.0)
|
||||
multi_json (~> 1.0)
|
||||
expression_parser (0.9.0)
|
||||
factory_girl (3.1.1)
|
||||
factory_girl (3.4.0)
|
||||
activesupport (>= 3.0.0)
|
||||
factory_girl_rails (3.1.0)
|
||||
factory_girl (~> 3.1.0)
|
||||
factory_girl_rails (3.4.0)
|
||||
factory_girl (~> 3.4.0)
|
||||
railties (>= 3.0.0)
|
||||
fssm (0.2.9)
|
||||
github-markup (0.7.2)
|
||||
|
@ -130,14 +125,14 @@ GEM
|
|||
redcarpet
|
||||
sanitize (~> 2.0.0)
|
||||
sinatra (~> 1.0)
|
||||
haml (3.1.4)
|
||||
haml (3.1.6)
|
||||
haml-rails (0.3.4)
|
||||
actionpack (~> 3.0)
|
||||
activesupport (~> 3.0)
|
||||
haml (~> 3.0)
|
||||
railties (~> 3.0)
|
||||
hashie (1.2.0)
|
||||
highline (1.6.11)
|
||||
highline (1.6.12)
|
||||
hike (1.2.1)
|
||||
hirb (0.6.2)
|
||||
i18n (0.6.0)
|
||||
|
@ -148,9 +143,11 @@ GEM
|
|||
jquery-rails (2.0.2)
|
||||
railties (>= 3.2.0, < 5.0)
|
||||
thor (~> 0.14)
|
||||
json (1.6.6)
|
||||
json (1.7.3)
|
||||
kgio (2.7.4)
|
||||
libv8 (3.3.10.4)
|
||||
macaddr (1.6.1)
|
||||
systemu (~> 2.5.0)
|
||||
mail (2.4.4)
|
||||
i18n (>= 0.4.0)
|
||||
mime-types (~> 1.16)
|
||||
|
@ -167,17 +164,17 @@ GEM
|
|||
meta-tags (1.2.6)
|
||||
actionpack
|
||||
mime-types (1.18)
|
||||
multi_json (1.3.2)
|
||||
multi_json (1.3.6)
|
||||
mustache (0.99.4)
|
||||
net-scp (1.0.4)
|
||||
net-ssh (>= 1.99.1)
|
||||
net-sftp (2.0.5)
|
||||
net-ssh (>= 2.0.9)
|
||||
net-ssh (2.3.0)
|
||||
net-ssh (2.5.2)
|
||||
net-ssh-gateway (1.1.0)
|
||||
net-ssh (>= 1.99.1)
|
||||
newrelic_rpm (3.3.4)
|
||||
nokogiri (1.5.2)
|
||||
newrelic_rpm (3.3.5)
|
||||
nokogiri (1.5.4)
|
||||
omniauth (1.0.3)
|
||||
hashie (~> 1.2)
|
||||
rack
|
||||
|
@ -185,12 +182,16 @@ GEM
|
|||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
orm_adapter (0.0.7)
|
||||
paperclip (3.0.2)
|
||||
paperclip (3.0.4)
|
||||
activemodel (>= 3.0.0)
|
||||
activerecord (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
cocaine (>= 0.0.2)
|
||||
mime-types
|
||||
perform_later (1.3.0)
|
||||
rails (~> 3.0)
|
||||
redis
|
||||
resque
|
||||
pg (0.13.2)
|
||||
polyglot (0.3.3)
|
||||
posix-spawn (0.3.6)
|
||||
|
@ -206,14 +207,14 @@ GEM
|
|||
rack
|
||||
rack-test (0.6.1)
|
||||
rack (>= 1.0)
|
||||
rails (3.2.3)
|
||||
actionmailer (= 3.2.3)
|
||||
actionpack (= 3.2.3)
|
||||
activerecord (= 3.2.3)
|
||||
activeresource (= 3.2.3)
|
||||
activesupport (= 3.2.3)
|
||||
rails (3.2.6)
|
||||
actionmailer (= 3.2.6)
|
||||
actionpack (= 3.2.6)
|
||||
activerecord (= 3.2.6)
|
||||
activeresource (= 3.2.6)
|
||||
activesupport (= 3.2.6)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.2.3)
|
||||
railties (= 3.2.6)
|
||||
rails-backbone (0.7.2)
|
||||
coffee-script (~> 2.2.0)
|
||||
ejs (~> 1.0.0)
|
||||
|
@ -222,44 +223,61 @@ GEM
|
|||
railties (>= 3.0.0)
|
||||
rails3-jquery-autocomplete (1.0.7)
|
||||
rails (~> 3.0)
|
||||
railties (3.2.3)
|
||||
actionpack (= 3.2.3)
|
||||
activesupport (= 3.2.3)
|
||||
railties (3.2.6)
|
||||
actionpack (= 3.2.6)
|
||||
activesupport (= 3.2.6)
|
||||
rack-ssl (~> 1.3.2)
|
||||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
thor (~> 0.14.6)
|
||||
raindrops (0.8.0)
|
||||
thor (>= 0.14.6, < 2.0)
|
||||
raindrops (0.9.0)
|
||||
rake (0.9.2.2)
|
||||
rdiscount (1.6.8)
|
||||
rdoc (3.12)
|
||||
json (~> 1.4)
|
||||
redcarpet (1.17.2)
|
||||
redis (2.2.2)
|
||||
redis-namespace (1.0.3)
|
||||
redis (< 3.0.0)
|
||||
redisk (0.2.2)
|
||||
redis (>= 0.1.1)
|
||||
redis-namespace (>= 0.1.0)
|
||||
resque (1.20.0)
|
||||
multi_json (~> 1.0)
|
||||
redis-namespace (~> 1.0.2)
|
||||
sinatra (>= 0.9.2)
|
||||
vegas (~> 0.1.2)
|
||||
resque-status (0.3.3)
|
||||
redisk (>= 0.2.1)
|
||||
resque (~> 1.19)
|
||||
uuid (~> 2.3)
|
||||
resque_mailer (2.1.0)
|
||||
actionmailer (~> 3.0)
|
||||
rr (1.0.4)
|
||||
rspec (2.9.0)
|
||||
rspec-core (~> 2.9.0)
|
||||
rspec-expectations (~> 2.9.0)
|
||||
rspec-mocks (~> 2.9.0)
|
||||
rspec-core (2.9.0)
|
||||
rspec-expectations (2.9.1)
|
||||
rspec (2.10.0)
|
||||
rspec-core (~> 2.10.0)
|
||||
rspec-expectations (~> 2.10.0)
|
||||
rspec-mocks (~> 2.10.0)
|
||||
rspec-core (2.10.1)
|
||||
rspec-expectations (2.10.0)
|
||||
diff-lcs (~> 1.1.3)
|
||||
rspec-mocks (2.9.0)
|
||||
rspec-rails (2.9.0)
|
||||
rspec-mocks (2.10.1)
|
||||
rspec-rails (2.10.1)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec (~> 2.9.0)
|
||||
rspec (~> 2.10.0)
|
||||
ruby-haml-js (0.0.3)
|
||||
execjs
|
||||
sprockets (>= 2.0.0)
|
||||
ruby-openid (2.1.8)
|
||||
russian (0.6.0)
|
||||
i18n (>= 0.5.0)
|
||||
rvm-capistrano (1.1.0)
|
||||
rvm-capistrano (1.2.2)
|
||||
capistrano (>= 2.0.0)
|
||||
sanitize (2.0.3)
|
||||
nokogiri (>= 1.4.4, < 1.6)
|
||||
sass (3.1.16)
|
||||
sass (3.1.19)
|
||||
sass-rails (3.2.5)
|
||||
railties (~> 3.2.0)
|
||||
sass (>= 3.1.10)
|
||||
|
@ -278,19 +296,20 @@ GEM
|
|||
skinny (0.2.0)
|
||||
eventmachine (~> 0.12)
|
||||
thin (~> 1.2)
|
||||
sprockets (2.1.2)
|
||||
sprockets (2.1.3)
|
||||
hike (~> 1.2)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sqlite3 (1.3.6)
|
||||
state_machine (1.1.2)
|
||||
systemu (2.5.1)
|
||||
therubyracer (0.10.1)
|
||||
libv8 (~> 3.3.10)
|
||||
thin (1.3.1)
|
||||
daemons (>= 1.0.9)
|
||||
eventmachine (>= 0.12.6)
|
||||
rack (>= 1.0.0)
|
||||
thor (0.14.6)
|
||||
thor (0.15.2)
|
||||
tilt (1.3.3)
|
||||
treetop (1.4.10)
|
||||
polyglot
|
||||
|
@ -299,10 +318,14 @@ GEM
|
|||
uglifier (1.2.4)
|
||||
execjs (>= 0.3.0)
|
||||
multi_json (>= 1.0.2)
|
||||
unicorn (4.2.1)
|
||||
unicorn (4.3.1)
|
||||
kgio (~> 2.6)
|
||||
rack
|
||||
raindrops (~> 0.7)
|
||||
uuid (2.3.5)
|
||||
macaddr (~> 1.0)
|
||||
vegas (0.1.11)
|
||||
rack (>= 1.0.0)
|
||||
warden (1.1.1)
|
||||
rack (>= 1.0)
|
||||
whenever (0.7.3)
|
||||
|
@ -318,8 +341,8 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
RedCloth
|
||||
airbrake (~> 3.0.9)
|
||||
ancestry (~> 1.2.5)
|
||||
airbrake (~> 3.1.1)
|
||||
ancestry (~> 1.3.0)
|
||||
bluepill (~> 0.0.60)
|
||||
cancan (~> 1.6.7)
|
||||
cape
|
||||
|
@ -327,48 +350,51 @@ DEPENDENCIES
|
|||
capistrano_colors
|
||||
charlock_holmes (~> 0.6.8)
|
||||
coffee-rails (~> 3.2.2)
|
||||
compass-rails (~> 1.0.1)
|
||||
compass-rails (~> 1.0.2)
|
||||
creole
|
||||
daemons (= 1.1.6)
|
||||
delayed_job_active_record (~> 0.3.2)
|
||||
devise (~> 2.0.4)
|
||||
diff-display (~> 0.0.1)
|
||||
factory_girl_rails (~> 3.1.0)
|
||||
factory_girl_rails (~> 3.4.0)
|
||||
gollum (= 1.3.1)
|
||||
grack!
|
||||
grit!
|
||||
haml-rails (~> 0.3.4)
|
||||
highline (~> 1.6.11)
|
||||
hirb
|
||||
jbuilder
|
||||
jbuilder (~> 0.4.0)
|
||||
jquery-rails (~> 2.0.2)
|
||||
mailcatcher
|
||||
meta-tags (~> 1.2.5)
|
||||
newrelic_rpm (~> 3.3.3)
|
||||
newrelic_rpm (~> 3.3.5)
|
||||
omniauth (~> 1.0.3)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
paperclip (~> 3.0.2)
|
||||
paperclip (~> 3.0.4)
|
||||
perform_later (~> 1.3.0)
|
||||
pg (~> 0.13.2)
|
||||
rails (= 3.2.3)
|
||||
rails (= 3.2.6)
|
||||
rails-backbone (~> 0.7.2)
|
||||
rails3-generators
|
||||
rails3-jquery-autocomplete (~> 1.0.7)
|
||||
rdiscount
|
||||
redcarpet (= 1.17.2)
|
||||
redhillonrails_core!
|
||||
resque (~> 1.20.0)
|
||||
resque-status (~> 0.3.3)
|
||||
resque_mailer (~> 2.1.0)
|
||||
rr (~> 1.0.4)
|
||||
rspec-rails (~> 2.9.0)
|
||||
rspec-rails (~> 2.10.1)
|
||||
ruby-haml-js (~> 0.0.3)
|
||||
russian (~> 0.6.0)
|
||||
rvm-capistrano
|
||||
sass-rails (~> 3.2.5)
|
||||
shotgun
|
||||
shoulda
|
||||
state_machine
|
||||
therubyracer (~> 0.10.1)
|
||||
therubyrhino (~> 1.73.1)
|
||||
trinidad (~> 1.0.2)
|
||||
uglifier (~> 1.2.4)
|
||||
unicorn (~> 4.2.1)
|
||||
unicorn (~> 4.3.1)
|
||||
whenever (~> 0.7.3)
|
||||
wikicloth
|
||||
will_paginate (~> 3.0.3)
|
||||
|
|
6
Rakefile
6
Rakefile
|
@ -3,5 +3,11 @@
|
|||
|
||||
require File.expand_path('../config/application', __FILE__)
|
||||
require 'rake'
|
||||
require 'resque/tasks'
|
||||
|
||||
# This fixes connection fail with Postgres server on new fork:
|
||||
task "resque:setup" => :environment do
|
||||
Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
|
||||
end
|
||||
|
||||
Rosa::Application.load_tasks
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
//= require autocomplete-rails
|
||||
//= require vendor
|
||||
//= require jquery.dataTables_ext
|
||||
//= require_tree ./lib
|
||||
//= require lib/lib
|
||||
//= require_tree ./design
|
||||
//= require_tree ./extra
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
Rosa.Models.Advisory = Backbone.Model.extend({
|
||||
defaults: {
|
||||
id: null,
|
||||
description: null,
|
||||
references: null,
|
||||
update_type: null
|
||||
}
|
||||
});
|
||||
|
||||
Rosa.Collections.AdvisoriesCollection = Backbone.Collection.extend({
|
||||
model: Rosa.Models.Advisory
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
Rosa.Routers.BuildListsAdvisoriesRouter = Backbone.Router.extend({
|
||||
routes: {},
|
||||
|
||||
initialize: function() {
|
||||
this.advisoriesCollection = new Rosa.Collections.AdvisoriesCollection(Rosa.bootstrapedData.advisories);
|
||||
this.advisoriesView = new Rosa.Views.BuildListAdvisoriesView({ collection: this.advisoriesCollection });
|
||||
|
||||
this.advisoriesView.render();
|
||||
}
|
||||
});
|
|
@ -0,0 +1,87 @@
|
|||
Rosa.Views.BuildListAdvisoriesView = Backbone.View.extend({
|
||||
initialize: function() {
|
||||
_.bindAll(this, 'popoverTitle', 'popoverDesc', 'showAdvisory',
|
||||
'changeAdvisoryList', 'showPreview', 'showForm', 'hideAll');
|
||||
this.$el = $('#advisory_block');
|
||||
this._$form = this.$('#new_advisory_form');
|
||||
this._$preview = this.$('#advisory_preview');
|
||||
this._$type_select = $('#build_list_update_type');
|
||||
this._$selector = this.$('#attach_advisory');
|
||||
|
||||
this._$selector.on('change', this.showAdvisory);
|
||||
this._$type_select.on('change', this.changeAdvisoryList);
|
||||
},
|
||||
|
||||
changeAdvisoryList: function() {
|
||||
this._$selector.children('.popoverable').hide();
|
||||
this._$selector.children('.popoverable.' + this._$type_select.val()).show();
|
||||
this._$selector.val('no').trigger('change');
|
||||
},
|
||||
|
||||
popoverTitle: function(el) {
|
||||
return el.val();
|
||||
},
|
||||
|
||||
popoverDesc: function(el) {
|
||||
return this.collection.get(el.val()).get('popover_desc');
|
||||
},
|
||||
|
||||
showAdvisory: function(el) {
|
||||
var adv_id = this._$selector.val();
|
||||
switch (adv_id) {
|
||||
case 'no':
|
||||
this.hideAll();
|
||||
break
|
||||
case 'new':
|
||||
this.showForm();
|
||||
break
|
||||
default:
|
||||
this.showPreview(adv_id);
|
||||
}
|
||||
},
|
||||
|
||||
showPreview: function(id) {
|
||||
if (this._$form.is(':visible')) {
|
||||
this._$form.slideUp();
|
||||
}
|
||||
var adv = this.collection.get(id);
|
||||
var prev = this._$preview;
|
||||
prev.children('h3').html(prev.children('h3').html() + ' ' + adv.get('advisory_id'));
|
||||
prev.children('.descr').html(adv.get('description'));
|
||||
prev.children('.refs').html(adv.get('references'));
|
||||
if (!this._$preview.is(':visible')) {
|
||||
this._$preview.slideDown();
|
||||
}
|
||||
},
|
||||
|
||||
showForm: function() {
|
||||
if (this._$preview.is(':visible')) {
|
||||
this._$preview.slideUp();
|
||||
}
|
||||
if (!this._$form.is(':visible')) {
|
||||
this._$form.slideDown();
|
||||
}
|
||||
},
|
||||
|
||||
hideAll: function() {
|
||||
if (this._$preview.is(':visible')) {
|
||||
this._$preview.slideUp();
|
||||
}
|
||||
if (this._$form.is(':visible')) {
|
||||
this._$form.slideUp();
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var title = this.popoverTitle;
|
||||
var description = this.popoverDesc;
|
||||
this.changeAdvisoryList();
|
||||
this.$('#attach_advisory > .popoverable').popover({
|
||||
title: function() { return title($(this)); },
|
||||
content: function() { return description($(this)); }
|
||||
});
|
||||
this.showAdvisory();
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
|
@ -71,7 +71,7 @@ function setBranchSelected() {
|
|||
var pl_id = $('#build_list_save_to_platform_id').val();
|
||||
// Checks if selected platform is main or not:
|
||||
if ( $('.all_platforms').find('input[type="checkbox"][value=' + pl_id + '].build_bpl_ids').size() > 0 ) {
|
||||
var pl_name = $('#build_list_save_to_platform_id option[value="' + pl_id + '"]').text().match(/([\w-]+)\/[\w-]+/)[1];
|
||||
var pl_name = $('#build_list_save_to_platform_id option[value="' + pl_id + '"]').text().match(/([\w-.]+)\/[\w-.]+/)[1];
|
||||
var branch_pl_opt = $('#build_list_project_version option[value="latest_' + pl_name + '"]');
|
||||
// If there is branch we need - set it selected:
|
||||
if ( branch_pl_opt.size() > 0 ) {
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
/* ===========================================================
|
||||
* bootstrap-popover.js v2.0.4
|
||||
* http://twitter.github.com/bootstrap/javascript.html#popovers
|
||||
* ===========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* =========================================================== */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* POPOVER PUBLIC CLASS DEFINITION
|
||||
* =============================== */
|
||||
|
||||
var Popover = function ( element, options ) {
|
||||
this.init('popover', element, options)
|
||||
}
|
||||
|
||||
|
||||
/* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
|
||||
========================================== */
|
||||
|
||||
Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
|
||||
|
||||
constructor: Popover
|
||||
|
||||
, setContent: function () {
|
||||
var $tip = this.tip()
|
||||
, title = this.getTitle()
|
||||
, content = this.getContent()
|
||||
|
||||
$tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
|
||||
$tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
|
||||
|
||||
$tip.removeClass('fade top bottom left right in')
|
||||
}
|
||||
|
||||
, hasContent: function () {
|
||||
return this.getTitle() || this.getContent()
|
||||
}
|
||||
|
||||
, getContent: function () {
|
||||
var content
|
||||
, $e = this.$element
|
||||
, o = this.options
|
||||
|
||||
content = $e.attr('data-content')
|
||||
|| (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
|
||||
|
||||
return content
|
||||
}
|
||||
|
||||
, tip: function () {
|
||||
if (!this.$tip) {
|
||||
this.$tip = $(this.options.template)
|
||||
}
|
||||
return this.$tip
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
/* POPOVER PLUGIN DEFINITION
|
||||
* ======================= */
|
||||
|
||||
$.fn.popover = function (option) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('popover')
|
||||
, options = typeof option == 'object' && option
|
||||
if (!data) $this.data('popover', (data = new Popover(this, options)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.popover.Constructor = Popover
|
||||
|
||||
$.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
|
||||
placement: 'right'
|
||||
, content: ''
|
||||
, template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
|
||||
})
|
||||
|
||||
}(window.jQuery);
|
|
@ -0,0 +1,275 @@
|
|||
/* ===========================================================
|
||||
* bootstrap-tooltip.js v2.0.4
|
||||
* http://twitter.github.com/bootstrap/javascript.html#tooltips
|
||||
* Inspired by the original jQuery.tipsy by Jason Frame
|
||||
* ===========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ========================================================== */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* TOOLTIP PUBLIC CLASS DEFINITION
|
||||
* =============================== */
|
||||
|
||||
var Tooltip = function (element, options) {
|
||||
this.init('tooltip', element, options)
|
||||
}
|
||||
|
||||
Tooltip.prototype = {
|
||||
|
||||
constructor: Tooltip
|
||||
|
||||
, init: function (type, element, options) {
|
||||
var eventIn
|
||||
, eventOut
|
||||
|
||||
this.type = type
|
||||
this.$element = $(element)
|
||||
this.options = this.getOptions(options)
|
||||
this.enabled = true
|
||||
|
||||
if (this.options.trigger != 'manual') {
|
||||
eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
|
||||
eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
|
||||
this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this))
|
||||
this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this))
|
||||
}
|
||||
|
||||
this.options.selector ?
|
||||
(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
|
||||
this.fixTitle()
|
||||
}
|
||||
|
||||
, getOptions: function (options) {
|
||||
options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
|
||||
|
||||
if (options.delay && typeof options.delay == 'number') {
|
||||
options.delay = {
|
||||
show: options.delay
|
||||
, hide: options.delay
|
||||
}
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
, enter: function (e) {
|
||||
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
|
||||
|
||||
if (!self.options.delay || !self.options.delay.show) return self.show()
|
||||
|
||||
clearTimeout(this.timeout)
|
||||
self.hoverState = 'in'
|
||||
this.timeout = setTimeout(function() {
|
||||
if (self.hoverState == 'in') self.show()
|
||||
}, self.options.delay.show)
|
||||
}
|
||||
|
||||
, leave: function (e) {
|
||||
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
|
||||
|
||||
if (this.timeout) clearTimeout(this.timeout)
|
||||
if (!self.options.delay || !self.options.delay.hide) return self.hide()
|
||||
|
||||
self.hoverState = 'out'
|
||||
this.timeout = setTimeout(function() {
|
||||
if (self.hoverState == 'out') self.hide()
|
||||
}, self.options.delay.hide)
|
||||
}
|
||||
|
||||
, show: function () {
|
||||
var $tip
|
||||
, inside
|
||||
, pos
|
||||
, actualWidth
|
||||
, actualHeight
|
||||
, placement
|
||||
, tp
|
||||
|
||||
if (this.hasContent() && this.enabled) {
|
||||
$tip = this.tip()
|
||||
this.setContent()
|
||||
|
||||
if (this.options.animation) {
|
||||
$tip.addClass('fade')
|
||||
}
|
||||
|
||||
placement = typeof this.options.placement == 'function' ?
|
||||
this.options.placement.call(this, $tip[0], this.$element[0]) :
|
||||
this.options.placement
|
||||
|
||||
inside = /in/.test(placement)
|
||||
|
||||
$tip
|
||||
.remove()
|
||||
.css({ top: 0, left: 0, display: 'block' })
|
||||
.appendTo(inside ? this.$element : document.body)
|
||||
|
||||
pos = this.getPosition(inside)
|
||||
|
||||
actualWidth = $tip[0].offsetWidth
|
||||
actualHeight = $tip[0].offsetHeight
|
||||
|
||||
switch (inside ? placement.split(' ')[1] : placement) {
|
||||
case 'bottom':
|
||||
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
|
||||
break
|
||||
case 'top':
|
||||
tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
|
||||
break
|
||||
case 'left':
|
||||
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
|
||||
break
|
||||
case 'right':
|
||||
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
|
||||
break
|
||||
}
|
||||
|
||||
$tip
|
||||
.css(tp)
|
||||
.addClass(placement)
|
||||
.addClass('in')
|
||||
}
|
||||
}
|
||||
|
||||
, isHTML: function(text) {
|
||||
// html string detection logic adapted from jQuery
|
||||
return typeof text != 'string'
|
||||
|| ( text.charAt(0) === "<"
|
||||
&& text.charAt( text.length - 1 ) === ">"
|
||||
&& text.length >= 3
|
||||
) || /^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(text)
|
||||
}
|
||||
|
||||
, setContent: function () {
|
||||
var $tip = this.tip()
|
||||
, title = this.getTitle()
|
||||
|
||||
$tip.find('.tooltip-inner')[this.isHTML(title) ? 'html' : 'text'](title)
|
||||
$tip.removeClass('fade in top bottom left right')
|
||||
}
|
||||
|
||||
, hide: function () {
|
||||
var that = this
|
||||
, $tip = this.tip()
|
||||
|
||||
$tip.removeClass('in')
|
||||
|
||||
function removeWithAnimation() {
|
||||
var timeout = setTimeout(function () {
|
||||
$tip.off($.support.transition.end).remove()
|
||||
}, 500)
|
||||
|
||||
$tip.one($.support.transition.end, function () {
|
||||
clearTimeout(timeout)
|
||||
$tip.remove()
|
||||
})
|
||||
}
|
||||
|
||||
$.support.transition && this.$tip.hasClass('fade') ?
|
||||
removeWithAnimation() :
|
||||
$tip.remove()
|
||||
}
|
||||
|
||||
, fixTitle: function () {
|
||||
var $e = this.$element
|
||||
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
|
||||
$e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
|
||||
}
|
||||
}
|
||||
|
||||
, hasContent: function () {
|
||||
return this.getTitle()
|
||||
}
|
||||
|
||||
, getPosition: function (inside) {
|
||||
return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
|
||||
width: this.$element[0].offsetWidth
|
||||
, height: this.$element[0].offsetHeight
|
||||
})
|
||||
}
|
||||
|
||||
, getTitle: function () {
|
||||
var title
|
||||
, $e = this.$element
|
||||
, o = this.options
|
||||
|
||||
title = $e.attr('data-original-title')
|
||||
|| (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
|
||||
|
||||
return title
|
||||
}
|
||||
|
||||
, tip: function () {
|
||||
return this.$tip = this.$tip || $(this.options.template)
|
||||
}
|
||||
|
||||
, validate: function () {
|
||||
if (!this.$element[0].parentNode) {
|
||||
this.hide()
|
||||
this.$element = null
|
||||
this.options = null
|
||||
}
|
||||
}
|
||||
|
||||
, enable: function () {
|
||||
this.enabled = true
|
||||
}
|
||||
|
||||
, disable: function () {
|
||||
this.enabled = false
|
||||
}
|
||||
|
||||
, toggleEnabled: function () {
|
||||
this.enabled = !this.enabled
|
||||
}
|
||||
|
||||
, toggle: function () {
|
||||
this[this.tip().hasClass('in') ? 'hide' : 'show']()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* TOOLTIP PLUGIN DEFINITION
|
||||
* ========================= */
|
||||
|
||||
$.fn.tooltip = function ( option ) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('tooltip')
|
||||
, options = typeof option == 'object' && option
|
||||
if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.tooltip.Constructor = Tooltip
|
||||
|
||||
$.fn.tooltip.defaults = {
|
||||
animation: true
|
||||
, placement: 'top'
|
||||
, selector: false
|
||||
, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
|
||||
, trigger: 'hover'
|
||||
, title: ''
|
||||
, delay: 0
|
||||
}
|
||||
|
||||
}(window.jQuery);
|
|
@ -0,0 +1,3 @@
|
|||
//= require ./jquery.placeholder
|
||||
//= require ./bootstrap-tooltip
|
||||
//= require ./bootstrap-popover
|
|
@ -954,6 +954,121 @@ form.mass_build input[type="checkbox"] {
|
|||
height: 11px;
|
||||
}
|
||||
|
||||
div#new_advisory_form, div#advisory_preview {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/*=============== popovers ===============*/
|
||||
|
||||
.popover {
|
||||
display: none;
|
||||
left: 0;
|
||||
padding: 5px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
z-index: 1010;
|
||||
}
|
||||
|
||||
.popover.top {
|
||||
margin-top: -5px;
|
||||
}
|
||||
|
||||
.popover.right {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.popover.bottom {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.popover.left {
|
||||
margin-left: -5px;
|
||||
}
|
||||
|
||||
.popover.top .arrow {
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
border-top: 5px solid #000000;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
margin-left: -5px;
|
||||
}
|
||||
|
||||
.popover.right .arrow {
|
||||
border-bottom: 5px solid transparent;
|
||||
border-right: 5px solid #000000;
|
||||
border-top: 5px solid transparent;
|
||||
left: 0;
|
||||
margin-top: -5px;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.popover.bottom .arrow {
|
||||
border-bottom: 5px solid #000000;
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
left: 50%;
|
||||
margin-left: -5px;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.popover.left .arrow {
|
||||
border-bottom: 5px solid transparent;
|
||||
border-left: 5px solid #000000;
|
||||
border-top: 5px solid transparent;
|
||||
margin-top: -5px;
|
||||
right: 0;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.popover .arrow {
|
||||
height: 0;
|
||||
position: absolute;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.popover-inner {
|
||||
background: none repeat scroll 0 0 rgba(0, 0, 0, 0.8);
|
||||
border-radius: 6px 6px 6px 6px;
|
||||
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
|
||||
overflow: hidden;
|
||||
padding: 3px;
|
||||
width: 280px;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
.popover-title {
|
||||
background-color: #F5F5F5;
|
||||
border-bottom: 1px solid #EEEEEE;
|
||||
border-radius: 3px 3px 0 0;
|
||||
line-height: 1;
|
||||
padding: 9px 15px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.popover-content {
|
||||
background-clip: padding-box;
|
||||
background-color: #FFFFFF;
|
||||
border-radius: 0 0 3px 3px;
|
||||
padding: 14px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.popover-content p, .popover-content ul, .popover-content ol {
|
||||
margin-bottom: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.fade {
|
||||
-moz-transition: opacity 0.15s linear 0s;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.fade.in {
|
||||
opacity: 1;
|
||||
}
|
||||
/*=============== popovers end ===============*/
|
||||
|
||||
.bottom_20 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
class AdvisoriesController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
before_filter :find_advisory, :only => [:show]
|
||||
skip_before_filter :authenticate_user! if APP_CONFIG['anonymous_access']
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
class Platforms::PlatformsController < Platforms::BaseController
|
||||
|
||||
before_filter :authenticate_user!
|
||||
skip_before_filter :authenticate_user!, :only => [:advisories] if APP_CONFIG['anonymous_access']
|
||||
load_and_authorize_resource
|
||||
|
||||
autocomplete :user, :uname
|
||||
|
@ -99,8 +100,7 @@ class Platforms::PlatformsController < Platforms::BaseController
|
|||
end
|
||||
|
||||
def destroy
|
||||
@platform.delay.destroy if @platform
|
||||
|
||||
@platform.destroy # later with resque
|
||||
flash[:notice] = t("flash.platform.destroyed")
|
||||
redirect_to platforms_path
|
||||
end
|
||||
|
@ -142,4 +142,7 @@ class Platforms::PlatformsController < Platforms::BaseController
|
|||
redirect_to members_platform_url(@platform)
|
||||
end
|
||||
|
||||
def advisories
|
||||
@advisories = @platform.advisories.paginate(:page => params[:page])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -54,6 +54,12 @@ class Platforms::RepositoriesController < Platforms::BaseController
|
|||
end
|
||||
end
|
||||
|
||||
def erase
|
||||
@repository.erase
|
||||
flash[:success] = t('flash.repository.erase')
|
||||
redirect_to platform_repository_path(@platform, @repository)
|
||||
end
|
||||
|
||||
def projects_list
|
||||
|
||||
owner_subquery = "
|
||||
|
|
|
@ -70,6 +70,7 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
|
||||
def show
|
||||
@item_groups = @build_list.items.group_by_level
|
||||
@advisories = @build_list.project.advisories
|
||||
end
|
||||
|
||||
def update
|
||||
|
@ -93,13 +94,10 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
|
||||
def publish_build
|
||||
if params[:status].to_i == 0 # ok
|
||||
@build_list.status = BuildList::BUILD_PUBLISHED
|
||||
@build_list.package_version = "#{params[:version]}-#{params[:release]}"
|
||||
system("cd #{@build_list.project.git_repository.path} && git tag #{@build_list.package_version} #{@build_list.commit_hash}") # TODO REDO through grit
|
||||
@build_list.published
|
||||
else
|
||||
@build_list.status = BuildList::FAILED_PUBLISH
|
||||
@build_list.fail_publish
|
||||
end
|
||||
@build_list.save
|
||||
|
||||
render :nothing => true, :status => 200
|
||||
end
|
||||
|
@ -118,20 +116,19 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
end
|
||||
|
||||
def pre_build
|
||||
@build_list.status = BuildServer::BUILD_STARTED
|
||||
@build_list.save
|
||||
@build_list.start_build
|
||||
|
||||
render :nothing => true, :status => 200
|
||||
end
|
||||
|
||||
def post_build
|
||||
@build_list.status = params[:status]
|
||||
params[:status].to_i == BuildServer::SUCCESS ? @build_list.build_success : @build_list.build_error
|
||||
@build_list.container_path = params[:container_path]
|
||||
@build_list.save
|
||||
|
||||
render :nothing => true, :status => 200
|
||||
|
||||
@build_list.delay.publish if @build_list.auto_publish # && @build_list.can_publish?
|
||||
@build_list.publish if @build_list.auto_publish # && @build_list.can_publish? # later with resque
|
||||
end
|
||||
|
||||
def circle_build
|
||||
|
@ -172,14 +169,31 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
|
||||
def publish
|
||||
@build_list.update_type = params[:build_list][:update_type] if params[:build_list][:update_type].present?
|
||||
if params[:create_advisory].present? and !@build_list.build_advisory(params[:build_list][:advisory]) do |a|
|
||||
|
||||
if params[:attach_advisory].present? and params[:attach_advisory] != 'no' and !@build_list.advisory
|
||||
if params[:attach_advisory] == 'new'
|
||||
# create new advisory
|
||||
if !@build_list.build_advisory(params[:build_list][:advisory]) do |a|
|
||||
a.update_type = @build_list.update_type
|
||||
a.project = @build_list.project
|
||||
a.platforms << @build_list.save_to_platform unless a.platforms.include? @build_list.save_to_platform
|
||||
end.save
|
||||
redirect_to :back, :notice => t('layout.build_lists.publish_fail') and return
|
||||
end
|
||||
if @build_list.save and @build_list.publish
|
||||
else
|
||||
# attach existing advisory
|
||||
a = Advisory.where(:advisory_id => params[:attach_advisory]).limit(1).first
|
||||
if a.update_type != @build_list.update_type
|
||||
redirect_to :back, :notice => t('layout.build_lists.publish_fail') and return
|
||||
end
|
||||
a.platforms << @build_list.save_to_platform unless a.platforms.include? @build_list.save_to_platform
|
||||
@build_list.advisory = a
|
||||
unless a.save
|
||||
redirect_to :back, :notice => t('layout.build_lists.publish_fail') and return
|
||||
end
|
||||
end
|
||||
end
|
||||
if @build_list.save and @build_list.now_publish
|
||||
redirect_to :back, :notice => t('layout.build_lists.publish_success')
|
||||
else
|
||||
redirect_to :back, :notice => t('layout.build_lists.publish_fail')
|
||||
|
|
|
@ -4,7 +4,7 @@ class Projects::IssuesController < Projects::BaseController
|
|||
before_filter :authenticate_user!
|
||||
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
|
||||
load_resource :project
|
||||
load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id, :only => [:show, :edit, :update, :destroy, :new, :create]
|
||||
load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id, :only => [:show, :edit, :update, :destroy, :new, :create, :index]
|
||||
before_filter :load_and_authorize_label, :only => NON_RESTFUL_ACTION
|
||||
|
||||
layout 'application'
|
||||
|
|
|
@ -255,10 +255,7 @@ class Projects::WikiController < Projects::BaseController
|
|||
unless @committer
|
||||
p = commit_message.merge({:name => current_user.uname, :email => current_user.email})
|
||||
@committer = Gollum::Committer.new(@wiki, p)
|
||||
# @committer.after_commit do |committer, sha1|
|
||||
# here goes callback for notification
|
||||
# end
|
||||
ActivityFeedObserver.instance.after_create(@committer).delay
|
||||
GitHook.perform_later!(:notification, :process, {:project_id => @project.id, :actor_name => @committer.actor.name, :commit_sha => @committer.commit})
|
||||
end
|
||||
@committer
|
||||
end
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
module AdvisoriesHelper
|
||||
def advisories_select_options(advisories, opts = {:class => 'popoverable'})
|
||||
def_values = [[t("layout.advisories.no_"), 'no'], [t("layout.advisories.new"), 'new']]
|
||||
options_for_select(def_values, def_values.first) +
|
||||
options_for_select(advisories.map { |a| [a.advisory_id, :class => "#{opts[:class]} #{a.update_type}"] })
|
||||
end
|
||||
|
||||
def construct_ref_link(ref)
|
||||
ref = sanitize(ref)
|
||||
url = if ref =~ %r[^http(s?)://*]
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
class UserMailer < ActionMailer::Base
|
||||
default :from => APP_CONFIG['do-not-reply-email']
|
||||
|
||||
include Resque::Mailer # send email async
|
||||
|
||||
def new_user_notification(user)
|
||||
@user = user
|
||||
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_user_notification", :project_name => APP_CONFIG['project_name'])) do |format|
|
||||
|
|
|
@ -19,6 +19,8 @@ class Ability
|
|||
can :search, BuildList
|
||||
can :read, BuildList, :project => {:visibility => 'open'}
|
||||
can :read, ProductBuildList, :product => {:platform => {:visibility => 'open'}}
|
||||
can :read, Advisory
|
||||
can(:advisories, Platform) {APP_CONFIG['anonymous_access']}
|
||||
# Core callbacks
|
||||
can [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt], BuildList
|
||||
|
||||
|
@ -82,13 +84,13 @@ class Ability
|
|||
can([:read, :related, :members], Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
|
||||
can([:update, :members], Platform) {|platform| local_admin? platform}
|
||||
can([:destroy, :members, :add_member, :remove_member, :remove_members, :build_all, :mass_builds] , Platform) {|platform| owner? platform}
|
||||
can :autocomplete_user_uname, Platform
|
||||
can [:autocomplete_user_uname, :read_advisories, :advisories], Platform
|
||||
|
||||
can [:read, :projects_list], Repository, :platform => {:visibility => 'open'}
|
||||
can [:read, :projects_list], Repository, :platform => {:owner_type => 'User', :owner_id => user.id}
|
||||
can [:read, :projects_list], Repository, :platform => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||
can([:read, :projects_list], Repository, read_relations_for('repositories', 'platforms')) {|repository| local_reader? repository.platform}
|
||||
can([:create, :update, :projects_list, :add_project, :remove_project], Repository) {|repository| local_admin? repository.platform}
|
||||
can([:create, :update, :projects_list, :add_project, :remove_project, :erase], Repository) {|repository| local_admin? repository.platform}
|
||||
can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository.platform}
|
||||
|
||||
can :read, Product, :platform => {:visibility => 'open'}
|
||||
|
@ -117,7 +119,7 @@ class Ability
|
|||
|
||||
# Shared cannot rights for all users (registered, admin)
|
||||
cannot :destroy, Platform, :platform_type => 'personal'
|
||||
cannot [:create, :destroy, :add_project, :remove_project], Repository, :platform => {:platform_type => 'personal'}
|
||||
cannot [:create, :destroy, :add_project, :remove_project, :erase], Repository, :platform => {:platform_type => 'personal'}
|
||||
cannot :destroy, Issue
|
||||
|
||||
cannot [:members, :add_member, :remove_member, :remove_members], Platform, :platform_type => 'personal'
|
||||
|
|
|
@ -15,7 +15,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
|
|||
recipients = record.collect_recipient_ids
|
||||
recipients.each do |recipient_id|
|
||||
recipient = User.find(recipient_id)
|
||||
UserMailer.delay.new_issue_notification(record, recipient) if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue
|
||||
UserMailer.new_issue_notification(record, recipient).deliver if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue
|
||||
ActivityFeed.create(
|
||||
:user => recipient,
|
||||
:kind => 'new_issue_notification',
|
||||
|
@ -25,7 +25,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
|
|||
end
|
||||
|
||||
if record.assignee_id_changed?
|
||||
UserMailer.delay.issue_assign_notification(record, record.assignee) if record.assignee.notifier.issue_assign && record.assignee.notifier.can_notify
|
||||
UserMailer.new_issue_notification(record, record.assignee).deliver if record.assignee.notifier.issue_assign && record.assignee.notifier.can_notify
|
||||
ActivityFeed.create(
|
||||
:user => record.user,
|
||||
:kind => 'issue_assign_notification',
|
||||
|
@ -39,7 +39,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
|
|||
subscribes = record.commentable.subscribes
|
||||
subscribes.each do |subscribe|
|
||||
if record.user_id != subscribe.user_id
|
||||
UserMailer.delay.new_comment_notification(record, subscribe.user) if record.can_notify_on_new_comment?(subscribe)
|
||||
UserMailer.new_comment_notification(record, subscribe.user).deliver if record.can_notify_on_new_comment?(subscribe)
|
||||
ActivityFeed.create(
|
||||
:user => subscribe.user,
|
||||
:kind => 'new_comment_notification',
|
||||
|
@ -57,7 +57,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
|
|||
( (subscribe.project.owner?(subscribe.user) && subscribe.user.notifier.new_comment_commit_repo_owner) or
|
||||
(subscribe.user.commentor?(record.commentable) && subscribe.user.notifier.new_comment_commit_commentor) or
|
||||
(subscribe.user.committer?(record.commentable) && subscribe.user.notifier.new_comment_commit_owner) )
|
||||
UserMailer.delay.new_comment_notification(record, subscribe.user)
|
||||
UserMailer.new_comment_notification(record, subscribe.user).deliver
|
||||
end
|
||||
ActivityFeed.create(
|
||||
:user => subscribe.user,
|
||||
|
@ -93,26 +93,23 @@ class ActivityFeedObserver < ActiveRecord::Observer
|
|||
end
|
||||
|
||||
record.project.owner_and_admin_ids.each do |recipient|
|
||||
ActivityFeed.create(
|
||||
ActivityFeed.create!(
|
||||
:user => User.find(recipient),
|
||||
:kind => kind,
|
||||
:data => options
|
||||
)
|
||||
end
|
||||
|
||||
when 'Gollum::Committer'
|
||||
actor = User.find_by_uname(record.actor.name)
|
||||
project_name = record.wiki.path.match(/\/(\w+)\.wiki\.git$/)[1]
|
||||
project = Project.find_by_name(project_name)
|
||||
commit_sha = record.commit
|
||||
#wiki_name = record.wiki.name
|
||||
when 'Hash' # 'Gollum::Committer'
|
||||
actor = User.find_by_uname! record[:actor_name]
|
||||
project = Project.find record[:project_id]
|
||||
|
||||
project.owner_and_admin_ids.each do |recipient|
|
||||
ActivityFeed.create(
|
||||
ActivityFeed.create!(
|
||||
:user => User.find(recipient),#record.user,
|
||||
:kind => 'wiki_new_commit_notification',
|
||||
:data => {:user_id => actor.id, :user_name => actor.name, :user_email => actor.email, :project_id => project.id,
|
||||
:project_name => project_name, :commit_sha => commit_sha, :project_owner => project.owner.uname}
|
||||
:project_name => project.name, :commit_sha => record[:commit_sha], :project_owner => project.owner.uname}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -122,7 +119,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
|
|||
case record.class.to_s
|
||||
when 'Issue'
|
||||
if record.assignee_id && record.assignee_id_changed?
|
||||
UserMailer.delay.issue_assign_notification(record, record.assignee) if record.assignee.notifier.issue_assign && record.assignee.notifier.can_notify
|
||||
UserMailer.issue_assign_notification(record, record.assignee).deliver if record.assignee.notifier.issue_assign && record.assignee.notifier.can_notify
|
||||
ActivityFeed.create(
|
||||
:user => record.assignee,
|
||||
:kind => 'issue_assign_notification',
|
||||
|
|
|
@ -6,10 +6,13 @@ class Advisory < ActiveRecord::Base
|
|||
validates :description, :update_type, :presence => true
|
||||
|
||||
after_create :generate_advisory_id
|
||||
before_save :normalize_references, :if => :references_changed?
|
||||
|
||||
ID_TEMPLATE = 'ROSA-%<type>s-%<year>d:%<id>04d'
|
||||
TYPES = {'security' => 'SA', 'bugfix' => 'A'}
|
||||
|
||||
scope :by_project, lambda {|p| where('project_id' => p.try(:id) || p)}
|
||||
|
||||
def to_param
|
||||
advisory_id
|
||||
end
|
||||
|
@ -20,4 +23,15 @@ class Advisory < ActiveRecord::Base
|
|||
self.advisory_id = sprintf(ID_TEMPLATE, :type => TYPES[self.update_type], :year => Time.now.utc.year, :id => self.id)
|
||||
self.save
|
||||
end
|
||||
|
||||
def normalize_references
|
||||
self.references.gsub!(/\r| /, '')
|
||||
self.references = self.references.split('\n').map do |ref|
|
||||
ref = CGI::escapeHTML(ref)
|
||||
ref = "http://#{ref}" unless ref =~ %r[^http(s?)://*]
|
||||
ref
|
||||
end.join("\n")
|
||||
end
|
||||
|
||||
end
|
||||
Advisory.include_root_in_json = false
|
||||
|
|
|
@ -96,10 +96,102 @@ class BuildList < ActiveRecord::Base
|
|||
serialize :additional_repos
|
||||
serialize :include_repos
|
||||
|
||||
before_create :set_default_status
|
||||
after_create :place_build
|
||||
after_commit :place_build
|
||||
after_destroy :delete_container
|
||||
|
||||
@queue = :clone_and_build
|
||||
|
||||
state_machine :status, :initial => :waiting_for_response do
|
||||
|
||||
after_transition :on => :published, :do => :set_version_and_tag
|
||||
|
||||
event :place_build do
|
||||
transition :waiting_for_response => :build_pending, :if => lambda { |build_list|
|
||||
build_list.add_to_queue == BuildServer::SUCCESS
|
||||
}
|
||||
[
|
||||
'BuildList::BUILD_PENDING',
|
||||
'BuildServer::PLATFORM_PENDING',
|
||||
'BuildServer::PLATFORM_NOT_FOUND',
|
||||
'BuildServer::PROJECT_NOT_FOUND',
|
||||
'BuildServer::PROJECT_VERSION_NOT_FOUND'
|
||||
].each do |code|
|
||||
transition :waiting_for_response => code.demodulize.downcase.to_sym, :if => lambda { |build_list|
|
||||
build_list.add_to_queue == code.constantize
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
event :start_build do
|
||||
transition [ :build_pending,
|
||||
:platform_pending,
|
||||
:platform_not_found,
|
||||
:project_not_found,
|
||||
:project_version_not_found ] => :build_started
|
||||
end
|
||||
|
||||
event :cancel do
|
||||
transition [:build_pending, :platform_pending] => :build_canceled, :if => lambda { |build_list|
|
||||
build_list.can_cancel? && BuildServer.delete_build_list(build_list.bs_id) == BuildServer::SUCCESS
|
||||
}
|
||||
end
|
||||
|
||||
event :published do
|
||||
transition [:build_publish, :rejected_publish] => :build_published
|
||||
end
|
||||
|
||||
event :fail_publish do
|
||||
transition [:build_publish, :rejected_publish] => :failed_publish
|
||||
end
|
||||
|
||||
event :publish do
|
||||
transition [:success, :failed_publish] => :build_publish, :if => lambda { |build_list|
|
||||
BuildServer.publish_container(build_list.bs_id) == BuildServer::SUCCESS
|
||||
}
|
||||
transition [:success, :failed_publish] => :failed_publish
|
||||
end
|
||||
|
||||
event :reject_publish do
|
||||
transition :success => :rejected_publish, :if => :can_reject_publish?
|
||||
end
|
||||
|
||||
event :build_success do
|
||||
transition [:build_started, :build_canceled] => :success
|
||||
end
|
||||
|
||||
event :build_error do
|
||||
transition [:build_started, :build_canceled] => :build_error
|
||||
end
|
||||
|
||||
HUMAN_STATUSES.each do |code,name|
|
||||
state name, :value => code
|
||||
end
|
||||
end
|
||||
|
||||
later :publish, :queue => :clone_build
|
||||
|
||||
def set_version_and_tag
|
||||
pkg = self.packages.where(:package_type => 'source', :project_id => self.project_id).first
|
||||
self.package_version = "#{pkg.platform.name}-#{pkg.version}-#{pkg.release}"
|
||||
system("cd #{self.project.git_repository.path} && git tag #{self.package_version} #{self.commit_hash}") # TODO REDO through grit
|
||||
save
|
||||
end
|
||||
|
||||
#TODO: Share this checking on product owner.
|
||||
def can_cancel?
|
||||
[BUILD_PENDING, BuildServer::PLATFORM_PENDING].include? status && bs_id
|
||||
end
|
||||
|
||||
def can_reject_publish?
|
||||
can_publish? and save_to_platform.released
|
||||
end
|
||||
|
||||
|
||||
def add_to_queue
|
||||
#XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority
|
||||
@status ||= BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority
|
||||
end
|
||||
|
||||
def self.human_status(status)
|
||||
I18n.t("layout.build_lists.statuses.#{HUMAN_STATUSES[status]}")
|
||||
end
|
||||
|
@ -126,38 +218,6 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def publish
|
||||
return false unless can_publish?
|
||||
has_published = BuildServer.publish_container bs_id
|
||||
update_attribute(:status, has_published == 0 ? BUILD_PUBLISH : FAILED_PUBLISH)
|
||||
return has_published == 0
|
||||
end
|
||||
|
||||
def can_publish?
|
||||
status == BuildServer::SUCCESS or status == FAILED_PUBLISH
|
||||
end
|
||||
|
||||
def reject_publish
|
||||
return false unless can_reject_publish?
|
||||
update_attribute(:status, REJECTED_PUBLISH)
|
||||
end
|
||||
|
||||
def can_reject_publish?
|
||||
can_publish? and save_to_platform.released
|
||||
end
|
||||
|
||||
def cancel
|
||||
return false unless can_cancel?
|
||||
has_canceled = BuildServer.delete_build_list bs_id
|
||||
update_attribute(:status, BUILD_CANCELED) if has_canceled == 0
|
||||
return has_canceled == 0
|
||||
end
|
||||
|
||||
#TODO: Share this checking on product owner.
|
||||
def can_cancel?
|
||||
status == BUILD_PENDING && bs_id
|
||||
end
|
||||
|
||||
def event_log_message
|
||||
{:project => project.name, :version => project_version, :arch => arch.name}.inspect
|
||||
end
|
||||
|
@ -181,19 +241,6 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
protected
|
||||
|
||||
def set_default_status
|
||||
self.status = WAITING_FOR_RESPONSE unless self.status.present?
|
||||
return true
|
||||
end
|
||||
|
||||
def place_build
|
||||
#XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority
|
||||
self.status = BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority
|
||||
self.status = BUILD_PENDING if self.status == 0
|
||||
save
|
||||
end
|
||||
|
||||
|
||||
def delete_container
|
||||
if can_cancel?
|
||||
BuildServer.delete_build_list bs_id
|
||||
|
|
|
@ -3,10 +3,12 @@ class GitHook
|
|||
attr_reader :repo, :newrev, :oldrev, :newrev_type, :oldrev_type, :refname,
|
||||
:change_type, :rev, :rev_type, :refname_type, :owner, :project
|
||||
|
||||
def initialize(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type)
|
||||
include Resque::Plugins::Status
|
||||
|
||||
def initialize(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type = nil)
|
||||
@repo, @newrev, @oldrev, @refname, @newrev_type, @oldrev_type = repo, newrev, oldrev, ref, newrev_type, oldrev_type
|
||||
if @owner = User.where(:uname => owner_uname).first || Group.where(:uname => owner_uname).first
|
||||
@project = @owner.projects.where(:name => repo).first
|
||||
if @owner = User.where(:uname => owner_uname).first || Group.where(:uname => owner_uname).first!
|
||||
@project = @owner.own_projects.where(:name => repo).first!
|
||||
end
|
||||
@change_type = git_change_type
|
||||
git_revision_types
|
||||
|
@ -55,4 +57,8 @@ class GitHook
|
|||
@refname_type= "*** Unknown type of update to $refname (#{rev_type})"
|
||||
end
|
||||
end
|
||||
|
||||
def self.process(*args)
|
||||
ActivityFeedObserver.instance.after_create(args.size > 1 ? GitHook.new(*args) : args.first)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,12 +24,12 @@ class MassBuild < ActiveRecord::Base
|
|||
|
||||
# ATTENTION: repositories and arches must be set before calling this method!
|
||||
def build_all
|
||||
platform.delay.build_all(
|
||||
platform.build_all(
|
||||
:mass_build_id => self.id,
|
||||
:user => self.user,
|
||||
:repositories => self.repositories,
|
||||
:arches => self.arches,
|
||||
:auto_publish => self.auto_publish
|
||||
)
|
||||
) # later with resque
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ class Platform < ActiveRecord::Base
|
|||
|
||||
validates :description, :presence => true
|
||||
validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES}
|
||||
validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ }
|
||||
validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-\.]+$/ }
|
||||
validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']}
|
||||
|
||||
before_create :create_directory, :if => lambda {Thread.current[:skip]} # TODO remove this when core will be ready
|
||||
|
@ -104,11 +104,10 @@ class Platform < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def base_clone(attrs = {}) # :description, :name, :owner
|
||||
clone.tap do |c|
|
||||
# c.attributes = attrs #
|
||||
attrs.each {|k,v| c.send("#{k}=", v)}
|
||||
c.updated_at = nil; c.created_at = nil # :id = nil
|
||||
c.parent = self
|
||||
dup.tap do |c|
|
||||
attrs.each {|k,v| c.send("#{k}=", v)} # c.attributes = attrs
|
||||
c.updated_at = nil; c.created_at = nil
|
||||
c.parent = self; c.released = false
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -119,7 +118,7 @@ class Platform < ActiveRecord::Base
|
|||
|
||||
def full_clone(attrs = {})
|
||||
base_clone(attrs).tap do |c|
|
||||
with_skip {c.save} and c.clone_relations(self) and c.delay.xml_rpc_clone
|
||||
with_skip {c.save} and c.clone_relations(self) and c.xml_rpc_clone # later with resque
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -173,17 +172,19 @@ class Platform < ActiveRecord::Base
|
|||
begin
|
||||
p.build_for(self, user, arch, auto_publish, mass_build_id)
|
||||
rescue RuntimeError, Exception
|
||||
p.delay.build_for(self, user, arch, auto_publish, mass_build_id)
|
||||
# p.async(:build_for, self, user, arch, auto_publish, mass_build_id) # TODO need this?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
later :build_all, :loner => true, :queue => :clone_build
|
||||
|
||||
def destroy
|
||||
with_skip {super} # avoid cascade XML RPC requests
|
||||
end
|
||||
later :destroy, :queue => :clone_build
|
||||
|
||||
protected
|
||||
|
||||
|
@ -217,6 +218,7 @@ class Platform < ActiveRecord::Base
|
|||
raise "Failed to clone platform #{old_name} with code #{result}. Path: #{build_path(old_name)} to platform #{new_name}"
|
||||
end
|
||||
end
|
||||
later :xml_rpc_clone, :loner => true, :queue => :clone_build
|
||||
|
||||
def freeze_platform
|
||||
if released_changed? && released == true
|
||||
|
|
|
@ -54,10 +54,10 @@ class Product < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def full_clone(attrs = {})
|
||||
clone.tap do |c| # dup
|
||||
dup.tap do |c|
|
||||
c.platform_id = nil
|
||||
attrs.each {|k,v| c.send("#{k}=", v)}
|
||||
c.updated_at = nil; c.created_at = nil # :id = nil
|
||||
c.updated_at = nil; c.created_at = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -41,12 +41,12 @@ class Project < ActiveRecord::Base
|
|||
|
||||
after_create :attach_to_personal_repository
|
||||
after_create :create_git_repo
|
||||
after_create {|p| p.delay(:queue => 'fork', :priority => 20).fork_git_repo unless is_root?}
|
||||
after_create {|p| p.fork_git_repo unless p.is_root?}
|
||||
after_save :create_wiki
|
||||
|
||||
after_destroy :destroy_git_repo
|
||||
after_destroy :destroy_wiki
|
||||
after_save {|p| p.delay(:queue => 'import', :priority => 10).import_attached_srpm if p.srpm?} # should be after create_git_repo
|
||||
after_save {|p| p.import_attached_srpm if p.srpm?} # later with resque # should be after create_git_repo
|
||||
# after_rollback lambda { destroy_git_repo rescue true if new_record? }
|
||||
|
||||
has_ancestry
|
||||
|
@ -219,11 +219,6 @@ class Project < ActiveRecord::Base
|
|||
owner == user
|
||||
end
|
||||
|
||||
def self.process_hook(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type)
|
||||
rec = GitHook.new(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type)
|
||||
ActivityFeedObserver.instance.after_create rec
|
||||
end
|
||||
|
||||
def owner_and_admin_ids
|
||||
recipients = self.relations.by_role('admin').where(:actor_type => 'User').map { |rel| rel.read_attribute(:actor_id) }
|
||||
recipients = recipients | [self.owner_id] if self.owner_type == 'User'
|
||||
|
@ -252,7 +247,7 @@ class Project < ActiveRecord::Base
|
|||
def create_git_repo
|
||||
if is_root?
|
||||
Grit::Repo.init_bare(path)
|
||||
write_hook.delay(:queue => 'fork', :priority => 15)
|
||||
write_hook
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -260,6 +255,7 @@ class Project < ActiveRecord::Base
|
|||
dummy = Grit::Repo.new(path) rescue parent.git_repository.repo.fork_bare(path)
|
||||
write_hook
|
||||
end
|
||||
later :fork_git_repo, :queue => :fork_import
|
||||
|
||||
def destroy_git_repo
|
||||
FileUtils.rm_rf path
|
||||
|
@ -271,7 +267,7 @@ class Project < ActiveRecord::Base
|
|||
self.srpm = nil; save # clear srpm
|
||||
end
|
||||
end
|
||||
|
||||
later :import_attached_srpm, :queue => :fork_import
|
||||
|
||||
def create_wiki
|
||||
if has_wiki && !FileTest.exist?(wiki_path)
|
||||
|
@ -291,7 +287,7 @@ class Project < ActiveRecord::Base
|
|||
hook = File.join(::Rails.root.to_s, 'tmp', "post-receive-hook")
|
||||
FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook.partial"), hook)
|
||||
File.open(hook, 'a') do |f|
|
||||
s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && #{is_production ? 'RAILS_ENV=production' : ''} bundle exec rails runner 'Project.delay(:queue => \\\"hook\\\").process_hook(\\\"$owner\\\", \\\"$reponame\\\", \\\"$newrev\\\", \\\"$oldrev\\\", \\\"$ref\\\", \\\"$newrev_type\\\", \\\"$oldrev_type\\\")'\""
|
||||
s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && #{is_production ? 'RAILS_ENV=production' : ''} bundle exec rake hook:enqueue[$owner,$reponame,$newrev,$oldrev,$ref,$newrev_type,$oldrev_type]\""
|
||||
s << " > /dev/null 2>&1" if is_production
|
||||
s << "\ndone\n"
|
||||
f.write(s)
|
||||
|
|
|
@ -16,11 +16,15 @@ class Repository < ActiveRecord::Base
|
|||
attr_accessible :name, :description
|
||||
attr_readonly :name, :platform_id
|
||||
|
||||
def erase
|
||||
system("rm -Rf #{ APP_CONFIG['root_path'] }/platforms/#{ self.platform.name }/repository/*")
|
||||
end
|
||||
|
||||
def base_clone(attrs = {})
|
||||
clone.tap do |c| # dup
|
||||
dup.tap do |c|
|
||||
c.platform_id = nil
|
||||
attrs.each {|k,v| c.send("#{k}=", v)}
|
||||
c.updated_at = nil; c.created_at = nil # :id = nil
|
||||
c.updated_at = nil; c.created_at = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,10 +33,11 @@ class Repository < ActiveRecord::Base
|
|||
from.projects.find_each {|p| self.projects << p}
|
||||
end
|
||||
end
|
||||
later :clone_relations, :loner => true, :queue => :clone_build
|
||||
|
||||
def full_clone(attrs = {})
|
||||
base_clone(attrs).tap do |c|
|
||||
with_skip {c.save} and c.delay.clone_relations(self)
|
||||
with_skip {c.save} and c.clone_relations(self) # later with resque
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
json.array!(advisories) do |json, a|
|
||||
json.id a.advisory_id
|
||||
json.advisory_id a.advisory_id
|
||||
json.description simple_format(a.description)
|
||||
json.popover_desc truncate(a.description, :length => 500);
|
||||
json.references a.references.split("\n").map{|ref| construct_ref_link(ref)}.join('<br />')
|
||||
json.update_type a.update_type
|
||||
end
|
|
@ -16,6 +16,9 @@
|
|||
- if can? :read, @platform.products.build
|
||||
%li{:class => (contr == :products) ? 'active' : ''}
|
||||
= link_to t("layout.products.list_header"), platform_products_path(@platform)
|
||||
- if can? :read_advisories, @platform
|
||||
%li{:class => (contr == :platforms and act == :advisories) ? 'active' : ''}
|
||||
= link_to t("layout.advisories.list_header"), advisories_platform_path(@platform)
|
||||
- if can? :update, @platform
|
||||
%li{:class => (act == :edit && contr == :platforms) ? 'active' : nil}
|
||||
= link_to t("platform_menu.settings"), edit_platform_path(@platform)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
%table#myTable.tablesorter.advisories{:cellspacing => "0", :cellpadding => "0"}
|
||||
%thead
|
||||
%tr
|
||||
%th.th1= t("activerecord.attributes.advisory.advisory_id")
|
||||
%th.th2= t("activerecord.attributes.advisory.description")
|
||||
%tbody
|
||||
= render :partial => 'advisory', :collection => @advisories, :as => :advisory
|
|
@ -0,0 +1,3 @@
|
|||
%tr{:class => cycle("odd", "even")}
|
||||
%td= link_to advisory.advisory_id, advisory_path(advisory)
|
||||
%td= truncate(advisory.description, :length => 50)
|
|
@ -0,0 +1,6 @@
|
|||
- set_meta_tags :title => [title_object(@platform), t('layout.advisories.list_header')]
|
||||
= render 'submenu'
|
||||
= render 'sidebar'
|
||||
|
||||
= render :partial => 'advisories', :object => @advisories
|
||||
= will_paginate @advisories
|
|
@ -11,5 +11,7 @@
|
|||
%h3.fix= t("layout.projects.list_header")
|
||||
- if can? :add_project, @repository
|
||||
= link_to t("layout.projects.add"), add_project_platform_repository_path(@platform, @repository), :class => 'button'
|
||||
- if can? :erase, @repository
|
||||
= link_to t("layout.repositories.erase"), erase_platform_repository_path(@platform, @repository), :class => 'button', :confirm => t('layout.repositories.erase_confirm'), :method => :post
|
||||
|
||||
= render 'proj_list'
|
|
@ -72,12 +72,33 @@
|
|||
.both
|
||||
|
||||
- if @build_list.can_publish? and @build_list.save_to_platform.released and @build_list.advisory.nil?
|
||||
.leftlist= label_tag :create_advisory, t("layout.build_lists.create_advisory")
|
||||
.rightlist= check_box_tag :create_advisory, 1, false
|
||||
#advisory_block
|
||||
.leftlist= label_tag :attach_advisory, t("layout.build_lists.attached_advisory")
|
||||
.rightlist= select_tag :attach_advisory, advisories_select_options(@advisories)
|
||||
.both
|
||||
|
||||
#new_advisory_form
|
||||
= f.fields_for @build_list.build_advisory do |f|
|
||||
= render :partial => 'advisories/form', :locals => {:f => f}
|
||||
|
||||
#advisory_preview
|
||||
%h3= t("activerecord.models.advisory") << ' '
|
||||
|
||||
.leftlist= t("activerecord.attributes.advisory.description")
|
||||
.rightlist.descr
|
||||
.both
|
||||
|
||||
.leftlist= t("activerecord.attributes.advisory.references")
|
||||
.rightlist.refs
|
||||
.both
|
||||
|
||||
:javascript
|
||||
$(function() {
|
||||
Rosa.bootstrapedData.advisories = #{ render 'advisories/advisories.json.jbuilder',
|
||||
:advisories => @advisories };
|
||||
var r = new Rosa.Routers.BuildListsAdvisoriesRouter();
|
||||
});
|
||||
|
||||
= submit_tag t("layout.publish"), :confirm => t("layout.confirm"), :name => 'publish' if @build_list.can_publish? and can?(:publish, @build_list)
|
||||
= submit_tag t("layout.reject_publish"), :confirm => t("layout.confirm"), :name => 'reject_publish' if @build_list.can_reject_publish? and can?(:reject_publish, @build_list)
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
- if owner.projects.exists? :name => @project.name
|
||||
- if owner.own_projects.exists? :name => @project.name
|
||||
- is_group = owner.class == Group ? "(#{t 'activerecord.models.group'})" : ''
|
||||
%p.center
|
||||
=t 'layout.projects.already_exists'
|
||||
=link_to "#{owner.uname}/#{@project.name} #{is_group}", project_path(owner.projects.by_name(@project.name).first)
|
||||
=link_to "#{owner.uname}/#{@project.name} #{is_group}", project_path(owner, @project.name)
|
||||
- else
|
||||
= form_for @project, :url => fork_project_path(@project), :html => { :class => :form, :multipart => true, :method => :post } do |f|
|
||||
= hidden_field_tag :group, owner.id if owner.class == Group
|
||||
|
|
|
@ -35,8 +35,9 @@ set :deploy_via, :remote_cache
|
|||
|
||||
require './lib/recipes/nginx'
|
||||
require './lib/recipes/unicorn'
|
||||
require './lib/recipes/bluepill'
|
||||
require './lib/recipes/delayed_job'
|
||||
#require './lib/recipes/bluepill'
|
||||
set :workers_count, 4
|
||||
require './lib/recipes/resque'
|
||||
|
||||
namespace :deploy do
|
||||
task :stub_xml_rpc do
|
||||
|
@ -82,12 +83,16 @@ end
|
|||
after "deploy:finalize_update", "deploy:symlink_all"
|
||||
after "deploy:update_code", "deploy:migrate"
|
||||
after "deploy:setup", "deploy:symlink_pids"
|
||||
# after "deploy:restart", "bluepill:start" # "bluepill:processes:restart_dj" # "bluepill:restart"
|
||||
|
||||
# DJ
|
||||
after "deploy:stop", "delayed_job:stop"
|
||||
after "deploy:start", "delayed_job:start"
|
||||
after "deploy:restart", "delayed_job:restart"
|
||||
# Bluepill
|
||||
#after "deploy:restart", "bluepill:restart" # "bluepill:processes:restart_dj" # "bluepill:restart"
|
||||
#after "deploy:start", "bluepill:start"
|
||||
#after "deploy:stop", "bluepill:stop"
|
||||
|
||||
# Resque
|
||||
after "deploy:stop", "resque:stop"
|
||||
after "deploy:start", "resque:start"
|
||||
after "deploy:restart", "resque:restart"
|
||||
|
||||
after "deploy:restart", "deploy:cleanup"
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
require 'resque/server'
|
||||
require 'resque/status_server'
|
||||
|
||||
::ResqueServer = ::Resque::Server # need for CanCan
|
||||
|
||||
Resque::Mailer.default_queue_name = :notification
|
||||
Resque::Mailer.excluded_environments = [:test]
|
||||
|
||||
unless Rails.env.test?
|
||||
PerformLater.config.enabled = true # this will default to false if unset
|
||||
end
|
||||
|
||||
Resque::Plugins::Status::Hash.expire_in = (24 * 60 * 60) # 24hrs in seconds
|
|
@ -38,3 +38,4 @@ en:
|
|||
users: Users
|
||||
register_requests: Invites
|
||||
event_logs: Event log
|
||||
resque_server: Resque
|
||||
|
|
|
@ -38,3 +38,4 @@ ru:
|
|||
users: Пользователи
|
||||
register_requests: Инвайты
|
||||
event_logs: Лог событий
|
||||
resque_server: Resque
|
||||
|
|
|
@ -6,6 +6,8 @@ en:
|
|||
project_name: Project
|
||||
affected_versions: Affected versions
|
||||
ref_comment: Add links one by row
|
||||
no_: No
|
||||
new: New
|
||||
|
||||
flash:
|
||||
advisories:
|
||||
|
|
|
@ -6,6 +6,8 @@ ru:
|
|||
project_name: Проект
|
||||
affected_versions: Применен в версиях
|
||||
ref_comment: Вставляйте ссылки по одной на строку
|
||||
no_: Нет
|
||||
new: Новый
|
||||
|
||||
flash:
|
||||
advisories:
|
||||
|
|
|
@ -14,6 +14,8 @@ en:
|
|||
back_to_the_list: ⇐ List of repositories
|
||||
confirm_delete: Are you sure you want to delete this repository?
|
||||
current_repository_header: Current repository
|
||||
erase: Erase
|
||||
erase_confirm: Are you sure you want to erase this repository?
|
||||
|
||||
personal_repositories:
|
||||
settings_header: Settings
|
||||
|
@ -32,6 +34,7 @@ en:
|
|||
project_not_added: Project adding error. A project with such name already exists in this repository. Remove the old project first
|
||||
project_removed: Project deleted
|
||||
project_not_removed: Unable to delete project from repository
|
||||
erase: Repository successfully erased!
|
||||
|
||||
activerecord:
|
||||
models:
|
||||
|
|
|
@ -14,6 +14,8 @@ ru:
|
|||
back_to_the_list: ⇐ К списку репозиториев
|
||||
confirm_delete: Вы уверены, что хотите удалить этот репозиторий?
|
||||
current_repository_header: Текущий репозиторий
|
||||
erase: Очистить
|
||||
erase_confirm: Уверены, что хотите очистить репозиторий?
|
||||
|
||||
personal_repositories:
|
||||
settings_header: Настройки
|
||||
|
@ -32,6 +34,7 @@ ru:
|
|||
project_not_added: Не удалось добавить проект. В этом репозитории уже есть проект с таким именем. Сначала нужно удалить старый проект
|
||||
project_removed: Проект удален из репозитория
|
||||
project_not_removed: Не удалось удалить проект из репозитория
|
||||
erase: Репозиторий успешно очищен!
|
||||
|
||||
activerecord:
|
||||
models:
|
||||
|
|
|
@ -1,46 +1,53 @@
|
|||
#! /usr/bin/env ruby
|
||||
|
||||
app_name = ENV['APP_NAME'] || 'rosa_build'
|
||||
Bluepill.application(app_name) do |app|
|
||||
Bluepill.application(app_name, :log_file => "/srv/rosa_build/shared/log/bluepill.log") do |app|
|
||||
app.uid = app.gid = 'rosa'
|
||||
app.working_dir = "/srv/#{app_name}/current"
|
||||
%w(fork import hook default).each do |queue|
|
||||
app.process("delayed_job_#{queue}_queue") do |process|
|
||||
process.start_grace_time = 10.seconds
|
||||
process.stop_grace_time = 10.seconds
|
||||
process.restart_grace_time = 10.seconds
|
||||
|
||||
process.start_command = "/usr/bin/env ruby script/delayed_job --queue=#{queue} -p #{queue} --pid-dir=/srv/#{app_name}/current/tmp/#{queue}_pids start"
|
||||
process.stop_command = "/usr/bin/env ruby script/delayed_job --pid-dir=/srv/#{app_name}/current/tmp/#{queue}_pids stop"
|
||||
process.pid_file = File.join(app.working_dir, 'tmp', "#{queue}_pids", 'delayed_job.pid')
|
||||
end
|
||||
end
|
||||
|
||||
app.process("newrelic") do |process|
|
||||
process.start_grace_time = 10.seconds
|
||||
process.stop_grace_time = 10.seconds
|
||||
process.restart_grace_time = 10.seconds
|
||||
|
||||
path = File.join(app.working_dir, 'tmp', 'pids', 'newrelic.pid')
|
||||
process.start_command = "/usr/bin/env /usr/local/bin/nrsysmond -c /etc/newrelic/nrsysmond.cfg -p #{path}"
|
||||
process.pid_file = path
|
||||
end
|
||||
|
||||
app.process("unicorn") do |process|
|
||||
process.start_grace_time = 8.seconds
|
||||
process.stop_grace_time = 5.seconds
|
||||
process.restart_grace_time = 13.seconds
|
||||
|
||||
process.start_command = "bundle exec unicorn -l /tmp/#{app_name}_unicorn.sock -E production -c config/unicorn.rb -D"
|
||||
app.process("resque") do |process|
|
||||
process.group = "resque"
|
||||
pid_path = File.join(app.working_dir, 'tmp', 'pids', 'resque.pid')
|
||||
process.start_command = "bundle exec rake resque:work QUEUE=fork_import,hook,clone_build,notification PIDFILE=#{ pid_path } BACKGROUND=yes"
|
||||
process.pid_file = pid_path
|
||||
process.stop_command = "kill -QUIT {{PID}}"
|
||||
process.restart_command = "kill -USR2 {{PID}}"
|
||||
process.pid_file = File.join(app.working_dir, 'tmp', 'pids', 'unicorn.pid')
|
||||
process.daemonize = true
|
||||
process.start_grace_time = 5.seconds
|
||||
process.stop_grace_time = 5.seconds
|
||||
process.restart_grace_time = 5.seconds
|
||||
|
||||
process.monitor_children do |child_process|
|
||||
child_process.stop_command = "kill -QUIT {{PID}}"
|
||||
#process.monitor_children do |c|
|
||||
# c.stop_command = "kill -USR1 {{PID}}" # TODO: Are we really need this?
|
||||
# c.checks :mem_usage, :every => 30.seconds, :below => 80.megabytes, :fires => :stop
|
||||
# c.checks :running_time, :every => 30.seconds, :below => 10.minutes, :fires => :stop
|
||||
#end
|
||||
end
|
||||
|
||||
child_process.checks :mem_usage, :every => 10.seconds, :below => 150.megabytes, :times => [3,4], :fires => :stop
|
||||
child_process.checks :cpu_usage, :every => 10.seconds, :below => 20, :times => [3,4], :fires => :stop
|
||||
end
|
||||
end
|
||||
#app.process("newrelic") do |process|
|
||||
# process.start_grace_time = 10.seconds
|
||||
# process.stop_grace_time = 10.seconds
|
||||
# process.restart_grace_time = 10.seconds
|
||||
|
||||
# path = File.join(app.working_dir, 'tmp', 'pids', 'newrelic.pid')
|
||||
# process.start_command = "/usr/bin/env /usr/local/bin/nrsysmond -c /etc/newrelic/nrsysmond.cfg -p #{path}"
|
||||
# process.pid_file = path
|
||||
#end
|
||||
|
||||
#app.process("unicorn") do |process|
|
||||
# process.start_grace_time = 8.seconds
|
||||
# process.stop_grace_time = 5.seconds
|
||||
# process.restart_grace_time = 13.seconds
|
||||
|
||||
# process.start_command = "bundle exec unicorn -l /tmp/#{app_name}_unicorn.sock -E production -c config/unicorn.rb -D"
|
||||
# process.stop_command = "kill -QUIT {{PID}}"
|
||||
# process.restart_command = "kill -USR2 {{PID}}"
|
||||
# process.pid_file = File.join(app.working_dir, 'tmp', 'pids', 'unicorn.pid')
|
||||
|
||||
# process.monitor_children do |child_process|
|
||||
# child_process.stop_command = "kill -QUIT {{PID}}"
|
||||
|
||||
# child_process.checks :mem_usage, :every => 10.seconds, :below => 150.megabytes, :times => [3,4], :fires => :stop
|
||||
# child_process.checks :cpu_usage, :every => 10.seconds, :below => 20, :times => [3,4], :fires => :stop
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
|
|
@ -33,6 +33,9 @@ Rosa::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
resources :event_logs, :only => :index
|
||||
constraints AdminAccess do
|
||||
mount Resque::Server => 'resque'
|
||||
end
|
||||
end
|
||||
|
||||
resources :advisories, :only => [:index, :show]
|
||||
|
@ -49,11 +52,13 @@ Rosa::Application.routes.draw do
|
|||
post :make_clone
|
||||
post :build_all
|
||||
get :mass_builds
|
||||
get :advisories
|
||||
end
|
||||
get :autocomplete_user_uname, :on => :collection
|
||||
resources :repositories do
|
||||
member do
|
||||
get :add_project
|
||||
post :erase
|
||||
delete :remove_project
|
||||
get :projects_list
|
||||
end
|
||||
|
@ -61,6 +66,7 @@ Rosa::Application.routes.draw do
|
|||
resources :products do
|
||||
resources :product_build_lists, :only => [:create, :destroy]
|
||||
end
|
||||
|
||||
end
|
||||
match '/private/:platform_name/*file_path' => 'privates#show'
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
class DropDelayedJobs < ActiveRecord::Migration
|
||||
def up
|
||||
drop_table :delayed_jobs
|
||||
end
|
||||
|
||||
def down
|
||||
create_table :delayed_jobs do |t|
|
||||
t.integer "priority", :default => 0
|
||||
t.integer "attempts", :default => 0
|
||||
t.text "handler"
|
||||
t.text "last_error"
|
||||
t.datetime "run_at"
|
||||
t.datetime "locked_at"
|
||||
t.datetime "failed_at"
|
||||
t.string "locked_by"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "queue", :default => "default"
|
||||
end
|
||||
add_index :delayed_jobs, ["priority", "run_at"], :name => "delayed_jobs_priority"
|
||||
end
|
||||
end
|
39
db/schema.rb
39
db/schema.rb
|
@ -11,14 +11,14 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120529130537) do
|
||||
ActiveRecord::Schema.define(:version => 20120609163454) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
t.string "kind"
|
||||
t.text "data"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "advisories", :force => true do |t|
|
||||
|
@ -136,22 +136,6 @@ ActiveRecord::Schema.define(:version => 20120529130537) do
|
|||
t.integer "project_id"
|
||||
end
|
||||
|
||||
create_table "delayed_jobs", :force => true do |t|
|
||||
t.integer "priority", :default => 0
|
||||
t.integer "attempts", :default => 0
|
||||
t.text "handler"
|
||||
t.text "last_error"
|
||||
t.datetime "run_at"
|
||||
t.datetime "locked_at"
|
||||
t.datetime "failed_at"
|
||||
t.string "locked_by"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "queue", :default => "default"
|
||||
end
|
||||
|
||||
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
|
||||
|
||||
create_table "event_logs", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.string "user_name"
|
||||
|
@ -304,25 +288,27 @@ ActiveRecord::Schema.define(:version => 20120529130537) do
|
|||
t.text "description"
|
||||
t.string "ancestry"
|
||||
t.boolean "has_issues", :default => true
|
||||
t.boolean "has_wiki", :default => false
|
||||
t.string "srpm_file_name"
|
||||
t.string "srpm_content_type"
|
||||
t.integer "srpm_file_size"
|
||||
t.datetime "srpm_updated_at"
|
||||
t.boolean "has_wiki", :default => false
|
||||
t.string "default_branch", :default => "master"
|
||||
t.boolean "is_package", :default => true, :null => false
|
||||
t.integer "average_build_time", :default => 0, :null => false
|
||||
t.integer "build_count", :default => 0, :null => false
|
||||
end
|
||||
|
||||
add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false
|
||||
|
||||
create_table "register_requests", :force => true do |t|
|
||||
t.string "name"
|
||||
t.string "email"
|
||||
t.string "token"
|
||||
t.boolean "approved", :default => false
|
||||
t.boolean "rejected", :default => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "interest"
|
||||
t.text "more"
|
||||
end
|
||||
|
@ -376,7 +362,6 @@ ActiveRecord::Schema.define(:version => 20120529130537) do
|
|||
t.string "name"
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
t.string "password_salt", :default => "", :null => false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "remember_created_at"
|
||||
t.datetime "created_at"
|
||||
|
@ -384,11 +369,8 @@ ActiveRecord::Schema.define(:version => 20120529130537) do
|
|||
t.string "uname"
|
||||
t.string "role"
|
||||
t.string "language", :default => "en"
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.integer "own_projects_count", :default => 0, :null => false
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.integer "own_projects_count", :default => 0, :null => false
|
||||
t.text "professional_experience"
|
||||
t.string "site"
|
||||
t.string "company"
|
||||
|
@ -400,6 +382,9 @@ ActiveRecord::Schema.define(:version => 20120529130537) do
|
|||
t.integer "failed_attempts", :default => 0
|
||||
t.string "unlock_token"
|
||||
t.datetime "locked_at"
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.string "authentication_token"
|
||||
t.integer "build_priority", :default => 50
|
||||
end
|
||||
|
|
|
@ -10,3 +10,9 @@ class OwnerConstraint
|
|||
@class_name.send(@finder, request.params[:uname]).present?
|
||||
end
|
||||
end
|
||||
|
||||
class AdminAccess
|
||||
def self.matches?(request)
|
||||
!!request.env['warden'].user.try(:admin?)
|
||||
end
|
||||
end
|
|
@ -23,13 +23,6 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|||
task :status, :roles => [:app] do
|
||||
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} status"
|
||||
end
|
||||
|
||||
desc "Restart DJ processes"
|
||||
task :restart_dj, :roles => [:app] do
|
||||
%w(fork import hook default).each do |queue|
|
||||
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart delayed_job_#{queue}_queue"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Start a bluepill process and load a config"
|
||||
|
@ -47,5 +40,10 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|||
task :restart, :roles => [:app] do
|
||||
processes.stop; stop; start
|
||||
end
|
||||
|
||||
desc "Stop bluepill and monitored services"
|
||||
task :stop, :roles => [:app] do
|
||||
processes.stop
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
Capistrano::Configuration.instance(:must_exist).load do
|
||||
namespace :delayed_job do
|
||||
def dj_queues
|
||||
%w(fork import hook default)
|
||||
end
|
||||
|
||||
def rails_env
|
||||
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
|
||||
end
|
||||
|
||||
def roles
|
||||
fetch(:delayed_job_server_role, :app)
|
||||
end
|
||||
|
||||
desc "Stop the delayed_job process"
|
||||
task :stop, :roles => lambda { roles } do
|
||||
dj_queues.each do |queue|
|
||||
run "cd #{current_path};#{rails_env} script/delayed_job --pid-dir=#{shared_path}/pids/#{queue} stop"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Start the delayed_job process"
|
||||
task :start, :roles => lambda { roles } do
|
||||
dj_queues.each do |queue|
|
||||
run "cd #{current_path};#{rails_env} script/delayed_job --queue=#{queue} -p #{queue} --pid-dir=#{shared_path}/pids/#{queue} start"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Restart the delayed_job process"
|
||||
task :restart, :roles => lambda { roles } do
|
||||
dj_queues.each do |queue|
|
||||
run "cd #{current_path};#{rails_env} script/delayed_job --queue=#{queue} -p #{queue} --pid-dir=#{shared_path}/pids/#{queue} restart"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,31 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
Capistrano::Configuration.instance(:must_exist).load do
|
||||
|
||||
namespace :resque do
|
||||
task :start do
|
||||
start_workers
|
||||
end
|
||||
|
||||
task :stop do
|
||||
stop_workers
|
||||
end
|
||||
|
||||
task :restart do
|
||||
stop_workers
|
||||
start_workers
|
||||
end
|
||||
|
||||
def rails_env
|
||||
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
|
||||
end
|
||||
|
||||
def stop_workers
|
||||
run "kill -QUIT `ps aux | grep resque | grep -v grep | awk '{ print $2 }'`"
|
||||
# run "kill -QUIT `ps aux | grep resque | grep -v grep | awk '{ print $2 }'` > /dev/null 2>&1 &"
|
||||
end
|
||||
|
||||
def start_workers
|
||||
run "cd #{fetch :current_path} && COUNT=#{ workers_count } QUEUE=fork_import,hook,clone_build,notification #{ rails_env } BACKGROUND=yes bundle exec rake resque:workers"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -6,7 +6,7 @@ namespace :hook do
|
|||
hook = File.join(::Rails.root.to_s, 'tmp', "post-receive-hook")
|
||||
FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook.partial"), hook)
|
||||
File.open(hook, 'a') do |f|
|
||||
s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && #{is_production ? 'RAILS_ENV=production' : ''} bundle exec rails runner 'Project.delay(:queue => \\\"hook\\\").process_hook(\\\"$owner\\\", \\\"$reponame\\\", \\\"$newrev\\\", \\\"$oldrev\\\", \\\"$ref\\\", \\\"$newrev_type\\\", \\\"$oldrev_type\\\")'\""
|
||||
s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && #{is_production ? 'RAILS_ENV=production' : ''} bundle exec rake hook:enqueue[$owner,$reponame,$newrev,$oldrev,$ref,$newrev_type,$oldrev_type]\""
|
||||
s << " > /dev/null 2>&1" if is_production
|
||||
s << "\ndone\n"
|
||||
f.write(s)
|
||||
|
@ -32,6 +32,14 @@ namespace :hook do
|
|||
FileUtils.rm_rf(hook)
|
||||
end
|
||||
|
||||
desc 'Enqueue hook process'
|
||||
task :enqueue, :owner, :reponame, :newrev, :oldrev, :ref, :newrev_type, :oldrev_type do |t, args|
|
||||
# require 'resque'
|
||||
require './app/models/git_hook'
|
||||
PerformLater.config.enabled = true unless Rails.env.test?
|
||||
GitHook.perform_later!(:hook, :process, *args.to_hash.values)
|
||||
end
|
||||
|
||||
desc "remove git hook from all repos"
|
||||
task :remove => :environment do
|
||||
say "process.."
|
||||
|
|
|
@ -27,6 +27,32 @@ namespace :import do
|
|||
say 'DONE'
|
||||
end
|
||||
|
||||
# bundle exec rake import:srpm RAILS_ENV=production BASE=/share/platforms/naulinux5x_personal/tmp/SRPMS LIST=https://dl.dropbox.com/u/984976/nauschool5x.srpms.txt OWNER=naulinux PLATFORM=naulinux REPO=main > log/srpm_naulinux.log
|
||||
desc 'Import SRPMs as projects'
|
||||
task :srpm => :environment do
|
||||
base = ENV['BASE'] || '/share/alt_repos/rsync'
|
||||
list = ENV['LIST'] #|| 'https://dl.dropbox.com/u/984976/alt_import.txt'
|
||||
mask = ENV['MASK'] || '*.src.rpm'
|
||||
owner = User.find_by_uname(ENV['OWNER']) || Group.find_by_uname!(ENV['OWNER'] || 'altlinux')
|
||||
platform = Platform.find_by_name!(ENV['PLATFORM'] || 'altlinux5')
|
||||
repo = platform.repositories.find_by_name!(ENV['REPO'] || 'main')
|
||||
say "START import projects from '#{base}' using '#{list || mask}' for '#{owner.uname}' to repo '#{platform.name}/#{repo.name}'."
|
||||
repo.project_to_repositories.clear if agree "Clear destination repo #{platform.name}/#{repo.name}?"
|
||||
(list ? open(list).readlines.map{|n| File.join base, n.chomp.strip} : Dir[File.join base, mask]).each do |path|
|
||||
print "Processing '#{path}'..."
|
||||
if name = `rpm -q --qf '[%{Name}]' -p #{path}` and $?.success? and name.present?
|
||||
p = Project.find_or_create_by_name_and_owner_type_and_owner_id(name, owner.class.to_s, owner.id)
|
||||
p.import_srpm(path, platform.name)
|
||||
repo.projects << p
|
||||
print "Ok! - #{p.name}"
|
||||
else
|
||||
print 'Fail!'
|
||||
end
|
||||
puts
|
||||
end
|
||||
say 'DONE'
|
||||
end
|
||||
|
||||
namespace :sync do
|
||||
desc "Sync all repos"
|
||||
task :all do
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
ENV['RAILS_ENV'] ||= "production"
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
|
||||
require 'delayed/command'
|
||||
Delayed::Command.new(ARGV).daemonize
|
|
@ -317,27 +317,37 @@ describe Projects::BuildListsController do
|
|||
|
||||
context 'callbacks' do
|
||||
let(:build_list) { FactoryGirl.create(:build_list_core) }
|
||||
let(:build_list_package) { FactoryGirl.create(:build_list_package, :build_list_id => build_list.id, :platform_id => build_list.project.repositories.first.platform_id, :project_id => build_list.project_id, :version => "4.7.5.3", :release => 1) }
|
||||
|
||||
before(:each) do
|
||||
mock(controller).authenticate_build_service! {true}
|
||||
end
|
||||
|
||||
describe 'publish_build' do
|
||||
before { test_git_commit(build_list.project); build_list.update_attribute :commit_hash, build_list.project.git_repository.commits('master').last.id }
|
||||
before {
|
||||
test_git_commit(build_list.project)
|
||||
build_list.update_attribute :commit_hash, build_list.project.git_repository.commits('master').last.id
|
||||
build_list.update_attribute(:status, BuildList::BUILD_PUBLISH)
|
||||
build_list_package
|
||||
}
|
||||
|
||||
def do_get(status)
|
||||
get :publish_build, :id => build_list.bs_id, :status => status, :version => '4.7.5.3', :release => '1'
|
||||
build_list.reload
|
||||
end
|
||||
|
||||
it { do_get(BuildServer::SUCCESS); response.should be_ok }
|
||||
it(:passes) {
|
||||
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
|
||||
do_get(BuildServer::SUCCESS)
|
||||
response.should be_ok
|
||||
}
|
||||
it 'should create correct git tag for correct commit' do
|
||||
do_get(BuildServer::SUCCESS)
|
||||
build_list.project.git_repository.tags.last.name.should == build_list.package_version
|
||||
build_list.project.git_repository.commits(build_list.package_version).last.id.should == build_list.commit_hash
|
||||
end
|
||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISHED) }
|
||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :package_version).to('4.7.5.3-1') }
|
||||
it(:passes) { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISHED) }
|
||||
it(:passes) { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :package_version).to("#{ build_list_package.platform.name }-4.7.5.3-1") }
|
||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildList::FAILED_PUBLISH) }
|
||||
it { lambda{ do_get(BuildServer::ERROR) }.should_not change(build_list, :package_version) }
|
||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :updated_at) }
|
||||
|
@ -390,6 +400,10 @@ describe Projects::BuildListsController do
|
|||
end
|
||||
|
||||
describe 'pre_build' do
|
||||
before do
|
||||
build_list.update_attribute :status, BuildList::BUILD_PENDING
|
||||
end
|
||||
|
||||
def do_get
|
||||
get :pre_build, :id => build_list.bs_id
|
||||
build_list.reload
|
||||
|
@ -413,15 +427,32 @@ describe Projects::BuildListsController do
|
|||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :updated_at) }
|
||||
|
||||
context 'with auto_publish' do
|
||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISH) }
|
||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildServer::ERROR) }
|
||||
it(:passes) {
|
||||
build_list.update_attribute(:started_at, (Time.now - 1.day))
|
||||
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
|
||||
build_list.reload
|
||||
lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISH)
|
||||
}
|
||||
it(:passes) {
|
||||
build_list.update_attribute(:started_at, (Time.now - 1.day))
|
||||
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
|
||||
lambda{ do_get(BuildServer::BUILD_ERROR) }.should change(build_list, :status).to(BuildServer::BUILD_ERROR)
|
||||
}
|
||||
end
|
||||
|
||||
context 'without auto_publish' do
|
||||
before { build_list.update_attribute(:auto_publish, false) }
|
||||
|
||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildServer::SUCCESS) }
|
||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildServer::ERROR) }
|
||||
it(:passes) {
|
||||
build_list.update_attribute(:started_at, (Time.now - 1.day))
|
||||
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
|
||||
lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildServer::SUCCESS)
|
||||
}
|
||||
it(:passes) {
|
||||
build_list.update_attribute(:started_at, (Time.now - 1.day))
|
||||
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
|
||||
lambda{ do_get(BuildServer::BUILD_ERROR) }.should change(build_list, :status).to(BuildServer::BUILD_ERROR)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -11,6 +11,12 @@ shared_examples_for 'issue user with project reader rights' do
|
|||
get :show, :owner_name => @project.owner.uname, :project_name => @project.name, :id => @issue.serial_id
|
||||
response.should render_template(:show)
|
||||
end
|
||||
|
||||
it 'should be able to perform index action on hidden project' do
|
||||
@project.update_attribute :visibility, 'hidden'
|
||||
get :index, :owner_name => @project.owner.uname, :project_name => @project.name
|
||||
response.should render_template(:index)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'issue user with project writer rights' do
|
||||
|
@ -187,7 +193,22 @@ describe Projects::IssuesController do
|
|||
|
||||
context 'for guest' do
|
||||
if APP_CONFIG['anonymous_access']
|
||||
it_should_behave_like 'issue user with project reader rights'
|
||||
# it_should_behave_like 'issue user with project reader rights'
|
||||
it 'should be able to perform index action' do
|
||||
get :index, :owner_name => @project.owner.uname, :project_name => @project.name
|
||||
response.should render_template(:index)
|
||||
end
|
||||
|
||||
it 'should be able to perform show action' do
|
||||
get :show, :owner_name => @project.owner.uname, :project_name => @project.name, :id => @issue.serial_id
|
||||
response.should render_template(:show)
|
||||
end
|
||||
|
||||
it 'should not be able to perform index action on hidden project' do
|
||||
@project.update_attribute :visibility, 'hidden'
|
||||
get :index, :owner_name => @project.owner.uname, :project_name => @project.name
|
||||
response.should redirect_to(forbidden_path)
|
||||
end
|
||||
else
|
||||
it 'should not be able to perform index action' do
|
||||
get :index, :owner_name => @project.owner.uname, :project_name => @project.name
|
||||
|
@ -198,6 +219,12 @@ describe Projects::IssuesController do
|
|||
get :show, :owner_name => @project.owner.uname, :project_name => @project.name, :id => @issue.serial_id
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
|
||||
it 'should not be able to perform index action on hidden project' do
|
||||
@project.update_attribute :visibility, 'hidden'
|
||||
get :index, :owner_name => @project.owner.uname, :project_name => @project.name
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not be able to perform create action' do
|
||||
|
|
|
@ -16,4 +16,15 @@ FactoryGirl.define do
|
|||
factory :build_list_core, :parent => :build_list do
|
||||
bs_id { FactoryGirl.generate(:integer) }
|
||||
end
|
||||
|
||||
factory :build_list_package, :class => BuildList::Package do
|
||||
association :build_list
|
||||
association :project
|
||||
association :platform
|
||||
fullname "test_package"
|
||||
name "test_package"
|
||||
version "3.1.12"
|
||||
release 6
|
||||
package_type "source"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ def test_git_commit(project)
|
|||
project.git_repository.repo.index.commit('Test commit')
|
||||
end
|
||||
|
||||
Delayed::Worker.delay_jobs = false # Execute all jobs realtime
|
||||
Resque.inline = true
|
||||
|
||||
# Add testing root_path
|
||||
%x(rm -Rf #{Rails.root}/tmp/test_root)
|
||||
|
|
Loading…
Reference in New Issue