20170628000001_form_group_selection.rb 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. class FormGroupSelection < ActiveRecord::Migration[4.2]
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.exists?(name: 'system_init_done')
  5. group = Group.where(active: true).first
  6. if !group
  7. group = Group.first
  8. end
  9. group_id = 1
  10. if group
  11. group_id = group.id
  12. end
  13. Setting.create_if_not_exists(
  14. title: 'Group selection for Ticket creation',
  15. name: 'form_ticket_create_group_id',
  16. area: 'Form::Base',
  17. description: 'Defines if group of created tickets via web form.',
  18. options: {
  19. form: [
  20. {
  21. display: '',
  22. null: true,
  23. name: 'form_ticket_create_group_id',
  24. tag: 'select',
  25. relation: 'Group',
  26. },
  27. ],
  28. },
  29. state: group_id,
  30. preferences: {
  31. permission: ['admin.channel_formular'],
  32. },
  33. frontend: false,
  34. )
  35. Setting.create_if_not_exists(
  36. title: 'Limit tickets by ip per hour',
  37. name: 'form_ticket_create_by_ip_per_hour',
  38. area: 'Form::Base',
  39. description: 'Defines limit of tickets by ip per hour via web form.',
  40. options: {
  41. form: [
  42. {
  43. display: '',
  44. null: true,
  45. name: 'form_ticket_create_by_ip_per_hour',
  46. tag: 'input',
  47. },
  48. ],
  49. },
  50. state: 20,
  51. preferences: {
  52. permission: ['admin.channel_formular'],
  53. },
  54. frontend: false,
  55. )
  56. Setting.create_if_not_exists(
  57. title: 'Limit tickets by ip per day',
  58. name: 'form_ticket_create_by_ip_per_day',
  59. area: 'Form::Base',
  60. description: 'Defines limit of tickets by ip per day via web form.',
  61. options: {
  62. form: [
  63. {
  64. display: '',
  65. null: true,
  66. name: 'form_ticket_create_by_ip_per_day',
  67. tag: 'input',
  68. },
  69. ],
  70. },
  71. state: 240,
  72. preferences: {
  73. permission: ['admin.channel_formular'],
  74. },
  75. frontend: false,
  76. )
  77. Setting.create_if_not_exists(
  78. title: 'Limit tickets per day',
  79. name: 'form_ticket_create_per_day',
  80. area: 'Form::Base',
  81. description: 'Defines limit of tickets per day via web form.',
  82. options: {
  83. form: [
  84. {
  85. display: '',
  86. null: true,
  87. name: 'form_ticket_create_per_day',
  88. tag: 'input',
  89. },
  90. ],
  91. },
  92. state: 5000,
  93. preferences: {
  94. permission: ['admin.channel_formular'],
  95. },
  96. frontend: false,
  97. )
  98. end
  99. end