20160217000001_object_manager_update_user.rb 16 KB

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