organization.rb 793 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class Organization < ApplicationModel
  3. include HasActivityStreamLog
  4. include ChecksClientNotification
  5. include ChecksLatestChangeObserved
  6. include HasHistory
  7. include HasSearchIndexBackend
  8. include CanCsvImport
  9. include Organization::ChecksAccess
  10. include Organization::Assets
  11. include Organization::Search
  12. include Organization::SearchIndex
  13. has_many :members, class_name: 'User'
  14. before_create :domain_cleanup
  15. before_update :domain_cleanup
  16. validates :name, presence: true
  17. activity_stream_permission 'admin.role'
  18. private
  19. def domain_cleanup
  20. return true if domain.blank?
  21. domain.gsub!(/@/, '')
  22. domain.gsub!(/\s*/, '')
  23. domain.strip!
  24. domain.downcase!
  25. true
  26. end
  27. end