Merge pull request #499 from warpc/478-project_build_failed

[refs #478] Add js handler to disable frozen platforms and their reps
This commit is contained in:
Vladimir Sharshov 2012-05-24 03:39:55 -07:00
commit 0d3e06b5d9
5 changed files with 28 additions and 3 deletions

View File

@ -45,6 +45,26 @@ $(document).ready(function() {
$('.build_bpl_ids').click(function() {
return false;
});
$("select#build_list_update_type").change(function() {
if ( $(this).val() == "bugfix" || $(this).val() == "security" ) {
$("select#build_list_save_to_platform_id option").each(function(i,el) {
$(el).removeAttr("disabled");
});
} else {
$("select#build_list_save_to_platform_id option").each(function(i,el) {
if ( $.inArray(parseInt($(el).attr("value")), FROZEN_PLS) == 0 ) {
$(el).attr("disabled", "disabled");
// If disabled option is selected - select blank repository (it is always first):
if ( $(el).attr("selected") ) {
$( $("select#build_list_save_to_platform_id option")[0] ).attr("selected", "selected");
}
}
});
}
});
$("select#build_list_update_type").trigger('change');
});
function setPlChecked(pointer, checked) {

View File

@ -17,9 +17,9 @@ class BuildList < ActiveRecord::Base
validates_numericality_of :priority, :greater_than_or_equal_to => 0
validates :update_type, :inclusion => UPDATE_TYPES,
:unless => Proc.new { |b| b.save_to_platform.released }
validates :update_type, :inclusion => RELEASE_UPDATE_TYPES,
validates :update_type, :inclusion => {:in => RELEASE_UPDATE_TYPES, :message => I18n.t('flash.build_list.frozen_platform')},
:if => Proc.new { |b| b.save_to_platform.released && b.mass_build_id.nil?}
validate lambda {
validate lambda {
errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_platform')) if save_to_platform.platform_type == 'main' && save_to_platform_id != build_for_platform_id
}

View File

@ -11,7 +11,7 @@
.offset25{:style => 'padding-left: 25px'}= render 'include_repos', :platform => pl
%section.right
%h3= t("activerecord.attributes.build_list.save_to_platform")
.lineForm= f.select :save_to_platform_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]}
.lineForm= f.select :save_to_platform_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]}, :include_blank => true
%h3= t("activerecord.attributes.build_list.project_version")
- if controller.action_name == 'new'
.lineForm= f.select :project_version, @project.versions_for_group_select, :selected => "latest_" + @project.default_branch
@ -34,4 +34,7 @@
%br
= f.submit t("layout.projects.build_button")
:javascript
var FROZEN_PLS = [#{ @project.repositories.map { |r| r.id if r.platform.released }.delete_if { |i| i.nil? }.join(", ") }];
= render 'projects/base/submenu'

View File

@ -124,3 +124,4 @@ en:
no_arch_or_platform_selected: At least one of architecture of platform must selected
wrong_platform: Only the primary platform can be selected for the main repository!
can_not_published: Build can only be published with status "Build complete"
frozen_platform: In case of a repository for package storage with frozen platform allowed only bugfix and security updates

View File

@ -123,3 +123,4 @@ ru:
no_arch_or_platform_selected: Выберите хотя бы одну архитектуру и платформу
wrong_platform: Для основного репозитория (main) может быть выбран только его же основная платформа!
can_not_published: Опубликовать сборку можно только со статусом "Собран"
frozen_platform: В случае выбора репозитория для сохранения пакетов из замороженнной платформы разрешены только bugfix и security обновления