[refs #442] Change cancel btn. Move some actions to mass_builds controller. Add more ability rights

This commit is contained in:
konstantin.grabar 2012-07-02 18:50:47 +04:00
parent 004f603e02
commit 8f9a6ee2d2
6 changed files with 31 additions and 20 deletions

View File

@ -0,0 +1,15 @@
class MassBuildsController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource
def cancel_mass_build
@mass_build.cancel_all
flash[:notice] = t("flash.platform.cancel_mass_build")
redirect_to mass_builds_platform_path(@mass_build.platform)
end
def failed_builds_list
render :text => @mass_build.generate_failed_builds_list
end
end

View File

@ -31,18 +31,6 @@ class Platforms::PlatformsController < Platforms::BaseController
render :action => :build_all
end
def cancel_mass_build
@mass_build = MassBuild.find params[:mass_build_id]
@mass_build.cancel_all
flash[:notice] = t("flash.platform.cancel_mass_build")
redirect_to mass_builds_platform_path(@mass_build.platform)
end
def failed_builds_list
@mass_build = MassBuild.find params[:mass_build_id]
render :text => @mass_build.generate_failed_builds_list
end
def index
@platforms = @platforms.accessible_by(current_ability, :related).paginate(:page => params[:page], :per_page => 20)
end

View File

@ -83,7 +83,9 @@ class Ability
can [:read, :related, :members], Platform, :owner_type => 'Group', :owner_id => user.group_ids
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, :cancel_mass_build, :failed_builds_list] , Platform) {|platform| owner? platform}
can([:destroy, :members, :add_member, :remove_member, :remove_members, :build_all, :mass_builds] , Platform) {|platform| owner?(platform) || local_admin?(platform) }
can(:failed_builds_list, MassBuild) {|mass_build| owner?(mass_build.platform) || local_admin?(mass_build.platform) }
can(:cancel_mass_build, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build }
can [:autocomplete_user_uname, :read_advisories, :advisories], Platform
can [:read, :projects_list], Repository, :platform => {:visibility => 'open'}
@ -127,7 +129,9 @@ class Ability
cannot [:members, :add_member, :remove_member, :remove_members], Platform, :platform_type => 'personal'
cannot [:create, :update, :destroy, :clone], Product, :platform => {:platform_type => 'personal'}
cannot [:clone, :build_all, :mass_builds, :cancel_mass_build, :failed_builds_list], Platform, :platform_type => 'personal'
cannot [:clone, :build_all, :mass_builds], Platform, :platform_type => 'personal'
cannot(:failed_builds_list, MassBuild) {|mass_build| mass_build.platform.platform_type == 'personal'}
cannot(:cancel_mass_build, MassBuild) { |mass_build| mass_build.platform.platform_type == 'personal' && mass_build.stop_build }
can :create, Subscribe do |subscribe|
!subscribe.subscribeable.subscribes.exists?(:user_id => user.id)

View File

@ -57,5 +57,5 @@ class MassBuild < ActiveRecord::Base
bl.cancel
end
end
later :cancel_all, :loner => true, :queue => :clone_build
later :cancel_all, :queue => :clone_build
end

View File

@ -43,8 +43,8 @@
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'index'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {}))
= mass_build.read_attribute "#{status}_count"
.both
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platforms_path(:mass_build_id => mass_build.id), :target => "_blank"
%td= link_to t("layout.mass_builds.cancel_mass_build"), cancel_mass_build_platforms_path(:mass_build_id => mass_build.id), :method => :post, :confirm => t("layout.mass_builds.cancel_confirm")
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id), :target => "_blank" if can?(:failed_builds_list, mass_build)
%td= link_to image_tag('x.png'), cancel_mass_build_platform_mass_build_path(@platform, mass_build.id), :method => :post, :confirm => t("layout.mass_builds.cancel_confirm") if can?(:cancel_mass_build, mass_build)
%td
%a.toggle_btn{:href => "#toggle_#{ mass_build.id }", :'data-target' => "#toggle_#{ mass_build.id }"}= t("layout.mass_builds.extended_data")
.toggle{:id => "toggle_#{ mass_build.id }"}

View File

@ -55,10 +55,14 @@ Rosa::Application.routes.draw do
get :mass_builds
get :advisories
end
collection do
get :failed_builds_list
post :cancel_mass_build
resources :mass_builds do
member do
get :failed_builds_list
post :cancel_mass_build
end
end
get :autocomplete_user_uname, :on => :collection
resources :repositories do
member do