Module: HasHelpers::OrganizationMethods
- Defined in:
- app/models/has_helpers/organization_methods.rb
Constant Summary collapse
- PHOTO_OPTIONS =
Including apps' organization models can use this to set common settings for organization photos.
{ as: :logo, bucket: "hqadmin-#{ ::HasUtils::Env.current_environment }", # TODO: upgrade paperclip to 6 and you can use -> { "#{::HasHelpers::Application::HQADMIN.name}-#{ ::HasUtils::Env.current_environment }" }, styles: { thumbnail: "34x34#", medium: "80x80#", large: "120x120#", white: "120x120#" }, convert_options: { white: "-fuzz 5% -transparent white -colorize 90% -negate" } }.freeze
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/models/has_helpers/organization_methods.rb', line 13 def self.included(base) base.class_eval do attr_accessor :extra_attributes belongs_to :time_zone has_many :users, dependent: :destroy has_many :organization_links, dependent: :destroy, class_name: "HasHelpers::OrganizationLink" has_many :organization_resources, dependent: :destroy, class_name: "::HasHelpers::OrganizationResource" accepts_nested_attributes_for :organization_resources accepts_nested_attributes_for :organization_links, allow_destroy: true, reject_if: proc { |a| a.slice("X", "id", "name").values.all?(&:blank?) } before_validation :normalize has_validated_attributes name: { format: :name }, domain: { format: :domain } validates :name, presence: true, uniqueness: true validates :domain, presence: true, uniqueness: true validates :time_zone_id, presence: true, inclusion: { in: proc { ::TimeZone.pluck(:id) } } def organization self end def organization_id id end def contact_details # Used for PDF footers # Override to provide details such as contact information. # Return details in grouped within a hash. Note that group names are currently not used other than as hash keys. # # Example: # { # Contact: { # website: websites.primary.url.to_service(name), # address: addresses.primary, # } # } {} end private def normalize self.domain = domain.downcase if domain end end end |