#53: added Publisher into BuildList

This commit is contained in:
Vokhmin Alexey V 2013-03-28 15:58:26 +04:00
parent 6a264e0b81
commit 05a8cec169
9 changed files with 30 additions and 3 deletions

View File

@ -33,6 +33,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController
end end
def publish def publish
@build_list.publisher = current_user
render_json :publish render_json :publish
end end
@ -47,7 +48,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController
private private
def render_json(action_name, action_method = nil) def render_json(action_name, action_method = nil)
if @build_list.try("can_#{action_name}?") && @build_list.send(action_method || action_name) if @build_list.save && @build_list.try("can_#{action_name}?") && @build_list.send(action_method || action_name)
render_json_response @build_list, t("layout.build_lists.#{action_name}_success") render_json_response @build_list, t("layout.build_lists.#{action_name}_success")
else else
render_validation_error @build_list, t("layout.build_lists.#{action_name}_fail") render_validation_error @build_list, t("layout.build_lists.#{action_name}_fail")

View File

@ -173,6 +173,7 @@ class Projects::BuildListsController < Projects::BaseController
end end
@build_list.publisher = current_user
if @build_list.save && @build_list.can_publish? && @build_list.now_publish if @build_list.save && @build_list.can_publish? && @build_list.now_publish
redirect_to :back, :notice => t('layout.build_lists.publish_success') redirect_to :back, :notice => t('layout.build_lists.publish_success')
else else

View File

@ -10,6 +10,7 @@ class BuildList < ActiveRecord::Base
belongs_to :save_to_repository, :class_name => 'Repository' belongs_to :save_to_repository, :class_name => 'Repository'
belongs_to :build_for_platform, :class_name => 'Platform' belongs_to :build_for_platform, :class_name => 'Platform'
belongs_to :user belongs_to :user
belongs_to :publisher, :class_name => 'User'
belongs_to :advisory belongs_to :advisory
belongs_to :mass_build, :counter_cache => true belongs_to :mass_build, :counter_cache => true
has_many :items, :class_name => "BuildList::Item", :dependent => :destroy has_many :items, :class_name => "BuildList::Item", :dependent => :destroy
@ -156,6 +157,7 @@ class BuildList < ActiveRecord::Base
after_transition :on => :published, after_transition :on => :published,
:do => [:set_version_and_tag, :actualize_packages] :do => [:set_version_and_tag, :actualize_packages]
after_transition :on => :publish, :do => :set_publisher
after_transition :on => :cancel, :do => :cancel_job after_transition :on => :cancel, :do => :cancel_job
after_transition :on => [:published, :fail_publish, :build_error, :tests_failed], :do => :notify_users 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? self.use_save_to_repository = true if save_to_platform.main?
end end
def set_publisher
self.publisher ||= user
save
end
def current_ability def current_ability
@current_ability ||= Ability.new(user) @current_ability ||= Ability.new(user)
end end

View File

@ -40,7 +40,13 @@ json.build_list do |json|
:json => json_build_for_platform :json => json_build_for_platform
end 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) inc_repos = Repository.includes(:platform).where(:id => @build_list.include_repos)
json.include_repos inc_repos do |json_include_repos, repo| json.include_repos inc_repos do |json_include_repos, repo|

View File

@ -25,6 +25,10 @@
.rightlist .rightlist
= link_to @build_list.user.try(:fullname), @build_list.user = link_to @build_list.user.try(:fullname), @build_list.user
.both .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") .leftlist= t("activerecord.attributes.build_list.build_for_platform")
.rightlist .rightlist
- bfp = @build_list.build_for_platform - bfp = @build_list.build_for_platform

View File

@ -29,6 +29,7 @@ en:
auto_publish: Automated publising auto_publish: Automated publising
project_version: Version project_version: Version
user: User user: User
publisher: Publisher
preferences: Preferences preferences: Preferences
started_at: Build started at started_at: Build started at
duration: Build duration in seconds duration: Build duration in seconds

View File

@ -29,6 +29,7 @@ ru:
auto_publish: Автоматическая публикация auto_publish: Автоматическая публикация
project_version: Версия project_version: Версия
user: Пользователь user: Пользователь
publisher: Публикатор
preferences: Настройки preferences: Настройки
duration: Длительность билда в секундах duration: Длительность билда в секундах
mass_build_id: Массовая сборка mass_build_id: Массовая сборка

View File

@ -0,0 +1,5 @@
class AddPublishedUserToBuildList < ActiveRecord::Migration
def change
add_column :build_lists, :publisher_id, :integer
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # 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| create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false t.integer "user_id", :null => false
@ -137,6 +137,7 @@ ActiveRecord::Schema.define(:version => 20130327120129) do
t.boolean "auto_create_container", :default => false t.boolean "auto_create_container", :default => false
t.text "extra_repositories" t.text "extra_repositories"
t.text "extra_build_lists" t.text "extra_build_lists"
t.integer "publisher_id"
end end
add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id" add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"