20161117000002_ticket_number_generator_issue_427.rb 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. class TicketNumberGeneratorIssue427 < ActiveRecord::Migration
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.find_by(name: 'system_init_done')
  5. setting = Setting.find_by(name: 'ticket_number')
  6. setting.preferences = {
  7. settings_included: %w(ticket_number_increment ticket_number_date),
  8. controller: 'SettingsAreaTicketNumber',
  9. permission: ['admin.ticket'],
  10. }
  11. setting.save!
  12. setting = Setting.find_by(name: 'ticket_number_increment')
  13. setting.preferences = {
  14. permission: ['admin.ticket'],
  15. hidden: true,
  16. }
  17. setting.save!
  18. setting = Setting.find_by(name: 'ticket_number_date')
  19. setting.preferences = {
  20. permission: ['admin.ticket'],
  21. hidden: true,
  22. }
  23. # just to make sure that value is saved correctly - https://github.com/zammad/zammad/issues/413
  24. if setting.state_current['value'] == true || setting.state_current['value'] == false
  25. setting.state_current['value'] = { 'checksum' => setting.state_current['value'] }
  26. end
  27. setting.save!
  28. setting = Setting.find_by(name: 'ticket_hook_position')
  29. setting.preferences = {
  30. controller: 'SettingsAreaTicketHookPosition',
  31. permission: ['admin.ticket'],
  32. }
  33. setting.options = {
  34. form: [
  35. {
  36. display: '',
  37. null: true,
  38. name: 'ticket_hook_position',
  39. tag: 'select',
  40. translate: true,
  41. options: {
  42. 'left' => 'left',
  43. 'right' => 'right',
  44. 'none' => 'none',
  45. },
  46. },
  47. ],
  48. }
  49. setting.save!
  50. end
  51. end