trabajo-afectivo/app/models/organization.rb

43 lines
994 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
load 'organization/permission.rb'
include Organization::Permission
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
has_and_belongs_to_many :users
has_many :members, class_name: 'User'
validates :name, presence: true
before_create :domain_cleanup
before_update :domain_cleanup
activity_stream_support permission: 'admin.role'
2013-09-29 16:40:42 +00:00
history_support
search_index_support
notify_clients_support
latest_change_support
private
def domain_cleanup
2016-12-02 11:24:00 +00:00
return if domain.blank?
domain.gsub!(/@/, '')
domain.gsub!(/\s*/, '')
domain.strip!
domain.downcase!
end
def cache_delete
super
# delete asset caches
key = "Organization::member_ids::#{id}"
Cache.delete(key)
end
end