2016-10-19 03:11:36 +00:00
|
|
|
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
class Organization < ApplicationModel
|
2017-05-02 15:21:13 +00:00
|
|
|
include HasActivityStreamLog
|
|
|
|
include ChecksClientNotification
|
|
|
|
include ChecksLatestChangeObserved
|
|
|
|
include HasHistory
|
|
|
|
include HasSearchIndexBackend
|
2018-02-20 04:29:30 +00:00
|
|
|
include CanCsvImport
|
2019-02-12 07:38:59 +00:00
|
|
|
include ChecksHtmlSanitized
|
2017-01-31 17:13:45 +00:00
|
|
|
|
2018-04-26 08:55:53 +00:00
|
|
|
include Organization::ChecksAccess
|
2013-08-19 06:29:49 +00:00
|
|
|
include Organization::Assets
|
2018-04-26 08:55:53 +00:00
|
|
|
include Organization::Search
|
2014-01-29 23:54:34 +00:00
|
|
|
include Organization::SearchIndex
|
2018-05-05 17:03:14 +00:00
|
|
|
|
2018-04-12 14:57:37 +00:00
|
|
|
has_many :members, class_name: 'User'
|
2014-08-12 19:40:56 +00:00
|
|
|
|
2016-11-13 22:59:39 +00:00
|
|
|
before_create :domain_cleanup
|
|
|
|
before_update :domain_cleanup
|
|
|
|
|
2018-04-12 14:57:37 +00:00
|
|
|
validates :name, presence: true
|
|
|
|
|
2017-01-31 17:13:45 +00:00
|
|
|
activity_stream_permission 'admin.role'
|
2015-06-18 22:39:34 +00:00
|
|
|
|
2019-02-12 07:38:59 +00:00
|
|
|
sanitized_html :note
|
|
|
|
|
2015-06-18 22:39:34 +00:00
|
|
|
private
|
|
|
|
|
2016-11-13 22:59:39 +00:00
|
|
|
def domain_cleanup
|
2017-06-16 22:53:20 +00:00
|
|
|
return true if domain.blank?
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2016-11-13 22:59:39 +00:00
|
|
|
domain.gsub!(/@/, '')
|
|
|
|
domain.gsub!(/\s*/, '')
|
|
|
|
domain.strip!
|
|
|
|
domain.downcase!
|
2017-06-16 22:53:20 +00:00
|
|
|
true
|
2016-11-13 22:59:39 +00:00
|
|
|
end
|
|
|
|
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|