<commit_before>class AnnotationsController < BaseController

  cache_sweeper :annotation_sweeper

  before_filter :require_user, :except => [:show, :embedded_pager]
  before_filter :load_annotation, :only => [:show, :edit, :update, :destroy, :metadata]

  access_control do
    allow all, :to => [:show, :metadata, :embedded_pager]
    allow :superadmin, :admin, :collages_admin

    allow logged_in, :to => [:destroy, :edit, :update, :create, :new, :autocomplete_layers], :if => :allow_edit?
    allow :owner, :of => :collage, :to => [:destroy, :edit, :update, :create, :new, :autocomplete_layers]
  end

  def allow_edit?
    load_annotation

    current_user.can_permission_collage("edit_annotations", @collage)
  end

  def embedded_pager
    super Annotation
  end

  def metadata
    @annotation[:object_type] = @annotation.class.to_s
    @annotation[:child_object_name] = 'annotation'
    @annotation[:child_object_plural] = 'annotations'<commit_msg>Fixed annotation create permissions logic.<commit_after>class AnnotationsController < BaseController

  cache_sweeper :annotation_sweeper

  before_filter :require_user, :except => [:show, :embedded_pager]
  before_filter :load_annotation, :only => [:show, :edit, :update, :destroy, :metadata]

  access_control do
    allow all, :to => [:show, :metadata, :embedded_pager]
    allow :superadmin, :admin, :collages_admin

    allow logged_in, :to => [:destroy, :edit, :update, :autocomplete_layers], :if => :allow_edit?
    allow logged_in, :to => [:create, :new]
    allow :owner, :of => :collage, :to => [:destroy, :edit, :update, :create, :new, :autocomplete_layers]
  end

  def allow_edit?
    load_annotation

    current_user.can_permission_collage("edit_annotations", @collage)
  end

  def embedded_pager
    super Annotation
  end

  def metadata
    @annotation[:object_type] = @annotation.class.to_s
    @annotation[:child_object_name] = 'annotation'
    @annotation[:child_object_plural] = 'annotations'
{'fraction_non_alphanumeric': 0.12778904665314403, 'fraction_numerical': 0.0, 'mean_word_length': 5.165625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, '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': '3420687', 'n_tokens_mistral': 655, 'n_tokens_neox': 625, 'n_words': 150}