Merge pull request #64 from abf/rosa-build:53-information-about-user-who-published-build-list
#53: Save and show information about user who published build list
This commit is contained in:
commit
0a2c88e071
|
@ -33,6 +33,8 @@ class Api::V1::BuildListsController < Api::V1::BaseController
|
|||
end
|
||||
|
||||
def publish
|
||||
@build_list.publisher = current_user
|
||||
@build_list.save
|
||||
render_json :publish
|
||||
end
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ class Platforms::MassBuildsController < Platforms::BaseController
|
|||
|
||||
def publish
|
||||
if params[:status] == 'test_failed'
|
||||
@mass_build.publish_test_faild_builds
|
||||
@mass_build.publish_test_faild_builds current_user
|
||||
else
|
||||
@mass_build.publish_success_builds
|
||||
@mass_build.publish_success_builds current_user
|
||||
end
|
||||
redirect_to(platform_mass_builds_path(@mass_build.platform), :notice => t("flash.platform.publish_success"))
|
||||
end
|
||||
|
|
|
@ -173,6 +173,7 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
|
||||
end
|
||||
|
||||
@build_list.publisher = current_user
|
||||
if @build_list.save && @build_list.can_publish? && @build_list.now_publish
|
||||
redirect_to :back, :notice => t('layout.build_lists.publish_success')
|
||||
else
|
||||
|
|
|
@ -62,7 +62,7 @@ class UserMailer < ActionMailer::Base
|
|||
mail(
|
||||
:to => email_with_name(user, user.email),
|
||||
:subject => subject,
|
||||
:from => email_with_name(build_list.user)
|
||||
:from => email_with_name(build_list.publisher || build_list.user)
|
||||
) do |format|
|
||||
format.html
|
||||
end
|
||||
|
|
|
@ -136,21 +136,32 @@ class ActivityFeedObserver < ActiveRecord::Observer
|
|||
end
|
||||
|
||||
when 'BuildList'
|
||||
if [BuildList::BUILD_PUBLISHED,
|
||||
if ( record.status_changed? &&
|
||||
[BuildList::BUILD_PUBLISHED,
|
||||
BuildList::SUCCESS,
|
||||
BuildList::BUILD_ERROR,
|
||||
BuildList::PROJECT_VERSION_NOT_FOUND,
|
||||
BuildList::FAILED_PUBLISH,
|
||||
BuildList::TESTS_FAILED
|
||||
].include? record.status or
|
||||
(record.status == BuildList::BUILD_PENDING && record.bs_id_changed?)
|
||||
].include?(record.status)
|
||||
) or (record.status == BuildList::BUILD_PENDING && record.bs_id_changed?)
|
||||
record.project.admins.each do |recipient|
|
||||
user = record.publisher || record.user
|
||||
ActivityFeed.create(
|
||||
:user => recipient,
|
||||
:kind => 'build_list_notification',
|
||||
:data => {:task_num => record.bs_id, :build_list_id => record.id, :status => record.status, :updated_at => record.updated_at,
|
||||
:project_id => record.project_id, :project_name => record.project.name, :project_owner => record.project.owner.uname,
|
||||
:user_name => record.user.name, :user_email => record.user.email, :user_id => record.user_id}
|
||||
:data => {
|
||||
:task_num => record.bs_id,
|
||||
:build_list_id => record.id,
|
||||
:status => record.status,
|
||||
:updated_at => record.updated_at,
|
||||
:project_id => record.project_id,
|
||||
:project_name => record.project.name,
|
||||
:project_owner => record.project.owner.uname,
|
||||
:user_name => user.name,
|
||||
:user_email => user.email,
|
||||
:user_id => user.id
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,7 @@ class BuildList < ActiveRecord::Base
|
|||
belongs_to :save_to_repository, :class_name => 'Repository'
|
||||
belongs_to :build_for_platform, :class_name => 'Platform'
|
||||
belongs_to :user
|
||||
belongs_to :publisher, :class_name => 'User'
|
||||
belongs_to :advisory
|
||||
belongs_to :mass_build, :counter_cache => true
|
||||
has_many :items, :class_name => "BuildList::Item", :dependent => :destroy
|
||||
|
@ -156,6 +157,7 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
after_transition :on => :published,
|
||||
:do => [:set_version_and_tag, :actualize_packages]
|
||||
after_transition :on => :publish, :do => :set_publisher
|
||||
after_transition :on => :cancel, :do => :cancel_job
|
||||
|
||||
after_transition :on => [:published, :fail_publish, :build_error, :tests_failed], :do => :notify_users
|
||||
|
@ -476,6 +478,11 @@ class BuildList < ActiveRecord::Base
|
|||
self.use_save_to_repository = true if save_to_platform.main?
|
||||
end
|
||||
|
||||
def set_publisher
|
||||
self.publisher ||= user
|
||||
save
|
||||
end
|
||||
|
||||
def current_ability
|
||||
@current_ability ||= Ability.new(user)
|
||||
end
|
||||
|
|
|
@ -77,20 +77,22 @@ class MassBuild < ActiveRecord::Base
|
|||
end
|
||||
later :cancel_all, :queue => :clone_build
|
||||
|
||||
def publish_success_builds
|
||||
publish BuildList::SUCCESS, BuildList::FAILED_PUBLISH
|
||||
def publish_success_builds(user)
|
||||
publish user, BuildList::SUCCESS, BuildList::FAILED_PUBLISH
|
||||
end
|
||||
later :publish_success_builds, :queue => :clone_build
|
||||
|
||||
def publish_test_faild_builds
|
||||
publish BuildList::TESTS_FAILED
|
||||
def publish_test_faild_builds(user)
|
||||
publish user, BuildList::TESTS_FAILED
|
||||
end
|
||||
later :publish_test_faild_builds, :queue => :clone_build
|
||||
|
||||
private
|
||||
|
||||
def publish(*statuses)
|
||||
build_lists.where(:status => statuses).order(:id).find_in_batches(:batch_size => 50) do |bls|
|
||||
def publish(user, *statuses)
|
||||
builds = build_lists.where(:status => statuses)
|
||||
builds.update_all(:publisher_id => user.id)
|
||||
builds.order(:id).find_in_batches(:batch_size => 50) do |bls|
|
||||
bls.each{ |bl| bl.can_publish? && bl.now_publish }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,7 +40,13 @@ json.build_list do |json|
|
|||
:json => json_build_for_platform
|
||||
end
|
||||
|
||||
json.partial! 'api/v1/shared/owner', :owner => @build_list.project.owner
|
||||
json.user do |json_user|
|
||||
json.partial! 'api/v1/shared/member', :member => @build_list.user, :tag => json_user
|
||||
end
|
||||
|
||||
json.publisher do |json_publisher|
|
||||
json.partial! 'api/v1/shared/member', :member => @build_list.publisher, :tag => json_publisher
|
||||
end if @build_list.publisher
|
||||
|
||||
inc_repos = Repository.includes(:platform).where(:id => @build_list.include_repos)
|
||||
json.include_repos inc_repos do |json_include_repos, repo|
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
.rightlist
|
||||
= link_to @build_list.user.try(:fullname), @build_list.user
|
||||
.both
|
||||
.leftlist= t("activerecord.attributes.build_list.publisher")
|
||||
.rightlist
|
||||
= link_to @build_list.publisher.try(:fullname), @build_list.publisher if @build_list.publisher
|
||||
.both
|
||||
.leftlist= t("activerecord.attributes.build_list.build_for_platform")
|
||||
.rightlist
|
||||
- bfp = @build_list.build_for_platform
|
||||
|
|
|
@ -29,6 +29,7 @@ en:
|
|||
auto_publish: Automated publising
|
||||
project_version: Version
|
||||
user: User
|
||||
publisher: Publisher
|
||||
preferences: Preferences
|
||||
started_at: Build started at
|
||||
duration: Build duration in seconds
|
||||
|
|
|
@ -29,6 +29,7 @@ ru:
|
|||
auto_publish: Автоматическая публикация
|
||||
project_version: Версия
|
||||
user: Пользователь
|
||||
publisher: Публикатор
|
||||
preferences: Настройки
|
||||
duration: Длительность билда в секундах
|
||||
mass_build_id: Массовая сборка
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddPublishedUserToBuildList < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :build_lists, :publisher_id, :integer
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130327120129) do
|
||||
ActiveRecord::Schema.define(:version => 20130328112110) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -137,6 +137,7 @@ ActiveRecord::Schema.define(:version => 20130327120129) do
|
|||
t.boolean "auto_create_container", :default => false
|
||||
t.text "extra_repositories"
|
||||
t.text "extra_build_lists"
|
||||
t.integer "publisher_id"
|
||||
end
|
||||
|
||||
add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"
|
||||
|
|
Loading…
Reference in New Issue