<commit_before># encoding: utf-8
class ProjectsController < ApplicationController
  load_and_authorize_resource

  before_filter :search_and_paginate, only: :index
  before_filter :set_first_users, only: [:new, :edit]
  before_filter :add_users, only: [:create, :update]

  def index
    respond_to do |format|
      format.html
      format.json { render json: @projects }
    end
  end

  def show
    @comments = @project.comments
    @documents = @project.documents

    respond_to do |format|
      format.html
      format.json { render json: @project }
    end
  end

  def new
    render_new projects_path
  end

  def edit
    render_edit @project
  end

  def create
    if @project.save
      redirect_to(@project, notice: t('c.created'))
    else
      render_edit @project
    end
  end

  def update
    if @project.update_attributes(params[:project])
      redirect_to(@project, notice: t('c.updated'))
    else
      render_edit @project
    end
  end

  def destroy
    @project.destroy

    redirect_to(projects_url)
  end

  private
  def add_users
    @project.users << current_user unless @project.users.include?(current_user)
    @project.users = params[:users] ? User.find(params[:users]) : []
  end
end<commit_msg>Ajoute réélement l'utilisateur au projet<commit_after># encoding: utf-8

class ProjectsController < ApplicationController
  load_and_authorize_resource

  before_filter :search_and_paginate, only: :index
  before_filter :set_first_users, only: [:new, :edit]
  before_filter :add_users, only: [:create, :update]

  def index
    respond_to do |format|
      format.html
      format.json { render json: @projects }
    end
  end

  def show
    @comments = @project.comments
    @documents = @project.documents

    respond_to do |format|
      format.html
      format.json { render json: @project }
    end
  end

  def new
    render_new projects_path
  end

  def edit
    render_edit @project
  end

  def create
    @project.users << current_user unless @project.users.include?(current_user)

    if @project.save
      redirect_to(@project, notice: t('c.created'))
    else
      render_edit @project
    end
  end

  def update
    if @project.update_attributes(params[:project])
      redirect_to(@project, notice: t('c.updated'))
    else
      render_edit @project
    end
  end

  def destroy
    @project.destroy

    redirect_to(projects_url)
  end

  private
  def add_users
    @project.users = params[:users] ? User.find(params[:users]) : []
  end
end
{'fraction_non_alphanumeric': 0.0906187624750499, 'fraction_numerical': 0.0007984031936127744, 'mean_word_length': 3.1149425287356323, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2873233', 'n_tokens_mistral': 805, 'n_tokens_neox': 778, 'n_words': 203}