article.rb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. class Ticket::Article < ApplicationModel
  3. load 'ticket/article/assets.rb'
  4. include Ticket::Article::Assets
  5. load 'ticket/article/history_log.rb'
  6. include Ticket::Article::HistoryLog
  7. load 'ticket/article/activity_stream_log.rb'
  8. include Ticket::Article::ActivityStreamLog
  9. belongs_to :ticket
  10. belongs_to :type, class_name: 'Ticket::Article::Type'
  11. belongs_to :sender, class_name: 'Ticket::Article::Sender'
  12. belongs_to :created_by, class_name: 'User'
  13. belongs_to :updated_by, class_name: 'User'
  14. store :preferences
  15. before_create :check_subject
  16. before_update :check_subject
  17. notify_clients_support
  18. activity_stream_support ignore_attributes: {
  19. type_id: true,
  20. sender_id: true,
  21. preferences: true,
  22. }
  23. history_support ignore_attributes: {
  24. type_id: true,
  25. sender_id: true,
  26. preferences: true,
  27. }
  28. private
  29. def check_subject
  30. return if !subject
  31. subject.gsub!(/\s|\t|\r/, ' ')
  32. end
  33. class Flag < ApplicationModel
  34. end
  35. class Sender < ApplicationModel
  36. validates :name, presence: true
  37. latest_change_support
  38. end
  39. class Type < ApplicationModel
  40. validates :name, presence: true
  41. latest_change_support
  42. end
  43. end