20160307000001_only_one_group.rb 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. class OnlyOneGroup < ActiveRecord::Migration
  2. def up
  3. ObjectManager::Attribute.add(
  4. force: true,
  5. object: 'Ticket',
  6. name: 'group_id',
  7. display: 'Group',
  8. data_type: 'select',
  9. data_option: {
  10. default: '',
  11. relation: 'Group',
  12. relation_condition: { access: 'rw' },
  13. nulloption: true,
  14. multiple: false,
  15. null: false,
  16. translate: false,
  17. only_shown_if_selectable: true,
  18. },
  19. editable: false,
  20. active: true,
  21. screens: {
  22. create_middle: {
  23. '-all-' => {
  24. null: false,
  25. item_class: 'column',
  26. },
  27. },
  28. edit: {
  29. Agent: {
  30. null: false,
  31. },
  32. },
  33. },
  34. to_create: false,
  35. to_migrate: false,
  36. to_delete: false,
  37. position: 25,
  38. created_by_id: 1,
  39. updated_by_id: 1,
  40. )
  41. ObjectManager::Attribute.add(
  42. force: true,
  43. object: 'User',
  44. name: 'street',
  45. display: 'Street',
  46. data_type: 'input',
  47. data_option: {
  48. type: 'text',
  49. maxlength: 100,
  50. null: true,
  51. },
  52. editable: true,
  53. active: false,
  54. screens: {
  55. signup: {},
  56. invite_agent: {},
  57. invite_customer: {},
  58. edit: {
  59. '-all-' => {
  60. null: true,
  61. },
  62. },
  63. view: {
  64. '-all-' => {
  65. shown: true,
  66. },
  67. },
  68. },
  69. to_create: false,
  70. to_migrate: false,
  71. to_delete: false,
  72. position: 1100,
  73. created_by_id: 1,
  74. updated_by_id: 1,
  75. )
  76. ObjectManager::Attribute.add(
  77. force: true,
  78. object: 'User',
  79. name: 'zip',
  80. display: 'Zip',
  81. data_type: 'input',
  82. data_option: {
  83. type: 'text',
  84. maxlength: 100,
  85. null: true,
  86. item_class: 'formGroup--halfSize',
  87. },
  88. editable: true,
  89. active: false,
  90. screens: {
  91. signup: {},
  92. invite_agent: {},
  93. invite_customer: {},
  94. edit: {
  95. '-all-' => {
  96. null: true,
  97. },
  98. },
  99. view: {
  100. '-all-' => {
  101. shown: true,
  102. },
  103. },
  104. },
  105. to_create: false,
  106. to_migrate: false,
  107. to_delete: false,
  108. position: 1200,
  109. created_by_id: 1,
  110. updated_by_id: 1,
  111. )
  112. ObjectManager::Attribute.add(
  113. force: true,
  114. object: 'User',
  115. name: 'city',
  116. display: 'City',
  117. data_type: 'input',
  118. data_option: {
  119. type: 'text',
  120. maxlength: 100,
  121. null: true,
  122. item_class: 'formGroup--halfSize',
  123. },
  124. editable: true,
  125. active: false,
  126. screens: {
  127. signup: {},
  128. invite_agent: {},
  129. invite_customer: {},
  130. edit: {
  131. '-all-' => {
  132. null: true,
  133. },
  134. },
  135. view: {
  136. '-all-' => {
  137. shown: true,
  138. },
  139. },
  140. },
  141. to_create: false,
  142. to_migrate: false,
  143. to_delete: false,
  144. position: 1300,
  145. created_by_id: 1,
  146. updated_by_id: 1,
  147. )
  148. ObjectManager::Attribute.add(
  149. force: true,
  150. object: 'User',
  151. name: 'address',
  152. display: 'Address',
  153. data_type: 'textarea',
  154. data_option: {
  155. type: 'text',
  156. maxlength: 500,
  157. null: true,
  158. item_class: 'formGroup--halfSize',
  159. },
  160. editable: true,
  161. active: true,
  162. screens: {
  163. signup: {},
  164. invite_agent: {},
  165. invite_customer: {},
  166. edit: {
  167. '-all-' => {
  168. null: true,
  169. },
  170. },
  171. view: {
  172. '-all-' => {
  173. shown: true,
  174. },
  175. },
  176. },
  177. to_create: false,
  178. to_migrate: false,
  179. to_delete: false,
  180. position: 1350,
  181. created_by_id: 1,
  182. updated_by_id: 1,
  183. )
  184. list = []
  185. User.all { |user|
  186. next if !user.zip.empty? && !user.city.empty? && !user.street.empty?
  187. #next if !user.address.empty?
  188. list.push user
  189. }
  190. list
  191. end
  192. end