2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2017-09-08 08:28:34 +00:00
|
|
|
class OrganizationDomainBasedAssignment < ActiveRecord::Migration[4.2]
|
2016-11-13 22:59:39 +00:00
|
|
|
def up
|
|
|
|
# return if it's a new setup
|
2020-08-03 08:35:43 +00:00
|
|
|
return if !Setting.exists?(name: 'system_init_done')
|
2016-11-13 22:59:39 +00:00
|
|
|
|
|
|
|
add_column :organizations, :domain, :string, limit: 250, null: true, default: ''
|
|
|
|
add_column :organizations, :domain_assignment, :boolean, null: false, default: false
|
|
|
|
add_index :organizations, [:domain]
|
|
|
|
|
2018-04-12 14:57:37 +00:00
|
|
|
# rubocop:disable Lint/BooleanSymbol
|
2016-11-13 22:59:39 +00:00
|
|
|
ObjectManager::Attribute.add(
|
2018-12-19 17:31:51 +00:00
|
|
|
force: true,
|
|
|
|
object: 'Organization',
|
|
|
|
name: 'domain_assignment',
|
|
|
|
display: 'Domain based assignment',
|
|
|
|
data_type: 'boolean',
|
|
|
|
data_option: {
|
|
|
|
null: true,
|
|
|
|
default: false,
|
|
|
|
note: 'Assign Users based on users domain.',
|
2016-11-13 22:59:39 +00:00
|
|
|
item_class: 'formGroup--halfSize',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {
|
|
|
|
true: 'yes',
|
2016-11-13 22:59:39 +00:00
|
|
|
false: 'no',
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
translate: true,
|
2016-11-13 22:59:39 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
editable: false,
|
|
|
|
active: true,
|
|
|
|
screens: {
|
2016-11-13 22:59:39 +00:00
|
|
|
edit: {
|
|
|
|
Admin: {
|
|
|
|
null: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
view: {
|
|
|
|
'-all-' => {
|
|
|
|
shown: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
to_create: false,
|
|
|
|
to_migrate: false,
|
|
|
|
to_delete: false,
|
|
|
|
position: 1410,
|
2016-11-13 22:59:39 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
2018-04-12 14:57:37 +00:00
|
|
|
# rubocop:enable Lint/BooleanSymbol
|
2016-11-13 22:59:39 +00:00
|
|
|
|
|
|
|
ObjectManager::Attribute.add(
|
2018-12-19 17:31:51 +00:00
|
|
|
force: true,
|
|
|
|
object: 'Organization',
|
|
|
|
name: 'domain',
|
|
|
|
display: 'Domain',
|
|
|
|
data_type: 'input',
|
|
|
|
data_option: {
|
|
|
|
type: 'text',
|
|
|
|
maxlength: 150,
|
|
|
|
null: true,
|
2016-11-13 22:59:39 +00:00
|
|
|
item_class: 'formGroup--halfSize',
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
editable: false,
|
|
|
|
active: true,
|
|
|
|
screens: {
|
2016-11-13 22:59:39 +00:00
|
|
|
edit: {
|
|
|
|
'-all-' => {
|
|
|
|
null: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
view: {
|
|
|
|
'-all-' => {
|
|
|
|
shown: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
to_create: false,
|
|
|
|
to_migrate: false,
|
|
|
|
to_delete: false,
|
|
|
|
position: 1420,
|
2016-11-13 22:59:39 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
|
|
|
Cache.clear
|
|
|
|
end
|
|
|
|
end
|