Sha256: c4e164ed87ad75ff4583a6af7f69c145d85be6f4567f5dbb30200268955ec962

Contents?: true

Size: 1.18 KB

Versions: 25

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Decidim
  class OAuthApplication < ::Doorkeeper::Application
    include Decidim::Traceable
    include Decidim::Loggable
    include Decidim::HasUploadValidations

    belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization", inverse_of: :oauth_applications

    has_one_attached :organization_logo

    # validates_upload cannot be used here because the file is not necessarily
    # attached to any organization yet when creating a new OAuth application.
    # The organization becomes mapped after the OAuth application is created
    # but the logo needs to be uploaded in the front-end already before that.
    validates(
      :organization_logo,
      file_size: { less_than_or_equal_to: ->(record) { record.maximum_upload_size } },
      uploader_content_type: true,
      uploader_image_dimensions: true
    )
    attached_config[:organization_logo] = OpenStruct.new(uploader: OAuthApplicationLogoUploader)

    def owner
      organization
    end

    def type
      "Decidim::OAuthApplication"
    end

    def self.log_presenter_class_for(_log)
      Decidim::AdminLog::OAuthApplicationPresenter
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/models/decidim/oauth_application.rb
decidim-core-0.28.4 app/models/decidim/oauth_application.rb
decidim-core-0.27.9 app/models/decidim/oauth_application.rb
decidim-core-0.29.0 app/models/decidim/oauth_application.rb
decidim-core-0.28.3 app/models/decidim/oauth_application.rb
decidim-core-0.27.8 app/models/decidim/oauth_application.rb
decidim-core-0.29.0.rc4 app/models/decidim/oauth_application.rb
decidim-core-0.29.0.rc3 app/models/decidim/oauth_application.rb
decidim-core-0.29.0.rc2 app/models/decidim/oauth_application.rb
decidim-core-0.29.0.rc1 app/models/decidim/oauth_application.rb
decidim-core-0.28.2 app/models/decidim/oauth_application.rb
decidim-core-0.27.7 app/models/decidim/oauth_application.rb
decidim-core-0.28.1 app/models/decidim/oauth_application.rb
decidim-core-0.27.6 app/models/decidim/oauth_application.rb
decidim-core-0.28.0 app/models/decidim/oauth_application.rb
decidim-core-0.27.5 app/models/decidim/oauth_application.rb
decidim-core-0.28.0.rc5 app/models/decidim/oauth_application.rb
decidim-core-0.28.0.rc4 app/models/decidim/oauth_application.rb
decidim-core-0.27.4 app/models/decidim/oauth_application.rb
decidim-core-0.27.3 app/models/decidim/oauth_application.rb