<commit_before>class Users::DossiersController < UsersController
  include SmartListing::Helper::ControllerExtensions
  helper SmartListing::Helper

  SESSION_USER_RETURN_LOCATION = 'user_return_to'

  before_action :store_user_location!, only: :new
  before_action :authenticate_user!, except: [:commencer, :commencer_test]
  before_action :check_siret, only: :siret_informations

  before_action only: [:show] do
    authorized_routes? self.class
  end

  def commencer_test
    procedure_path = ProcedurePath.find_by(path: params[:procedure_path])
    procedure = procedure_path&.procedure

    if procedure&.brouillon_avec_lien?
      redirect_to new_users_dossier_path(procedure_id: procedure.id, brouillon: true)
    else
      flash.alert = "La démarche est inconnue."
      redirect_to root_path
    end
  end

  def commencer
    procedure_path = ProcedurePath.find_by(path: params[:procedure_path])
    procedure = procedure_path&.procedure

    if procedure.present?
      if procedure.archivee?
        @dossier = Dossier.new(procedure: procedure)

        render 'commencer/archived'<commit_msg>Allow users to fill dossiers on démarches en brouillon<commit_after>class Users::DossiersController < UsersController
  include SmartListing::Helper::ControllerExtensions
  helper SmartListing::Helper

  SESSION_USER_RETURN_LOCATION = 'user_return_to'

  before_action :store_user_location!, only: :new
  before_action :authenticate_user!, except: [:commencer, :commencer_test]
  before_action :check_siret, only: :siret_informations

  before_action only: [:show] do
    authorized_routes? self.class
  end

  def commencer_test
    procedure_path = ProcedurePath.find_by(path: params[:procedure_path])
    procedure = procedure_path&.procedure

    if procedure&.brouillon? && procedure&.path.present?
      redirect_to new_users_dossier_path(procedure_id: procedure.id, brouillon: true)
    else
      flash.alert = "La démarche est inconnue."
      redirect_to root_path
    end
  end

  def commencer
    procedure_path = ProcedurePath.find_by(path: params[:procedure_path])
    procedure = procedure_path&.procedure

    if procedure.present?
      if procedure.archivee?
        @dossier = Dossier.new(procedure: procedure)

        render 'commencer/archived'
{'fraction_non_alphanumeric': 0.08, 'fraction_numerical': 0.0, 'mean_word_length': 4.647642679900744, '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': '2001845', 'n_tokens_mistral': 727, 'n_tokens_neox': 676, 'n_words': 146}