<commit_before># frozen_string_literal: true

module CodeOcean
  class FilePolicy < AdminOrAuthorPolicy
    def author?
      @user == @record.context.author
    end

    def show?
      return false if @record.native_file? && !@record.native_file_location_valid?

      if @record.context.is_a?(Exercise)
        admin? || author? || !@record.hidden
      else
        admin? || author?
      end
    end

    def show_protected_upload?
      return false if @record.native_file? && !@record.native_file_location_valid?

      if @record.context.is_a?(Exercise)<commit_msg>Handle deleted exercise in FilePolicy<commit_after># frozen_string_literal: true

module CodeOcean
  class FilePolicy < AdminOrAuthorPolicy
    def author?
      @user == @record.context&.author
    end

    def show?
      return false if @record.native_file? && !@record.native_file_location_valid?

      if @record.context.is_a?(Exercise)
        admin? || author? || !@record.hidden
      else
        admin? || author?
      end
    end

    def show_protected_upload?
      return false if @record.native_file? && !@record.native_file_location_valid?

      if @record.context.is_a?(Exercise)
{'fraction_non_alphanumeric': 0.09974424552429667, 'fraction_numerical': 0.0, 'mean_word_length': 3.0905923344947737, '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': '510111', 'n_tokens_mistral': 363, 'n_tokens_neox': 357, 'n_words': 81}