20180604000001_setting_add_ticket_auto_assignment2.rb 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. class SettingAddTicketAutoAssignment2 < ActiveRecord::Migration[5.1]
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.exists?(name: 'system_init_done')
  5. Setting.create_if_not_exists(
  6. title: 'Auto Assigment',
  7. name: 'ticket_auto_assignment',
  8. area: 'Web::Base',
  9. description: 'Enable ticket auto assignment.',
  10. options: {
  11. form: [
  12. {
  13. display: '',
  14. null: true,
  15. name: 'ticket_auto_assignment',
  16. tag: 'boolean',
  17. options: {
  18. true => 'yes',
  19. false => 'no',
  20. },
  21. },
  22. ],
  23. },
  24. preferences: {
  25. authentication: true,
  26. permission: ['admin.ticket_auto_assignment'],
  27. },
  28. state: false,
  29. frontend: true
  30. )
  31. Setting.create_if_not_exists(
  32. title: 'Time Accounting Selector',
  33. name: 'ticket_auto_assignment_selector',
  34. area: 'Web::Base',
  35. description: 'Enable auto assignment for following matching tickets.',
  36. options: {
  37. form: [
  38. {},
  39. ],
  40. },
  41. preferences: {
  42. authentication: true,
  43. permission: ['admin.ticket_auto_assignment'],
  44. },
  45. state: { condition: { 'ticket.state_id' => { operator: 'is', value: Ticket::State.by_category(:work_on).pluck(:id) } } },
  46. frontend: true
  47. )
  48. Setting.create_or_update(
  49. title: 'Time Accounting Selector',
  50. name: 'ticket_auto_assignment_user_ids_ignore',
  51. area: 'Web::Base',
  52. description: 'Define an exception of "automatic assignment" for certain users (e.g. executives).',
  53. options: {
  54. form: [
  55. {},
  56. ],
  57. },
  58. preferences: {
  59. authentication: true,
  60. permission: ['admin.ticket_auto_assignment'],
  61. },
  62. state: [],
  63. frontend: true
  64. )
  65. end
  66. end