<commit_before>class DocumentPolicy < ApplicationPolicy
  def index?
    gds_editor || departmental_editor || writer
  end

  alias_method :new?, :index?
  alias_method :create?, :index?
  alias_method :edit?, :index?
  alias_method :update?, :index?
  alias_method :show?, :index?

  def publish?
    gds_editor || departmental_editor
  end

  alias_method :unpublish?, :publish?

  def pre_production_formats
    PRE_PRODUCTION
  end

  def removed_pre_production?
    !pre_production_formats.include?(document_class.document_type)
  end

  def user_organisation_owns_document_type?
    document_class.organisations.include?(user.organisation_content_id) && removed_pre_production?
  end

  def departmental_editor
    user_organisation_owns_document_type? && user.permissions.include?('editor')
  end

  def writer
    user_organisation_owns_document_type?
  end

  def gds_editor
    removed_pre_production? && user.gds_editor?
  end<commit_msg>added a conditional so that pre-production formats are displayed when run on a dev environment. Test and production environments should be unaffected"<commit_after>class DocumentPolicy < ApplicationPolicy
  def index?
    gds_editor || departmental_editor || writer
  end

  alias_method :new?, :index?
  alias_method :create?, :index?
  alias_method :edit?, :index?
  alias_method :update?, :index?
  alias_method :show?, :index?

  def publish?
    gds_editor || departmental_editor
  end

  alias_method :unpublish?, :publish?

  def pre_production_formats
    Rails.env.development? ? [] : PRE_PRODUCTION
  end

  def removed_pre_production?
    !pre_production_formats.include?(document_class.document_type)
  end

  def user_organisation_owns_document_type?
    document_class.organisations.include?(user.organisation_content_id) && removed_pre_production?
  end

  def departmental_editor
    user_organisation_owns_document_type? && user.permissions.include?('editor')
  end

  def writer
    user_organisation_owns_document_type?
  end

  def gds_editor
    removed_pre_production? && user.gds_editor?
  end
{'fraction_non_alphanumeric': 0.0774818401937046, 'fraction_numerical': 0.0, 'mean_word_length': 4.971098265895954, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2245237', 'n_tokens_mistral': 660, 'n_tokens_neox': 637, 'n_words': 139}