20161112000001_organization_domain_based_assignment.rb 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class OrganizationDomainBasedAssignment < ActiveRecord::Migration[4.2]
  3. def up
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. add_column :organizations, :domain, :string, limit: 250, null: true, default: ''
  7. add_column :organizations, :domain_assignment, :boolean, null: false, default: false
  8. add_index :organizations, [:domain]
  9. # rubocop:disable Lint/BooleanSymbol
  10. ObjectManager::Attribute.add(
  11. force: true,
  12. object: 'Organization',
  13. name: 'domain_assignment',
  14. display: 'Domain based assignment',
  15. data_type: 'boolean',
  16. data_option: {
  17. null: true,
  18. default: false,
  19. note: 'Assign Users based on users domain.',
  20. item_class: 'formGroup--halfSize',
  21. options: {
  22. true: 'yes',
  23. false: 'no',
  24. },
  25. translate: true,
  26. },
  27. editable: false,
  28. active: true,
  29. screens: {
  30. edit: {
  31. Admin: {
  32. null: false,
  33. },
  34. },
  35. view: {
  36. '-all-' => {
  37. shown: true,
  38. },
  39. },
  40. },
  41. to_create: false,
  42. to_migrate: false,
  43. to_delete: false,
  44. position: 1410,
  45. updated_by_id: 1,
  46. created_by_id: 1,
  47. )
  48. # rubocop:enable Lint/BooleanSymbol
  49. ObjectManager::Attribute.add(
  50. force: true,
  51. object: 'Organization',
  52. name: 'domain',
  53. display: 'Domain',
  54. data_type: 'input',
  55. data_option: {
  56. type: 'text',
  57. maxlength: 150,
  58. null: true,
  59. item_class: 'formGroup--halfSize',
  60. },
  61. editable: false,
  62. active: true,
  63. screens: {
  64. edit: {
  65. '-all-' => {
  66. null: true,
  67. },
  68. },
  69. view: {
  70. '-all-' => {
  71. shown: true,
  72. },
  73. },
  74. },
  75. to_create: false,
  76. to_migrate: false,
  77. to_delete: false,
  78. position: 1420,
  79. updated_by_id: 1,
  80. created_by_id: 1,
  81. )
  82. Rails.cache.clear
  83. end
  84. end