20161112000001_organization_domain_based_assignment.rb 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. class OrganizationDomainBasedAssignment < ActiveRecord::Migration[4.2]
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.exists?(name: 'system_init_done')
  5. add_column :organizations, :domain, :string, limit: 250, null: true, default: ''
  6. add_column :organizations, :domain_assignment, :boolean, null: false, default: false
  7. add_index :organizations, [:domain]
  8. # rubocop:disable Lint/BooleanSymbol
  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. # rubocop:enable Lint/BooleanSymbol
  48. ObjectManager::Attribute.add(
  49. force: true,
  50. object: 'Organization',
  51. name: 'domain',
  52. display: 'Domain',
  53. data_type: 'input',
  54. data_option: {
  55. type: 'text',
  56. maxlength: 150,
  57. null: true,
  58. item_class: 'formGroup--halfSize',
  59. },
  60. editable: false,
  61. active: true,
  62. screens: {
  63. edit: {
  64. '-all-' => {
  65. null: true,
  66. },
  67. },
  68. view: {
  69. '-all-' => {
  70. shown: true,
  71. },
  72. },
  73. },
  74. to_create: false,
  75. to_migrate: false,
  76. to_delete: false,
  77. position: 1420,
  78. updated_by_id: 1,
  79. created_by_id: 1,
  80. )
  81. Cache.clear
  82. end
  83. end