<commit_before>module WikiPagePermission
  # WikiPage
  #  def authorized?
  #    if @page
  #      if %w(show print).include? params[:action]
  #        @page.public? or current_user.may?(:view, @page)
  #      elsif %w(edit break_lock upload).include? params[:action]
  #        current_user.may?(:edit, @page)
  #      else
  #        current_user.may?(:admin, @page)
  #      end
  #    else
  #      true
  #    end
  #  end
  def may_show_wiki_page?(page = @page)
    page.nil? or
    page.public? or
    logged_in? && current_user.may?(:view, page)
  end

  alias_method :may_print_wiki_page?, :may_show_wiki_page?

  def may_edit_wiki_page?(page = @page)
    page.nil? or
    logged_in? && current_user.may?(:edit, page)
  end

  %w[break_lock upload].each{ |action|
    alias_method "may_#{action}_wiki_page?", :may_edit_wiki_page?
  }

end<commit_msg>wiki bug fix: allow preview and editor switch for people with :edit access<commit_after>module WikiPagePermission
  # WikiPage
  #  def authorized?
  #    if @page
  #      if %w(show print).include? params[:action]
  #        @page.public? or current_user.may?(:view, @page)
  #      elsif %w(edit break_lock upload).include? params[:action]
  #        current_user.may?(:edit, @page)
  #      else
  #        current_user.may?(:admin, @page)
  #      end
  #    else
  #      true
  #    end
  #  end
  def may_show_wiki_page?(page = @page)
    page.nil? or
    page.public? or
    logged_in? && current_user.may?(:view, page)
  end

  alias_method :may_print_wiki_page?, :may_show_wiki_page?

  def may_edit_wiki_page?(page = @page)
    page.nil? or
    logged_in? && current_user.may?(:edit, page)
  end

  %w[break_lock upload update_editors].each{ |action|
    alias_method "may_#{action}_wiki_page?", :may_edit_wiki_page?
  }

end
{'fraction_non_alphanumeric': 0.12903225806451613, 'fraction_numerical': 0.0, 'mean_word_length': 3.015625, 'pattern_counts': {'":': 0, '<': 3, '<?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': '10755', 'n_tokens_mistral': 663, 'n_tokens_neox': 660, 'n_words': 132}