Sha256: 87b9e2360ba70e5e65a6d3422feeb599566cc88efed6925f32307ec2852f1375

Contents?: true

Size: 951 Bytes

Versions: 7

Compression:

Stored size: 951 Bytes

Contents

class OrganizationAccessMode::ReadOnly < OrganizationAccessMode::Base
  def initialize(user, organization, *global_scopes, **specific_scopes)
    super user, organization
    @scopes = global_scopes.map { |scope| [scope, :all] }.to_h.merge specific_scopes
  end

  def faqs_here?
    has_scope(:faqs) && super
  end

  def profile_here?
    has_scope(:profile)
  end

  def discuss_here?
    has_scope(:discussions) && super
  end

  def validate_discuss_here!(discussion)
    super(discussion) unless discussion&.initiator == user
  end

  def show_content?(content)
    has_scope(:exercises) ||
      (has_scope(:exercises, :submitted) && content.has_progress_for?(user, organization))
  end

  def restore_indicators?(book)
    !book.has_progress_for?(user, organization) && user.has_assignments_in_organization?(organization)
  end

  def read_only?
    true
  end

  private

  def has_scope(key, value = :all)
    @scopes[key] == value
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mumuki-domain-9.18.0 app/models/organization_access_mode/read_only.rb
mumuki-domain-9.17.0 app/models/organization_access_mode/read_only.rb
mumuki-domain-9.16.0 app/models/organization_access_mode/read_only.rb
mumuki-domain-9.15.0 app/models/organization_access_mode/read_only.rb
mumuki-domain-9.14.1 app/models/organization_access_mode/read_only.rb
mumuki-domain-9.14.0 app/models/organization_access_mode/read_only.rb
mumuki-domain-9.13.1 app/models/organization_access_mode/read_only.rb