20160217000001_object_manager_update_user.rb 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. class ObjectManagerUpdateUser < 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. UserInfo.current_user_id = 1
  6. ObjectManager::Attribute.add(
  7. force: true,
  8. object: 'User',
  9. name: 'login',
  10. display: 'Login',
  11. data_type: 'input',
  12. data_option: {
  13. type: 'text',
  14. maxlength: 100,
  15. null: true,
  16. autocapitalize: false,
  17. item_class: 'formGroup--halfSize',
  18. },
  19. editable: false,
  20. active: true,
  21. screens: {
  22. signup: {},
  23. invite_agent: {},
  24. invite_customer: {},
  25. edit: {},
  26. view: {
  27. '-all-' => {
  28. shown: false,
  29. },
  30. },
  31. },
  32. to_create: false,
  33. to_migrate: false,
  34. to_delete: false,
  35. position: 100,
  36. )
  37. ObjectManager::Attribute.add(
  38. force: true,
  39. object: 'User',
  40. name: 'firstname',
  41. display: 'Firstname',
  42. data_type: 'input',
  43. data_option: {
  44. type: 'text',
  45. maxlength: 150,
  46. null: false,
  47. item_class: 'formGroup--halfSize',
  48. },
  49. editable: false,
  50. active: true,
  51. screens: {
  52. signup: {
  53. '-all-' => {
  54. null: false,
  55. },
  56. },
  57. invite_agent: {
  58. '-all-' => {
  59. null: false,
  60. },
  61. },
  62. invite_customer: {
  63. '-all-' => {
  64. null: false,
  65. },
  66. },
  67. edit: {
  68. '-all-' => {
  69. null: false,
  70. },
  71. },
  72. view: {
  73. '-all-' => {
  74. shown: true,
  75. },
  76. },
  77. },
  78. to_create: false,
  79. to_migrate: false,
  80. to_delete: false,
  81. position: 200,
  82. )
  83. ObjectManager::Attribute.add(
  84. force: true,
  85. object: 'User',
  86. name: 'lastname',
  87. display: 'Lastname',
  88. data_type: 'input',
  89. data_option: {
  90. type: 'text',
  91. maxlength: 150,
  92. null: false,
  93. item_class: 'formGroup--halfSize',
  94. },
  95. editable: false,
  96. active: true,
  97. screens: {
  98. signup: {
  99. '-all-' => {
  100. null: false,
  101. },
  102. },
  103. invite_agent: {
  104. '-all-' => {
  105. null: false,
  106. },
  107. },
  108. invite_customer: {
  109. '-all-' => {
  110. null: false,
  111. },
  112. },
  113. edit: {
  114. '-all-' => {
  115. null: false,
  116. },
  117. },
  118. view: {
  119. '-all-' => {
  120. shown: true,
  121. },
  122. },
  123. },
  124. to_create: false,
  125. to_migrate: false,
  126. to_delete: false,
  127. position: 300,
  128. )
  129. ObjectManager::Attribute.add(
  130. force: true,
  131. object: 'User',
  132. name: 'email',
  133. display: 'Email',
  134. data_type: 'input',
  135. data_option: {
  136. type: 'email',
  137. maxlength: 150,
  138. null: false,
  139. item_class: 'formGroup--halfSize',
  140. },
  141. editable: false,
  142. active: true,
  143. screens: {
  144. signup: {
  145. '-all-' => {
  146. null: false,
  147. },
  148. },
  149. invite_agent: {
  150. '-all-' => {
  151. null: false,
  152. },
  153. },
  154. invite_customer: {
  155. '-all-' => {
  156. null: false,
  157. },
  158. },
  159. edit: {
  160. '-all-' => {
  161. null: false,
  162. },
  163. },
  164. view: {
  165. '-all-' => {
  166. shown: true,
  167. },
  168. },
  169. },
  170. to_create: false,
  171. to_migrate: false,
  172. to_delete: false,
  173. position: 400,
  174. )
  175. ObjectManager::Attribute.add(
  176. force: true,
  177. object: 'User',
  178. name: 'web',
  179. display: 'Web',
  180. data_type: 'input',
  181. data_option: {
  182. type: 'url',
  183. maxlength: 250,
  184. null: true,
  185. item_class: 'formGroup--halfSize',
  186. },
  187. editable: false,
  188. active: true,
  189. screens: {
  190. signup: {},
  191. invite_agent: {},
  192. invite_customer: {},
  193. edit: {
  194. '-all-' => {
  195. null: true,
  196. },
  197. },
  198. view: {
  199. '-all-' => {
  200. shown: true,
  201. },
  202. },
  203. },
  204. to_create: false,
  205. to_migrate: false,
  206. to_delete: false,
  207. position: 500,
  208. )
  209. ObjectManager::Attribute.add(
  210. force: true,
  211. object: 'User',
  212. name: 'phone',
  213. display: 'Phone',
  214. data_type: 'input',
  215. data_option: {
  216. type: 'tel',
  217. maxlength: 100,
  218. null: true,
  219. item_class: 'formGroup--halfSize',
  220. },
  221. editable: false,
  222. active: true,
  223. screens: {
  224. signup: {},
  225. invite_agent: {},
  226. invite_customer: {},
  227. edit: {
  228. '-all-' => {
  229. null: true,
  230. },
  231. },
  232. view: {
  233. '-all-' => {
  234. shown: true,
  235. },
  236. },
  237. },
  238. to_create: false,
  239. to_migrate: false,
  240. to_delete: false,
  241. position: 600,
  242. )
  243. ObjectManager::Attribute.add(
  244. force: true,
  245. object: 'User',
  246. name: 'mobile',
  247. display: 'Mobile',
  248. data_type: 'input',
  249. data_option: {
  250. type: 'tel',
  251. maxlength: 100,
  252. null: true,
  253. item_class: 'formGroup--halfSize',
  254. },
  255. editable: false,
  256. active: true,
  257. screens: {
  258. signup: {},
  259. invite_agent: {},
  260. invite_customer: {},
  261. edit: {
  262. '-all-' => {
  263. null: true,
  264. },
  265. },
  266. view: {
  267. '-all-' => {
  268. shown: true,
  269. },
  270. },
  271. },
  272. to_create: false,
  273. to_migrate: false,
  274. to_delete: false,
  275. position: 700,
  276. )
  277. ObjectManager::Attribute.add(
  278. force: true,
  279. object: 'User',
  280. name: 'fax',
  281. display: 'Fax',
  282. data_type: 'input',
  283. data_option: {
  284. type: 'tel',
  285. maxlength: 100,
  286. null: true,
  287. item_class: 'formGroup--halfSize',
  288. },
  289. editable: false,
  290. active: true,
  291. screens: {
  292. signup: {},
  293. invite_agent: {},
  294. invite_customer: {},
  295. edit: {
  296. '-all-' => {
  297. null: true,
  298. },
  299. },
  300. view: {
  301. '-all-' => {
  302. shown: true,
  303. },
  304. },
  305. },
  306. to_create: false,
  307. to_migrate: false,
  308. to_delete: false,
  309. position: 800,
  310. )
  311. ObjectManager::Attribute.add(
  312. force: true,
  313. object: 'User',
  314. name: 'organization_id',
  315. display: 'Organization',
  316. data_type: 'autocompletion_ajax',
  317. data_option: {
  318. multiple: false,
  319. nulloption: true,
  320. null: true,
  321. relation: 'Organization',
  322. item_class: 'formGroup--halfSize',
  323. },
  324. editable: false,
  325. active: true,
  326. screens: {
  327. signup: {},
  328. invite_agent: {},
  329. invite_customer: {
  330. '-all-' => {
  331. null: true,
  332. },
  333. },
  334. edit: {
  335. '-all-' => {
  336. null: true,
  337. },
  338. },
  339. view: {
  340. '-all-' => {
  341. shown: true,
  342. },
  343. },
  344. },
  345. to_create: false,
  346. to_migrate: false,
  347. to_delete: false,
  348. position: 900,
  349. )
  350. ObjectManager::Attribute.add(
  351. force: true,
  352. object: 'User',
  353. name: 'department',
  354. display: 'Department',
  355. data_type: 'input',
  356. data_option: {
  357. type: 'text',
  358. maxlength: 200,
  359. null: true,
  360. item_class: 'formGroup--halfSize',
  361. },
  362. editable: false,
  363. active: true,
  364. screens: {
  365. signup: {},
  366. invite_agent: {},
  367. invite_customer: {},
  368. edit: {
  369. '-all-' => {
  370. null: true,
  371. },
  372. },
  373. view: {
  374. '-all-' => {
  375. shown: true,
  376. },
  377. },
  378. },
  379. to_create: false,
  380. to_migrate: false,
  381. to_delete: false,
  382. position: 1000,
  383. )
  384. ObjectManager::Attribute.add(
  385. force: true,
  386. object: 'User',
  387. name: 'street',
  388. display: 'Street',
  389. data_type: 'input',
  390. data_option: {
  391. type: 'text',
  392. maxlength: 100,
  393. null: true,
  394. },
  395. editable: false,
  396. active: true,
  397. screens: {
  398. signup: {},
  399. invite_agent: {},
  400. invite_customer: {},
  401. edit: {
  402. '-all-' => {
  403. null: true,
  404. },
  405. },
  406. view: {
  407. '-all-' => {
  408. shown: true,
  409. },
  410. },
  411. },
  412. to_create: false,
  413. to_migrate: false,
  414. to_delete: false,
  415. position: 1100,
  416. )
  417. ObjectManager::Attribute.add(
  418. force: true,
  419. object: 'User',
  420. name: 'zip',
  421. display: 'Zip',
  422. data_type: 'input',
  423. data_option: {
  424. type: 'text',
  425. maxlength: 100,
  426. null: true,
  427. item_class: 'formGroup--halfSize',
  428. },
  429. editable: false,
  430. active: true,
  431. screens: {
  432. signup: {},
  433. invite_agent: {},
  434. invite_customer: {},
  435. edit: {
  436. '-all-' => {
  437. null: true,
  438. },
  439. },
  440. view: {
  441. '-all-' => {
  442. shown: true,
  443. },
  444. },
  445. },
  446. to_create: false,
  447. to_migrate: false,
  448. to_delete: false,
  449. position: 1200,
  450. )
  451. ObjectManager::Attribute.add(
  452. force: true,
  453. object: 'User',
  454. name: 'city',
  455. display: 'City',
  456. data_type: 'input',
  457. data_option: {
  458. type: 'text',
  459. maxlength: 100,
  460. null: true,
  461. item_class: 'formGroup--halfSize',
  462. },
  463. editable: false,
  464. active: true,
  465. screens: {
  466. signup: {},
  467. invite_agent: {},
  468. invite_customer: {},
  469. edit: {
  470. '-all-' => {
  471. null: true,
  472. },
  473. },
  474. view: {
  475. '-all-' => {
  476. shown: true,
  477. },
  478. },
  479. },
  480. to_create: false,
  481. to_migrate: false,
  482. to_delete: false,
  483. position: 1300,
  484. )
  485. ObjectManager::Attribute.add(
  486. force: true,
  487. object: 'User',
  488. name: 'address',
  489. display: 'Address',
  490. data_type: 'textarea',
  491. data_option: {
  492. type: 'text',
  493. maxlength: 500,
  494. null: true,
  495. item_class: 'formGroup--halfSize',
  496. },
  497. editable: false,
  498. active: true,
  499. screens: {
  500. signup: {},
  501. invite_agent: {},
  502. invite_customer: {},
  503. edit: {
  504. '-all-' => {
  505. null: true,
  506. },
  507. },
  508. view: {
  509. '-all-' => {
  510. shown: true,
  511. },
  512. },
  513. },
  514. to_create: false,
  515. to_migrate: false,
  516. to_delete: false,
  517. position: 1350,
  518. )
  519. ObjectManager::Attribute.add(
  520. force: true,
  521. object: 'User',
  522. name: 'password',
  523. display: 'Password',
  524. data_type: 'input',
  525. data_option: {
  526. type: 'password',
  527. maxlength: 100,
  528. null: true,
  529. autocomplete: 'off',
  530. item_class: 'formGroup--halfSize',
  531. },
  532. editable: false,
  533. active: true,
  534. screens: {
  535. signup: {
  536. '-all-' => {
  537. null: false,
  538. },
  539. },
  540. invite_agent: {},
  541. invite_customer: {},
  542. edit: {
  543. Admin: {
  544. null: true,
  545. },
  546. },
  547. view: {}
  548. },
  549. to_create: false,
  550. to_migrate: false,
  551. to_delete: false,
  552. position: 1400,
  553. )
  554. # rubocop:disable Lint/BooleanSymbol
  555. ObjectManager::Attribute.add(
  556. force: true,
  557. object: 'User',
  558. name: 'vip',
  559. display: 'VIP',
  560. data_type: 'boolean',
  561. data_option: {
  562. null: true,
  563. default: false,
  564. item_class: 'formGroup--halfSize',
  565. options: {
  566. false: 'no',
  567. true: 'yes',
  568. },
  569. translate: true,
  570. },
  571. editable: false,
  572. active: true,
  573. screens: {
  574. edit: {
  575. Admin: {
  576. null: true,
  577. },
  578. Agent: {
  579. null: true,
  580. },
  581. },
  582. view: {
  583. '-all-' => {
  584. shown: false,
  585. },
  586. },
  587. },
  588. to_create: false,
  589. to_migrate: false,
  590. to_delete: false,
  591. position: 1490,
  592. )
  593. # rubocop:enable Lint/BooleanSymbol
  594. ObjectManager::Attribute.add(
  595. force: true,
  596. object: 'User',
  597. name: 'note',
  598. display: 'Note',
  599. data_type: 'richtext',
  600. data_option: {
  601. type: 'text',
  602. maxlength: 250,
  603. null: true,
  604. note: 'Notes are visible to agents only, never to customers.',
  605. },
  606. editable: false,
  607. active: true,
  608. screens: {
  609. signup: {},
  610. invite_agent: {},
  611. invite_customer: {
  612. '-all-' => {
  613. null: true,
  614. },
  615. },
  616. edit: {
  617. '-all-' => {
  618. null: true,
  619. },
  620. },
  621. view: {
  622. '-all-' => {
  623. shown: true,
  624. },
  625. },
  626. },
  627. to_create: false,
  628. to_migrate: false,
  629. to_delete: false,
  630. position: 1500,
  631. )
  632. ObjectManager::Attribute.add(
  633. force: true,
  634. object: 'User',
  635. name: 'role_ids',
  636. display: 'Roles',
  637. data_type: 'checkbox',
  638. data_option: {
  639. default: '',
  640. multiple: true,
  641. null: false,
  642. relation: 'Role',
  643. },
  644. editable: false,
  645. active: true,
  646. screens: {
  647. signup: {},
  648. invite_agent: {},
  649. invite_customer: {},
  650. edit: {
  651. Admin: {
  652. null: false,
  653. },
  654. },
  655. view: {
  656. '-all-' => {
  657. shown: false,
  658. },
  659. },
  660. },
  661. to_create: false,
  662. to_migrate: false,
  663. to_delete: false,
  664. position: 1600,
  665. )
  666. ObjectManager::Attribute.add(
  667. force: true,
  668. object: 'User',
  669. name: 'active',
  670. display: 'Active',
  671. data_type: 'active',
  672. data_option: {
  673. null: true,
  674. default: true,
  675. },
  676. editable: false,
  677. active: true,
  678. screens: {
  679. signup: {},
  680. invite_agent: {},
  681. invite_customer: {},
  682. edit: {
  683. Admin: {
  684. null: false,
  685. },
  686. },
  687. view: {
  688. '-all-' => {
  689. shown: false,
  690. },
  691. },
  692. },
  693. to_create: false,
  694. to_migrate: false,
  695. to_delete: false,
  696. position: 1800,
  697. )
  698. end
  699. end