trabajo-afectivo/app/models/organization.rb

41 lines
932 B
Ruby
Raw Normal View History

2016-10-19 03:11:36 +00:00
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
class Organization < ApplicationModel
include HasActivityStreamLog
include ChecksClientNotification
include ChecksLatestChangeObserved
include HasHistory
include HasSearchIndexBackend
include CanCsvImport
include Organization::ChecksAccess
load 'organization/assets.rb'
include Organization::Assets
extend Organization::Search
2016-07-06 06:13:44 +00:00
load 'organization/search_index.rb'
include Organization::SearchIndex
2018-04-12 14:57:37 +00:00
# rubocop:disable Rails/InverseOf
has_many :members, class_name: 'User'
# rubocop:enable Rails/InverseOf
before_create :domain_cleanup
before_update :domain_cleanup
2018-04-12 14:57:37 +00:00
validates :name, presence: true
activity_stream_permission 'admin.role'
private
def domain_cleanup
return true if domain.blank?
domain.gsub!(/@/, '')
domain.gsub!(/\s*/, '')
domain.strip!
domain.downcase!
true
end
end