permissions.rb 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. Permission.create_if_not_exists(
  2. name: 'admin',
  3. note: 'Admin Interface',
  4. preferences: {},
  5. )
  6. Permission.create_if_not_exists(
  7. name: 'admin.user',
  8. note: 'Manage %s',
  9. preferences: {
  10. translations: ['Users']
  11. },
  12. )
  13. Permission.create_if_not_exists(
  14. name: 'admin.group',
  15. note: 'Manage %s',
  16. preferences: {
  17. translations: ['Groups']
  18. },
  19. )
  20. Permission.create_if_not_exists(
  21. name: 'admin.role',
  22. note: 'Manage %s',
  23. preferences: {
  24. translations: ['Roles']
  25. },
  26. )
  27. Permission.create_if_not_exists(
  28. name: 'admin.organization',
  29. note: 'Manage %s',
  30. preferences: {
  31. translations: ['Organizations']
  32. },
  33. )
  34. Permission.create_if_not_exists(
  35. name: 'admin.overview',
  36. note: 'Manage %s',
  37. preferences: {
  38. translations: ['Overviews']
  39. },
  40. )
  41. Permission.create_if_not_exists(
  42. name: 'admin.text_module',
  43. note: 'Manage %s',
  44. preferences: {
  45. translations: ['Text Modules']
  46. },
  47. )
  48. Permission.create_if_not_exists(
  49. name: 'admin.time_accounting',
  50. note: 'Manage %s',
  51. preferences: {
  52. translations: ['Time Accounting']
  53. },
  54. )
  55. Permission.create_if_not_exists(
  56. name: 'admin.macro',
  57. note: 'Manage %s',
  58. preferences: {
  59. translations: ['Macros']
  60. },
  61. )
  62. Permission.create_if_not_exists(
  63. name: 'admin.tag',
  64. note: 'Manage %s',
  65. preferences: {
  66. translations: ['Tags']
  67. },
  68. )
  69. Permission.create_if_not_exists(
  70. name: 'admin.calendar',
  71. note: 'Manage %s',
  72. preferences: {
  73. translations: ['Calendar']
  74. },
  75. )
  76. Permission.create_if_not_exists(
  77. name: 'admin.sla',
  78. note: 'Manage %s',
  79. preferences: {
  80. translations: ['SLA']
  81. },
  82. )
  83. Permission.create_if_not_exists(
  84. name: 'admin.trigger',
  85. note: 'Manage %s',
  86. preferences: {
  87. translations: ['Triggers']
  88. },
  89. )
  90. Permission.create_if_not_exists(
  91. name: 'admin.scheduler',
  92. note: 'Manage %s',
  93. preferences: {
  94. translations: ['Scheduler']
  95. },
  96. )
  97. Permission.create_if_not_exists(
  98. name: 'admin.report_profile',
  99. note: 'Manage %s',
  100. preferences: {
  101. translations: ['Report Profiles']
  102. },
  103. )
  104. Permission.create_if_not_exists(
  105. name: 'admin.channel_web',
  106. note: 'Manage %s',
  107. preferences: {
  108. translations: ['Channel - Web']
  109. },
  110. )
  111. Permission.create_if_not_exists(
  112. name: 'admin.channel_formular',
  113. note: 'Manage %s',
  114. preferences: {
  115. translations: ['Channel - Formular']
  116. },
  117. )
  118. Permission.create_if_not_exists(
  119. name: 'admin.channel_email',
  120. note: 'Manage %s',
  121. preferences: {
  122. translations: ['Channel - Email']
  123. },
  124. )
  125. Permission.create_if_not_exists(
  126. name: 'admin.channel_twitter',
  127. note: 'Manage %s',
  128. preferences: {
  129. translations: ['Channel - Twitter']
  130. },
  131. )
  132. Permission.create_if_not_exists(
  133. name: 'admin.channel_facebook',
  134. note: 'Manage %s',
  135. preferences: {
  136. translations: ['Channel - Facebook']
  137. },
  138. )
  139. Permission.create_if_not_exists(
  140. name: 'admin.channel_telegram',
  141. note: 'Manage %s',
  142. preferences: {
  143. translations: ['Channel - Telegram']
  144. },
  145. )
  146. Permission.create_if_not_exists(
  147. name: 'admin.channel_google',
  148. note: 'Manage %s',
  149. preferences: {
  150. translations: ['Channel - Google']
  151. },
  152. )
  153. Permission.create_if_not_exists(
  154. name: 'admin.channel_microsoft365',
  155. note: 'Manage %s',
  156. preferences: {
  157. translations: ['Channel - Microsoft 365']
  158. },
  159. )
  160. Permission.create_if_not_exists(
  161. name: 'admin.channel_sms',
  162. note: 'Manage %s',
  163. preferences: {
  164. translations: ['Channel - SMS']
  165. },
  166. )
  167. Permission.create_if_not_exists(
  168. name: 'admin.channel_chat',
  169. note: 'Manage %s',
  170. preferences: {
  171. translations: ['Channel - Chat']
  172. },
  173. )
  174. Permission.create_if_not_exists(
  175. name: 'admin.branding',
  176. note: 'Manage %s',
  177. preferences: {
  178. translations: ['Branding']
  179. },
  180. )
  181. Permission.create_if_not_exists(
  182. name: 'admin.setting_system',
  183. note: 'Manage %s Settings',
  184. preferences: {
  185. translations: ['System']
  186. },
  187. )
  188. Permission.create_if_not_exists(
  189. name: 'admin.security',
  190. note: 'Manage %s Settings',
  191. preferences: {
  192. translations: ['Security']
  193. },
  194. )
  195. Permission.create_if_not_exists(
  196. name: 'admin.ticket',
  197. note: 'Manage %s Settings',
  198. preferences: {
  199. translations: ['Ticket']
  200. },
  201. )
  202. Permission.create_if_not_exists(
  203. name: 'admin.package',
  204. note: 'Manage %s',
  205. preferences: {
  206. translations: ['Packages']
  207. },
  208. )
  209. Permission.create_if_not_exists(
  210. name: 'admin.integration',
  211. note: 'Manage %s',
  212. preferences: {
  213. translations: ['Integrations']
  214. },
  215. )
  216. Permission.create_if_not_exists(
  217. name: 'admin.api',
  218. note: 'Manage %s',
  219. preferences: {
  220. translations: ['API']
  221. },
  222. )
  223. Permission.create_if_not_exists(
  224. name: 'admin.object',
  225. note: 'Manage %s',
  226. preferences: {
  227. translations: ['Objects']
  228. },
  229. )
  230. Permission.create_if_not_exists(
  231. name: 'admin.translation',
  232. note: 'Manage %s',
  233. preferences: {
  234. translations: ['Translations']
  235. },
  236. )
  237. Permission.create_if_not_exists(
  238. name: 'admin.monitoring',
  239. note: 'Manage %s',
  240. preferences: {
  241. translations: ['Monitoring']
  242. },
  243. )
  244. Permission.create_if_not_exists(
  245. name: 'admin.data_privacy',
  246. note: 'Manage %s',
  247. preferences: {
  248. translations: ['Data Privacy']
  249. },
  250. )
  251. Permission.create_if_not_exists(
  252. name: 'admin.maintenance',
  253. note: 'Manage %s',
  254. preferences: {
  255. translations: ['Maintenance']
  256. },
  257. )
  258. Permission.create_if_not_exists(
  259. name: 'admin.session',
  260. note: 'Manage %s',
  261. preferences: {
  262. translations: ['Sessions']
  263. },
  264. )
  265. Permission.create_if_not_exists(
  266. name: 'admin.webhook',
  267. note: 'Manage %s',
  268. preferences: {
  269. translations: ['Webhooks']
  270. },
  271. )
  272. Permission.create_if_not_exists(
  273. name: 'user_preferences',
  274. note: 'User Preferences',
  275. preferences: {},
  276. allow_signup: true,
  277. )
  278. Permission.create_if_not_exists(
  279. name: 'user_preferences.password',
  280. note: 'Change %s',
  281. preferences: {
  282. translations: ['Password']
  283. },
  284. allow_signup: true,
  285. )
  286. Permission.create_if_not_exists(
  287. name: 'user_preferences.notifications',
  288. note: 'Manage %s',
  289. preferences: {
  290. translations: ['Notifications'],
  291. required: ['ticket.agent'],
  292. },
  293. allow_signup: true,
  294. )
  295. Permission.create_if_not_exists(
  296. name: 'user_preferences.access_token',
  297. note: 'Manage %s',
  298. preferences: {
  299. translations: ['Token Access']
  300. },
  301. allow_signup: true,
  302. )
  303. Permission.create_if_not_exists(
  304. name: 'user_preferences.language',
  305. note: 'Change %s',
  306. preferences: {
  307. translations: ['Language']
  308. },
  309. allow_signup: true,
  310. )
  311. Permission.create_if_not_exists(
  312. name: 'user_preferences.linked_accounts',
  313. note: 'Manage %s',
  314. preferences: {
  315. translations: ['Linked Accounts']
  316. },
  317. allow_signup: true,
  318. )
  319. Permission.create_if_not_exists(
  320. name: 'user_preferences.device',
  321. note: 'Manage %s',
  322. preferences: {
  323. translations: ['Devices']
  324. },
  325. allow_signup: true,
  326. )
  327. Permission.create_if_not_exists(
  328. name: 'user_preferences.avatar',
  329. note: 'Manage %s',
  330. preferences: {
  331. translations: ['Avatar']
  332. },
  333. allow_signup: true,
  334. )
  335. Permission.create_if_not_exists(
  336. name: 'user_preferences.calendar',
  337. note: 'Access to %s',
  338. preferences: {
  339. translations: ['Calendars'],
  340. required: ['ticket.agent'],
  341. },
  342. allow_signup: true,
  343. )
  344. Permission.create_if_not_exists(
  345. name: 'user_preferences.out_of_office',
  346. note: 'Change %s',
  347. preferences: {
  348. translations: ['Out of Office'],
  349. required: ['ticket.agent'],
  350. },
  351. allow_signup: true,
  352. )
  353. Permission.create_if_not_exists(
  354. name: 'report',
  355. note: 'Report Interface',
  356. preferences: {},
  357. )
  358. Permission.create_if_not_exists(
  359. name: 'ticket',
  360. note: 'Ticket Interface',
  361. preferences: {
  362. disabled: true
  363. },
  364. )
  365. Permission.create_if_not_exists(
  366. name: 'ticket.agent',
  367. note: 'Access to Agent Tickets based on Group Access',
  368. preferences: {
  369. plugin: ['groups']
  370. },
  371. )
  372. Permission.create_if_not_exists(
  373. name: 'ticket.customer',
  374. note: 'Access to Customer Tickets based on current_user and organization',
  375. preferences: {},
  376. allow_signup: true,
  377. )
  378. Permission.create_if_not_exists(
  379. name: 'chat',
  380. note: 'Access to %s',
  381. preferences: {
  382. translations: ['Chat'],
  383. disabled: true,
  384. },
  385. )
  386. Permission.create_if_not_exists(
  387. name: 'chat.agent',
  388. note: 'Access to %s',
  389. preferences: {
  390. translations: ['Chat'],
  391. },
  392. )
  393. Permission.create_if_not_exists(
  394. name: 'cti',
  395. note: 'CTI',
  396. preferences: {
  397. disabled: true
  398. },
  399. )
  400. Permission.create_if_not_exists(
  401. name: 'cti.agent',
  402. note: 'Access to %s',
  403. preferences: {
  404. translations: ['CTI'],
  405. },
  406. )
  407. Permission.create_if_not_exists(
  408. name: 'admin.knowledge_base',
  409. note: 'Create and setup %s',
  410. preferences: {
  411. translations: ['Knowledge Base']
  412. }
  413. )
  414. Permission.create_if_not_exists(
  415. name: 'knowledge_base',
  416. note: 'Manage %s',
  417. preferences: {
  418. translations: ['Knowledge Base'],
  419. disabled: true,
  420. }
  421. )
  422. Permission.create_if_not_exists(
  423. name: 'knowledge_base.editor',
  424. note: 'Manage %s',
  425. preferences: {
  426. translations: ['Knowledge Base Editor']
  427. }
  428. )
  429. Permission.create_if_not_exists(
  430. name: 'knowledge_base.reader',
  431. note: 'Manage %s',
  432. preferences: {
  433. translations: ['Knowledge Base Reader']
  434. }
  435. )
  436. admin = Role.find_by(name: 'Admin')
  437. admin.permission_grant('user_preferences')
  438. admin.permission_grant('admin')
  439. admin.permission_grant('report')
  440. admin.permission_grant('knowledge_base.editor')
  441. agent = Role.find_by(name: 'Agent')
  442. agent.permission_grant('user_preferences')
  443. agent.permission_grant('ticket.agent')
  444. agent.permission_grant('chat.agent')
  445. agent.permission_grant('cti.agent')
  446. agent.permission_grant('knowledge_base.reader')
  447. customer = Role.find_by(name: 'Customer')
  448. customer.permission_grant('user_preferences.password')
  449. customer.permission_grant('user_preferences.language')
  450. customer.permission_grant('user_preferences.linked_accounts')
  451. customer.permission_grant('user_preferences.avatar')
  452. customer.permission_grant('ticket.customer')