#452: added "Builds settings" for user
This commit is contained in:
parent
6d3498c4e5
commit
2a01474d03
|
@ -13,11 +13,10 @@ class Users::SettingsController < Users::BaseController
|
||||||
@user.send_confirmation_instructions
|
@user.send_confirmation_instructions
|
||||||
end
|
end
|
||||||
flash[:notice] = t('flash.user.saved')
|
flash[:notice] = t('flash.user.saved')
|
||||||
redirect_to profile_settings_path
|
redirect_to profile_settings_path and return
|
||||||
else
|
|
||||||
flash[:error] = t('flash.user.save_error')
|
|
||||||
flash[:warning] = @user.errors.full_messages.join('. ')
|
|
||||||
end
|
end
|
||||||
|
flash[:error] = t('flash.user.save_error')
|
||||||
|
flash[:warning] = @user.errors.full_messages.join('. ')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -31,12 +30,10 @@ class Users::SettingsController < Users::BaseController
|
||||||
if request.patch?
|
if request.patch?
|
||||||
if @user.update_with_password(params[:user])
|
if @user.update_with_password(params[:user])
|
||||||
flash[:notice] = t('flash.user.saved')
|
flash[:notice] = t('flash.user.saved')
|
||||||
redirect_to private_settings_path
|
redirect_to private_settings_path and return
|
||||||
else
|
|
||||||
flash[:error] = t('flash.user.save_error')
|
|
||||||
flash[:warning] = @user.errors.full_messages.join('. ')
|
|
||||||
render(action: :private)
|
|
||||||
end
|
end
|
||||||
|
flash[:error] = t('flash.user.save_error')
|
||||||
|
flash[:warning] = @user.errors.full_messages.join('. ')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -44,10 +41,20 @@ class Users::SettingsController < Users::BaseController
|
||||||
if request.patch?
|
if request.patch?
|
||||||
if @user.notifier.update_attributes(params[:settings_notifier])
|
if @user.notifier.update_attributes(params[:settings_notifier])
|
||||||
flash[:notice] = I18n.t("flash.settings.saved")
|
flash[:notice] = I18n.t("flash.settings.saved")
|
||||||
redirect_to notifiers_settings_path
|
redirect_to notifiers_settings_path and return
|
||||||
else
|
|
||||||
flash[:error] = I18n.t("flash.settings.save_error")
|
|
||||||
end
|
end
|
||||||
|
flash[:error] = I18n.t("flash.settings.save_error")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def builds_settings
|
||||||
|
@user.builds_setting ||= @user.build_builds_setting
|
||||||
|
if request.patch?
|
||||||
|
if @user.builds_setting.update_attributes(params[:user_builds_setting])
|
||||||
|
flash[:notice] = I18n.t("flash.settings.saved")
|
||||||
|
redirect_to builds_settings_settings_path and return
|
||||||
|
end
|
||||||
|
flash[:error] = I18n.t("flash.settings.save_error")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ class BuildList < ActiveRecord::Base
|
||||||
include Feed::BuildList
|
include Feed::BuildList
|
||||||
include BuildListObserver
|
include BuildListObserver
|
||||||
include EventLoggable
|
include EventLoggable
|
||||||
|
include ExternalNodable
|
||||||
|
|
||||||
self.per_page = 25
|
self.per_page = 25
|
||||||
|
|
||||||
|
@ -32,7 +33,6 @@ class BuildList < ActiveRecord::Base
|
||||||
|
|
||||||
RELEASE_UPDATE_TYPES = [UPDATE_TYPE_BUGFIX, UPDATE_TYPE_SECURITY]
|
RELEASE_UPDATE_TYPES = [UPDATE_TYPE_BUGFIX, UPDATE_TYPE_SECURITY]
|
||||||
EXTRA_PARAMS = %w[cfg_options cfg_urpm_options build_src_rpm build_rpm]
|
EXTRA_PARAMS = %w[cfg_options cfg_urpm_options build_src_rpm build_rpm]
|
||||||
EXTERNAL_NODES = %w[owned everything]
|
|
||||||
|
|
||||||
AUTO_PUBLISH_STATUSES = [
|
AUTO_PUBLISH_STATUSES = [
|
||||||
AUTO_PUBLISH_STATUS_NONE = 'none',
|
AUTO_PUBLISH_STATUS_NONE = 'none',
|
||||||
|
@ -50,7 +50,6 @@ class BuildList < ActiveRecord::Base
|
||||||
presence: true
|
presence: true
|
||||||
|
|
||||||
validates_numericality_of :priority, greater_than_or_equal_to: 0
|
validates_numericality_of :priority, greater_than_or_equal_to: 0
|
||||||
validates :external_nodes, inclusion: { in: EXTERNAL_NODES }, allow_blank: true
|
|
||||||
validates :auto_publish_status, inclusion: { in: AUTO_PUBLISH_STATUSES }
|
validates :auto_publish_status, inclusion: { in: AUTO_PUBLISH_STATUSES }
|
||||||
validates :update_type, inclusion: UPDATE_TYPES,
|
validates :update_type, inclusion: UPDATE_TYPES,
|
||||||
unless: Proc.new { |b| b.advisory.present? }
|
unless: Proc.new { |b| b.advisory.present? }
|
||||||
|
@ -80,7 +79,7 @@ class BuildList < ActiveRecord::Base
|
||||||
attr_accessible :include_repos, :auto_publish, :build_for_platform_id, :commit_hash,
|
attr_accessible :include_repos, :auto_publish, :build_for_platform_id, :commit_hash,
|
||||||
:arch_id, :project_id, :save_to_repository_id, :update_type,
|
:arch_id, :project_id, :save_to_repository_id, :update_type,
|
||||||
:save_to_platform_id, :project_version, :auto_create_container,
|
:save_to_platform_id, :project_version, :auto_create_container,
|
||||||
:extra_repositories, :extra_build_lists, :extra_params, :external_nodes,
|
:extra_repositories, :extra_build_lists, :extra_params,
|
||||||
:include_testing_subrepository, :auto_publish_status,
|
:include_testing_subrepository, :auto_publish_status,
|
||||||
:use_cached_chroot, :use_extra_tests, :save_buildroot
|
:use_cached_chroot, :use_extra_tests, :save_buildroot
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
module ExternalNodable
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
EXTERNAL_NODES = %w(owned everything)
|
||||||
|
|
||||||
|
included do
|
||||||
|
validates :external_nodes,
|
||||||
|
inclusion: { in: EXTERNAL_NODES },
|
||||||
|
allow_blank: true
|
||||||
|
|
||||||
|
|
||||||
|
attr_accessible :external_nodes
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,7 +1,7 @@
|
||||||
class MassBuild < ActiveRecord::Base
|
class MassBuild < ActiveRecord::Base
|
||||||
|
include ExternalNodable
|
||||||
|
|
||||||
AUTO_PUBLISH_STATUSES = %w(none default testing)
|
AUTO_PUBLISH_STATUSES = %w(none default testing)
|
||||||
EXTERNAL_NODES = %w(owned everything)
|
|
||||||
|
|
||||||
STATUSES, HUMAN_STATUSES = [], {}
|
STATUSES, HUMAN_STATUSES = [], {}
|
||||||
[
|
[
|
||||||
|
@ -48,8 +48,7 @@ class MassBuild < ActiveRecord::Base
|
||||||
attr_accessible :arches, :auto_publish_status, :projects_list, :build_for_platform_id,
|
attr_accessible :arches, :auto_publish_status, :projects_list, :build_for_platform_id,
|
||||||
:extra_repositories, :extra_build_lists, :increase_release_tag,
|
:extra_repositories, :extra_build_lists, :increase_release_tag,
|
||||||
:use_cached_chroot, :use_extra_tests, :description, :extra_mass_builds,
|
:use_cached_chroot, :use_extra_tests, :description, :extra_mass_builds,
|
||||||
:include_testing_subrepository, :auto_create_container, :external_nodes,
|
:include_testing_subrepository, :auto_create_container, :repositories
|
||||||
:repositories
|
|
||||||
|
|
||||||
validates :save_to_platform_id,
|
validates :save_to_platform_id,
|
||||||
:build_for_platform_id,
|
:build_for_platform_id,
|
||||||
|
@ -58,10 +57,6 @@ class MassBuild < ActiveRecord::Base
|
||||||
:user_id,
|
:user_id,
|
||||||
presence: true
|
presence: true
|
||||||
|
|
||||||
validates :external_nodes,
|
|
||||||
inclusion: { in: EXTERNAL_NODES },
|
|
||||||
allow_blank: true
|
|
||||||
|
|
||||||
validates :projects_list,
|
validates :projects_list,
|
||||||
presence: true,
|
presence: true,
|
||||||
length: { maximum: 500_000 }
|
length: { maximum: 500_000 }
|
||||||
|
|
|
@ -18,7 +18,8 @@ class User < Avatar
|
||||||
:recoverable, :rememberable, :validatable, :lockable, :confirmable
|
:recoverable, :rememberable, :validatable, :lockable, :confirmable
|
||||||
devise :omniauthable, omniauth_providers: [:facebook, :google_oauth2, :github]
|
devise :omniauthable, omniauth_providers: [:facebook, :google_oauth2, :github]
|
||||||
|
|
||||||
has_one :notifier, class_name: 'SettingsNotifier', dependent: :destroy #:notifier
|
has_one :notifier, class_name: 'SettingsNotifier', dependent: :destroy #:notifier
|
||||||
|
has_one :builds_setting, class_name: 'UserBuildsSetting', dependent: :destroy
|
||||||
|
|
||||||
has_many :activity_feeds, dependent: :destroy
|
has_many :activity_feeds, dependent: :destroy
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
class UserBuildsSetting < ActiveRecord::Base
|
||||||
|
include ExternalNodable
|
||||||
|
|
||||||
|
belongs_to :user
|
||||||
|
|
||||||
|
validates :user, presence: true
|
||||||
|
|
||||||
|
attr_accessible :platforms,
|
||||||
|
:use_extra_tests
|
||||||
|
|
||||||
|
end
|
|
@ -25,6 +25,10 @@
|
||||||
a href=private_settings_path
|
a href=private_settings_path
|
||||||
i.fa.fa-cog>
|
i.fa.fa-cog>
|
||||||
= t('layout.users.user_private_settings')
|
= t('layout.users.user_private_settings')
|
||||||
|
li class=('active' if act == :builds_settings)
|
||||||
|
a href=builds_settings_settings_path
|
||||||
|
i.fa.fa-cogs>
|
||||||
|
= t('layout.users.builds_settings')
|
||||||
li class=('active' if act == :notifiers)
|
li class=('active' if act == :notifiers)
|
||||||
a href=notifiers_settings_path
|
a href=notifiers_settings_path
|
||||||
i.fa.fa-inbox>
|
i.fa.fa-inbox>
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
- set_meta_tags title: t('.title')
|
||||||
|
= render 'users/base/submenu'
|
||||||
|
|
||||||
|
|
||||||
|
.container.col-md-offset-2.col-md-8
|
||||||
|
.row
|
||||||
|
= simple_form_for @user.builds_setting,
|
||||||
|
url: builds_settings_settings_path,
|
||||||
|
wrapper: :horizontal_form,
|
||||||
|
wrapper_mappings: { boolean: :horizontal_boolean } do |f|
|
||||||
|
|
||||||
|
fieldset
|
||||||
|
legend
|
||||||
|
= t('.heading')
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-sm-4
|
||||||
|
= f.label :platforms
|
||||||
|
= f.hint :platforms
|
||||||
|
= f.collection_check_boxes :platforms, availables_main_platforms, :id, :name,
|
||||||
|
checked: @user.builds_setting.platforms,
|
||||||
|
collection_wrapper_tag: :div,
|
||||||
|
collection_wrapper_class: 'form-group',
|
||||||
|
item_wrapper_tag: :div,
|
||||||
|
item_wrapper_class: 'col-sm-9' do |b|
|
||||||
|
.checkbox
|
||||||
|
= b.label { b.check_box + b.text }
|
||||||
|
|
||||||
|
|
||||||
|
.col-sm-8
|
||||||
|
= f.input :external_nodes, collection: external_nodes, include_blank: true
|
||||||
|
= f.input :use_extra_tests, as: :boolean
|
||||||
|
|
||||||
|
.clearfix
|
||||||
|
hr
|
||||||
|
= submit_button_tag
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
en:
|
||||||
|
|
||||||
|
users:
|
||||||
|
settings:
|
||||||
|
builds_settings:
|
||||||
|
title: "Builds settings"
|
||||||
|
heading: "Builds settings"
|
||||||
|
|
||||||
|
simple_form:
|
||||||
|
labels:
|
||||||
|
user_builds_setting:
|
||||||
|
platforms: "Platforms"
|
||||||
|
external_nodes: "External nodes"
|
||||||
|
use_extra_tests: "Use extra tests"
|
||||||
|
# placeholders:
|
||||||
|
hints:
|
||||||
|
user_builds_setting:
|
||||||
|
platforms: "Select a platforms that you'd like to use."
|
||||||
|
external_nodes: "Select the type of nodes that you'd like to use."
|
||||||
|
use_extra_tests: "Uncheck this to disable extra tests."
|
|
@ -0,0 +1,20 @@
|
||||||
|
ru:
|
||||||
|
|
||||||
|
users:
|
||||||
|
settings:
|
||||||
|
builds_settings:
|
||||||
|
title: "Настройки сборок"
|
||||||
|
heading: "Настройки сборок"
|
||||||
|
|
||||||
|
simple_form:
|
||||||
|
labels:
|
||||||
|
user_builds_setting:
|
||||||
|
platforms: "Платформы"
|
||||||
|
external_nodes: "Дополнительные ноды"
|
||||||
|
use_extra_tests: "Использовать дополнительные тесты"
|
||||||
|
# placeholders:
|
||||||
|
hints:
|
||||||
|
user_builds_setting:
|
||||||
|
platforms: "Выберите платформы, которые вы хотели бы использовать."
|
||||||
|
external_nodes: "Выберите ноды, которые вы хотели бы использовать."
|
||||||
|
use_extra_tests: "Снимите тут, чтобы отключить дополнительные тесты."
|
|
@ -5,6 +5,7 @@ en:
|
||||||
new: Create
|
new: Create
|
||||||
profile: Profile
|
profile: Profile
|
||||||
settings: Settings
|
settings: Settings
|
||||||
|
builds_settings: Builds settings
|
||||||
new_header: New user
|
new_header: New user
|
||||||
edit_header: Edit
|
edit_header: Edit
|
||||||
list_header: Users
|
list_header: Users
|
||||||
|
|
|
@ -248,6 +248,8 @@ Rosa::Application.routes.draw do
|
||||||
patch :private
|
patch :private
|
||||||
get :notifiers
|
get :notifiers
|
||||||
patch :notifiers
|
patch :notifiers
|
||||||
|
get :builds_settings
|
||||||
|
patch :builds_settings
|
||||||
put :reset_auth_token
|
put :reset_auth_token
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
class CreateUserBuildsSettings < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :user_builds_settings do |t|
|
||||||
|
t.integer :user_id, null: false
|
||||||
|
t.text :platforms, null: false, default: [], array: true
|
||||||
|
t.boolean :use_extra_tests, null: false, default: true
|
||||||
|
t.string :external_nodes
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :user_builds_settings, :user_id, unique: true
|
||||||
|
end
|
||||||
|
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150112204757) do
|
ActiveRecord::Schema.define(version: 20150210192749) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -628,4 +628,12 @@ ActiveRecord::Schema.define(version: 20150112204757) do
|
||||||
t.index ["subject_id", "subject_type"], :name => "index_tokens_on_subject_id_and_subject_type"
|
t.index ["subject_id", "subject_type"], :name => "index_tokens_on_subject_id_and_subject_type"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "user_builds_settings", force: true do |t|
|
||||||
|
t.integer "user_id", null: false
|
||||||
|
t.text "platforms", default: [], null: false, array: true
|
||||||
|
t.boolean "use_extra_tests", default: true, null: false
|
||||||
|
t.string "external_nodes"
|
||||||
|
t.index ["user_id"], :name => "index_user_builds_settings_on_user_id", :unique => true
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue