permissions.rb 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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.scheduler',
  85. note: 'Manage %s',
  86. preferences: {
  87. translations: ['Scheduler']
  88. },
  89. )
  90. Permission.create_if_not_exists(
  91. name: 'admin.report_profile',
  92. note: 'Manage %s',
  93. preferences: {
  94. translations: ['Report Profiles']
  95. },
  96. )
  97. Permission.create_if_not_exists(
  98. name: 'admin.channel_web',
  99. note: 'Manage %s',
  100. preferences: {
  101. translations: ['Channel - Web']
  102. },
  103. )
  104. Permission.create_if_not_exists(
  105. name: 'admin.channel_formular',
  106. note: 'Manage %s',
  107. preferences: {
  108. translations: ['Channel - Formular']
  109. },
  110. )
  111. Permission.create_if_not_exists(
  112. name: 'admin.channel_email',
  113. note: 'Manage %s',
  114. preferences: {
  115. translations: ['Channel - Email']
  116. },
  117. )
  118. Permission.create_if_not_exists(
  119. name: 'admin.channel_twitter',
  120. note: 'Manage %s',
  121. preferences: {
  122. translations: ['Channel - Twitter']
  123. },
  124. )
  125. Permission.create_if_not_exists(
  126. name: 'admin.channel_facebook',
  127. note: 'Manage %s',
  128. preferences: {
  129. translations: ['Channel - Facebook']
  130. },
  131. )
  132. Permission.create_if_not_exists(
  133. name: 'admin.channel_telegram',
  134. note: 'Manage %s',
  135. preferences: {
  136. translations: ['Channel - Telegram']
  137. },
  138. )
  139. Permission.create_if_not_exists(
  140. name: 'admin.channel_sms',
  141. note: 'Manage %s',
  142. preferences: {
  143. translations: ['Channel - SMS']
  144. },
  145. )
  146. Permission.create_if_not_exists(
  147. name: 'admin.channel_chat',
  148. note: 'Manage %s',
  149. preferences: {
  150. translations: ['Channel - Chat']
  151. },
  152. )
  153. Permission.create_if_not_exists(
  154. name: 'admin.branding',
  155. note: 'Manage %s',
  156. preferences: {
  157. translations: ['Branding']
  158. },
  159. )
  160. Permission.create_if_not_exists(
  161. name: 'admin.setting_system',
  162. note: 'Manage %s Settings',
  163. preferences: {
  164. translations: ['System']
  165. },
  166. )
  167. Permission.create_if_not_exists(
  168. name: 'admin.security',
  169. note: 'Manage %s Settings',
  170. preferences: {
  171. translations: ['Security']
  172. },
  173. )
  174. Permission.create_if_not_exists(
  175. name: 'admin.ticket',
  176. note: 'Manage %s Settings',
  177. preferences: {
  178. translations: ['Ticket']
  179. },
  180. )
  181. Permission.create_if_not_exists(
  182. name: 'admin.package',
  183. note: 'Manage %s',
  184. preferences: {
  185. translations: ['Packages']
  186. },
  187. )
  188. Permission.create_if_not_exists(
  189. name: 'admin.integration',
  190. note: 'Manage %s',
  191. preferences: {
  192. translations: ['Integrations']
  193. },
  194. )
  195. Permission.create_if_not_exists(
  196. name: 'admin.api',
  197. note: 'Manage %s',
  198. preferences: {
  199. translations: ['API']
  200. },
  201. )
  202. Permission.create_if_not_exists(
  203. name: 'admin.object',
  204. note: 'Manage %s',
  205. preferences: {
  206. translations: ['Objects']
  207. },
  208. )
  209. Permission.create_if_not_exists(
  210. name: 'admin.translation',
  211. note: 'Manage %s',
  212. preferences: {
  213. translations: ['Translations']
  214. },
  215. )
  216. Permission.create_if_not_exists(
  217. name: 'admin.monitoring',
  218. note: 'Manage %s',
  219. preferences: {
  220. translations: ['Monitoring']
  221. },
  222. )
  223. Permission.create_if_not_exists(
  224. name: 'admin.maintenance',
  225. note: 'Manage %s',
  226. preferences: {
  227. translations: ['Maintenance']
  228. },
  229. )
  230. Permission.create_if_not_exists(
  231. name: 'admin.session',
  232. note: 'Manage %s',
  233. preferences: {
  234. translations: ['Sessions']
  235. },
  236. )
  237. Permission.create_if_not_exists(
  238. name: 'user_preferences',
  239. note: 'User Preferences',
  240. preferences: {},
  241. )
  242. Permission.create_if_not_exists(
  243. name: 'user_preferences.password',
  244. note: 'Change %s',
  245. preferences: {
  246. translations: ['Password']
  247. },
  248. )
  249. Permission.create_if_not_exists(
  250. name: 'user_preferences.notifications',
  251. note: 'Manage %s',
  252. preferences: {
  253. translations: ['Notifications'],
  254. required: ['ticket.agent'],
  255. },
  256. )
  257. Permission.create_if_not_exists(
  258. name: 'user_preferences.access_token',
  259. note: 'Manage %s',
  260. preferences: {
  261. translations: ['Token Access']
  262. },
  263. )
  264. Permission.create_if_not_exists(
  265. name: 'user_preferences.language',
  266. note: 'Change %s',
  267. preferences: {
  268. translations: ['Language']
  269. },
  270. )
  271. Permission.create_if_not_exists(
  272. name: 'user_preferences.linked_accounts',
  273. note: 'Manage %s',
  274. preferences: {
  275. translations: ['Linked Accounts']
  276. },
  277. )
  278. Permission.create_if_not_exists(
  279. name: 'user_preferences.device',
  280. note: 'Manage %s',
  281. preferences: {
  282. translations: ['Devices']
  283. },
  284. )
  285. Permission.create_if_not_exists(
  286. name: 'user_preferences.avatar',
  287. note: 'Manage %s',
  288. preferences: {
  289. translations: ['Avatar']
  290. },
  291. )
  292. Permission.create_if_not_exists(
  293. name: 'user_preferences.calendar',
  294. note: 'Access to %s',
  295. preferences: {
  296. translations: ['Calendars'],
  297. required: ['ticket.agent'],
  298. },
  299. )
  300. Permission.create_if_not_exists(
  301. name: 'user_preferences.out_of_office',
  302. note: 'Change %s',
  303. preferences: {
  304. translations: ['Out of Office'],
  305. required: ['ticket.agent'],
  306. },
  307. )
  308. Permission.create_if_not_exists(
  309. name: 'report',
  310. note: 'Report Interface',
  311. preferences: {},
  312. )
  313. Permission.create_if_not_exists(
  314. name: 'ticket',
  315. note: 'Ticket Interface',
  316. preferences: {
  317. disabled: true
  318. },
  319. )
  320. Permission.create_if_not_exists(
  321. name: 'ticket.agent',
  322. note: 'Access to Agent Tickets based on Group Access',
  323. preferences: {
  324. not: ['ticket.customer'],
  325. plugin: ['groups']
  326. },
  327. )
  328. Permission.create_if_not_exists(
  329. name: 'ticket.customer',
  330. note: 'Access to Customer Tickets based on current_user and organization',
  331. preferences: {
  332. not: ['ticket.agent'],
  333. },
  334. )
  335. Permission.create_if_not_exists(
  336. name: 'chat',
  337. note: 'Access to %s',
  338. preferences: {
  339. translations: ['Chat']
  340. },
  341. )
  342. Permission.create_if_not_exists(
  343. name: 'chat.agent',
  344. note: 'Access to %s',
  345. preferences: {
  346. translations: ['Chat'],
  347. not: ['chat.customer'],
  348. },
  349. )
  350. Permission.create_if_not_exists(
  351. name: 'cti',
  352. note: 'CTI',
  353. preferences: {
  354. disabled: true
  355. },
  356. )
  357. Permission.create_if_not_exists(
  358. name: 'cti.agent',
  359. note: 'Access to %s',
  360. preferences: {
  361. translations: ['CTI'],
  362. not: ['cti.customer'],
  363. },
  364. )
  365. admin = Role.find_by(name: 'Admin')
  366. admin.permission_grant('user_preferences')
  367. admin.permission_grant('admin')
  368. admin.permission_grant('report')
  369. agent = Role.find_by(name: 'Agent')
  370. agent.permission_grant('user_preferences')
  371. agent.permission_grant('ticket.agent')
  372. agent.permission_grant('chat.agent')
  373. agent.permission_grant('cti.agent')
  374. customer = Role.find_by(name: 'Customer')
  375. customer.permission_grant('user_preferences.password')
  376. customer.permission_grant('user_preferences.language')
  377. customer.permission_grant('user_preferences.linked_accounts')
  378. customer.permission_grant('user_preferences.avatar')
  379. customer.permission_grant('ticket.customer')