20161112000001_organization_domain_based_assignment.rb 1.9 KB

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