<commit_before>class NotesController < ApplicationController

  def show
    @note = Note.find(params[:id])
    if @logged_in.can_see?(@note)
      @person = @note.person
    else
      render :text => 'You are not authorized to view this note', :layout => true, :status => 401
    end
  end
  
  def new
    @note = Note.new(:group => Group.find_by_id(params[:group_id]))
  end
  
  def create
    @note = Note.create(params[:note].merge(:person_id => @logged_in))
    unless @note.errors.any?
      flash[:notice] = 'Note saved.'
      redirect_to @note
    else
      render :action => 'new'
    end
  end
  
  def edit
    @note = Note.find(params[:id])
    unless @logged_in.can_edit?(@note)
      render :text => 'You are not authorized.', :layout => true, :status => 401
    end
  end
  
  def update
    @note = Note.find(params[:id])
    if @logged_in.can_edit?(@note)
      if @note.update_attributes(params[:note])
        redirect_to @note
      else
        render :action => 'edit'
      end
    else
      render :text => 'You are not authorized.', :layout => true, :status => 401
    end
  end
  
  def destroy<commit_msg>Fix new note ownership.<commit_after>class NotesController < ApplicationController

  def show
    @note = Note.find(params[:id])
    if @logged_in.can_see?(@note)
      @person = @note.person
    else
      render :text => 'You are not authorized to view this note', :layout => true, :status => 401
    end
  end
  
  def new
    @note = Note.new(:group => Group.find_by_id(params[:group_id]))
  end
  
  def create
    @note = Note.create(params[:note].merge(:person_id => @logged_in.id))
    unless @note.errors.any?
      flash[:notice] = 'Note saved.'
      redirect_to @note
    else
      render :action => 'new'
    end
  end
  
  def edit
    @note = Note.find(params[:id])
    unless @logged_in.can_edit?(@note)
      render :text => 'You are not authorized.', :layout => true, :status => 401
    end
  end
  
  def update
    @note = Note.find(params[:id])
    if @logged_in.can_edit?(@note)
      if @note.update_attributes(params[:note])
        redirect_to @note
      else
        render :action => 'edit'
      end
    else
      render :text => 'You are not authorized.', :layout => true, :status => 401
    end
  end
  
  def destroy
{'fraction_non_alphanumeric': 0.13193534294451725, 'fraction_numerical': 0.007863695937090432, 'mean_word_length': 2.60062893081761, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '4209918', 'n_tokens_mistral': 766, 'n_tokens_neox': 745, 'n_words': 202}