Sha256: 3f642bda5a33f41fa3c4f967a64b22c279704a091cb0413be967d04bfb54bc25

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

module Decidim
  # Organizations are one of the main models of Decidim. In a single Decidim
  # installation we can find many organizations and each of them can start
  # their own participatory processes.
  class Organization < ApplicationRecord
    SOCIAL_HANDLERS = [:twitter, :facebook, :instagram, :youtube, :github].freeze

    has_many :participatory_process_groups, foreign_key: "decidim_organization_id", class_name: "Decidim::ParticipatoryProcessGroup", inverse_of: :organization
    has_many :participatory_processes, foreign_key: "decidim_organization_id", class_name: "Decidim::ParticipatoryProcess", inverse_of: :organization
    has_many :static_pages, foreign_key: "decidim_organization_id", class_name: "Decidim::StaticPage", inverse_of: :organization
    has_many :scopes, -> { order(name: :asc) }, foreign_key: "decidim_organization_id", class_name: "Decidim::Scope", inverse_of: :organization
    has_many :admins, -> { where("roles @> ?", "{admin}") }, foreign_key: "decidim_organization_id", class_name: "Decidim::User"
    has_many :users, foreign_key: "decidim_organization_id", class_name: "Decidim::User"

    validates :name, :host, uniqueness: true
    validates :reference_prefix, presence: true

    mount_uploader :homepage_image, Decidim::HomepageImageUploader
    mount_uploader :official_img_header, Decidim::OfficialImageHeaderUploader
    mount_uploader :official_img_footer, Decidim::OfficialImageFooterUploader
    mount_uploader :logo, Decidim::OrganizationLogoUploader
    mount_uploader :favicon, Decidim::OrganizationFaviconUploader

    def homepage_big_url
      homepage_image.big.url
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.4.0 app/models/decidim/organization.rb
decidim-core-0.3.2 app/models/decidim/organization.rb
decidim-core-0.3.1 app/models/decidim/organization.rb
decidim-core-0.3.0 app/models/decidim/organization.rb
decidim-core-0.2.0 app/models/decidim/organization.rb