permissions.rb 7.6 KB

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