#452: added "Builds settings" for user
This commit is contained in:
parent
6d3498c4e5
commit
2a01474d03
|
@ -13,13 +13,12 @@ class Users::SettingsController < Users::BaseController
|
|||
@user.send_confirmation_instructions
|
||||
end
|
||||
flash[:notice] = t('flash.user.saved')
|
||||
redirect_to profile_settings_path
|
||||
else
|
||||
redirect_to profile_settings_path and return
|
||||
end
|
||||
flash[:error] = t('flash.user.save_error')
|
||||
flash[:warning] = @user.errors.full_messages.join('. ')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def reset_auth_token
|
||||
@user.reset_authentication_token!
|
||||
|
@ -31,12 +30,10 @@ class Users::SettingsController < Users::BaseController
|
|||
if request.patch?
|
||||
if @user.update_with_password(params[:user])
|
||||
flash[:notice] = t('flash.user.saved')
|
||||
redirect_to private_settings_path
|
||||
else
|
||||
redirect_to private_settings_path and return
|
||||
end
|
||||
flash[:error] = t('flash.user.save_error')
|
||||
flash[:warning] = @user.errors.full_messages.join('. ')
|
||||
render(action: :private)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -44,11 +41,21 @@ class Users::SettingsController < Users::BaseController
|
|||
if request.patch?
|
||||
if @user.notifier.update_attributes(params[:settings_notifier])
|
||||
flash[:notice] = I18n.t("flash.settings.saved")
|
||||
redirect_to notifiers_settings_path
|
||||
else
|
||||
redirect_to notifiers_settings_path and return
|
||||
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
|
||||
|
|
|
@ -5,6 +5,7 @@ class BuildList < ActiveRecord::Base
|
|||
include Feed::BuildList
|
||||
include BuildListObserver
|
||||
include EventLoggable
|
||||
include ExternalNodable
|
||||
|
||||
self.per_page = 25
|
||||
|
||||
|
@ -32,7 +33,6 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
RELEASE_UPDATE_TYPES = [UPDATE_TYPE_BUGFIX, UPDATE_TYPE_SECURITY]
|
||||
EXTRA_PARAMS = %w[cfg_options cfg_urpm_options build_src_rpm build_rpm]
|
||||
EXTERNAL_NODES = %w[owned everything]
|
||||
|
||||
AUTO_PUBLISH_STATUSES = [
|
||||
AUTO_PUBLISH_STATUS_NONE = 'none',
|
||||
|
@ -50,7 +50,6 @@ class BuildList < ActiveRecord::Base
|
|||
presence: true
|
||||
|
||||
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 :update_type, inclusion: UPDATE_TYPES,
|
||||
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,
|
||||
:arch_id, :project_id, :save_to_repository_id, :update_type,
|
||||
: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,
|
||||
: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
|
||||
include ExternalNodable
|
||||
|
||||
AUTO_PUBLISH_STATUSES = %w(none default testing)
|
||||
EXTERNAL_NODES = %w(owned everything)
|
||||
|
||||
STATUSES, HUMAN_STATUSES = [], {}
|
||||
[
|
||||
|
@ -48,8 +48,7 @@ class MassBuild < ActiveRecord::Base
|
|||
attr_accessible :arches, :auto_publish_status, :projects_list, :build_for_platform_id,
|
||||
:extra_repositories, :extra_build_lists, :increase_release_tag,
|
||||
:use_cached_chroot, :use_extra_tests, :description, :extra_mass_builds,
|
||||
:include_testing_subrepository, :auto_create_container, :external_nodes,
|
||||
:repositories
|
||||
:include_testing_subrepository, :auto_create_container, :repositories
|
||||
|
||||
validates :save_to_platform_id,
|
||||
:build_for_platform_id,
|
||||
|
@ -58,10 +57,6 @@ class MassBuild < ActiveRecord::Base
|
|||
:user_id,
|
||||
presence: true
|
||||
|
||||
validates :external_nodes,
|
||||
inclusion: { in: EXTERNAL_NODES },
|
||||
allow_blank: true
|
||||
|
||||
validates :projects_list,
|
||||
presence: true,
|
||||
length: { maximum: 500_000 }
|
||||
|
|
|
@ -19,6 +19,7 @@ class User < Avatar
|
|||
devise :omniauthable, omniauth_providers: [:facebook, :google_oauth2, :github]
|
||||
|
||||
has_one :notifier, class_name: 'SettingsNotifier', dependent: :destroy #:notifier
|
||||
has_one :builds_setting, class_name: 'UserBuildsSetting', 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
|
||||
i.fa.fa-cog>
|
||||
= 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)
|
||||
a href=notifiers_settings_path
|
||||
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
|
||||
profile: Profile
|
||||
settings: Settings
|
||||
builds_settings: Builds settings
|
||||
new_header: New user
|
||||
edit_header: Edit
|
||||
list_header: Users
|
||||
|
|
|
@ -248,6 +248,8 @@ Rosa::Application.routes.draw do
|
|||
patch :private
|
||||
get :notifiers
|
||||
patch :notifiers
|
||||
get :builds_settings
|
||||
patch :builds_settings
|
||||
put :reset_auth_token
|
||||
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.
|
||||
|
||||
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
|
||||
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"
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue