20160307000001_only_one_group.rb 4.4 KB

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