Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
gregoirenovel committed Oct 17, 2018
2 parents bc0756c + dcb9a75 commit c741d27
Show file tree
Hide file tree
Showing 23 changed files with 611 additions and 251 deletions.
54 changes: 54 additions & 0 deletions app/assets/stylesheets/new_design/etablissement.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@import "constants";
@import "colors";

.etablissement {
margin-top: $default-padding * 2;
margin-bottom: $default-padding * 2;

h1 {
margin-bottom: $default-padding * 2;
}

p {
margin-bottom: $default-padding;
}

.etablissement-infos {
margin-top: $default-padding * 2;
margin-bottom: $default-padding * 2;

> * {
margin-bottom: $default-padding;

&:last-child {
margin-bottom: 0;
}
}

ul {
line-height: 28px;
list-style-type: disc;
list-style-position: inside;

// Inner lists
ul {
margin-left: $default-padding;
list-style-type: circle;
}
}

.etablissement-exercices {
font-style: italic;
}
}

.actions {
display: flex;
flex-wrap: wrap-reverse;
justify-content: space-between;

.button {
margin-bottom: $default-padding;
}
}
}
55 changes: 54 additions & 1 deletion app/controllers/new_user/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,50 @@ def update_identite
end
end

def siret
@dossier = dossier
end

def update_siret
@dossier = dossier

# We use the user as the holder model object for the siret value
# (so that we can restore it on the form in case of error).
#
# This is the only remaining use of User#siret: it could be refactored away.
# However some existing users have a siret but no associated etablissement,
# so we would need to analyze the legacy data and decide what to do with it.
current_user.siret = siret_params[:siret]

siret_model = Siret.new(siret: siret_params[:siret])
if !siret_model.valid?
return render_siret_error(siret_model.errors.full_messages)
end

sanitized_siret = siret_model.siret
etablissement_attributes = ApiEntrepriseService.get_etablissement_params_for_siret(sanitized_siret, @dossier.procedure.id)
if etablissement_attributes.blank?
return render_siret_error(t('errors.messages.siret_unknown'))
end

etablissement = @dossier.build_etablissement(etablissement_attributes)
etablissement.save!
current_user.update!(siret: sanitized_siret)
@dossier.update!(autorisation_donnees: true)

redirect_to etablissement_dossier_path
end

def etablissement
@dossier = dossier

# Redirect if the user attempts to access the page URL directly
if !@dossier.etablissement
flash.alert = 'Aucun établissement n’est associé à ce dossier'
return redirect_to siret_dossier_path(@dossier)
end
end

def brouillon
@dossier = dossier_with_champs

Expand All @@ -77,7 +121,7 @@ def brouillon
if dossier.procedure.for_individual
redirect_to identite_dossier_path(@dossier)
else
redirect_to users_dossier_path(@dossier)
redirect_to siret_dossier_path(@dossier)
end
end
end
Expand Down Expand Up @@ -251,10 +295,19 @@ def forbidden!
redirect_to root_path
end

def render_siret_error(error_message)
flash.alert = error_message
render :siret
end

def individual_params
params.require(:individual).permit(:gender, :nom, :prenom, :birthdate)
end

def siret_params
params.require(:user).permit(:siret)
end

def commentaire_params
params.require(:commentaire).permit(:body, :file)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def new
if dossier.procedure.for_individual
redirect_to identite_dossier_path(dossier)
else
redirect_to users_dossier_path(id: dossier.id)
redirect_to siret_dossier_path(id: dossier.id)
end
rescue ActiveRecord::RecordNotFound
error_procedure
Expand Down
15 changes: 8 additions & 7 deletions app/views/admin/procedures/_informations.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
- else
%a{ href: url_for(deliberation), target: '_blank' }
= deliberation.filename.to_s
= link_to 'supprimer', delete_deliberation_admin_procedure_path(@procedure),
method: :delete
- if @procedure.persisted?
= link_to 'supprimer', delete_deliberation_admin_procedure_path(@procedure), method: :delete
%br
Modifier :
= f.file_field :deliberation,
Expand All @@ -75,9 +75,9 @@
- else
%a{ href: url_for(notice), target: '_blank' }
= notice.filename.to_s
\-
= link_to 'supprimer', delete_notice_admin_procedure_path(@procedure),
method: :delete
- if @procedure.persisted?
\-
= link_to 'supprimer', delete_notice_admin_procedure_path(@procedure), method: :delete
%br
Modifier :
= f.file_field :notice,
Expand All @@ -89,8 +89,9 @@
- if @procedure.logo.present?
= image_tag @procedure.decorate.logo_img, { style: 'height: 40px; display: inline; margin-right: 6px;', id: 'preview_procedure_logo' }
\-
= link_to 'supprimer', delete_logo_admin_procedure_path(@procedure),
method: :delete

- if @procedure.persisted?
= link_to 'supprimer', delete_logo_admin_procedure_path(@procedure), method: :delete
= f.file_field :logo, accept: 'image/png, image/jpg, image/jpeg', style: 'display: inline'

%div{ style: 'margin-top: 5px;' }
Expand Down
9 changes: 9 additions & 0 deletions app/views/new_user/dossiers/_demarche_overview.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.procedure-logos
= image_tag procedure.decorate.logo_img
- if procedure.euro_flag
= image_tag "flag_of_europe.svg"

%h2.procedure-title
= procedure.libelle
.procedure-description
= h string_to_html(procedure.description)
35 changes: 35 additions & 0 deletions app/views/new_user/dossiers/etablissement.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
- content_for(:title, "Informations sur l’établissement")

- content_for :footer do
= render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier }

.etablissement
.container
%h1 Informations sur l’établissement

%p
Nous avons récupéré auprès de l’INSEE et d’Infogreffe les informations suivantes concernant votre établissement.

%p
Ces informations seront jointes à votre dossier.

.etablissement-infos.card.featured
- etablissement = @dossier.etablissement
%h2.card-title= raison_sociale_or_name(etablissement)

= render partial: 'new_user/dossiers/etablissement/infos_entreprise', locals: { etablissement: etablissement }

- if etablissement.association?
= render partial: 'new_user/dossiers/etablissement/infos_association', locals: { etablissement: etablissement }

.actions
= link_to 'Utiliser un autre numéro SIRET', siret_dossier_path(@dossier), class: 'button'

- if @dossier.procedure.use_api_carto
/ Until the old layout is gone, we need to disable turbolinks
/ to avoid the map loading twice (once for the turbolinks preview,
/ once when turbolinks notices the layout are differents and reloads
/ the page.)
= link_to 'Continuer avec ces informations', users_dossier_carte_path(@dossier), class: 'button primary', data: { turbolinks: false }
- else
= link_to 'Continuer avec ces informations', brouillon_dossier_path(@dossier), class: 'button primary'
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
%ul.etablissement-infos-association
%li
Numéro d’enregistrement au Registre National des Associations :
= etablissement.association_rna

%li
Titre :
= etablissement.association_titre

%li
Objet :
= etablissement.association_objet

%li
Date de création :
= etablissement.association_date_creation&.strftime('%d/%m/%Y')

%li
Date de déclaration :
= etablissement.association_date_declaration&.strftime('%d/%m/%Y')

%li
Date de publication :
= etablissement.association_date_publication&.strftime('%d/%m/%Y')
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
%ul.etablissement-infos-entreprise
%li
Siret :
= etablissement.siret

- if etablissement.siret != etablissement.entreprise.siret_siege_social
%li
SIRET siègle social :
= etablissement.entreprise.siret_siege_social

%li
Forme juridique :
= etablissement.entreprise.forme_juridique

%li
Libellé NAF :
= etablissement.libelle_naf

%li
Code NAF :
= etablissement.naf

%li
Date de création :
= etablissement.entreprise.date_creation&.strftime('%d/%m/%Y')

%li
Effectif organisation :
= effectif(etablissement)

%li
Code effectif :
= etablissement.entreprise.code_effectif_entreprise

%li
Numéro TVA intracommunautaire :
= etablissement.entreprise.numero_tva_intracommunautaire

%li
Adresse :
- etablissement.adresse.split("\n").each do |line|
= line

%li
Capital social :
= pretty_currency(etablissement.entreprise.capital_social)

- if etablissement.exercices.present?
%p.etablissement-exercices Les exercices comptables des trois dernières années seront joints à votre dossier.
10 changes: 1 addition & 9 deletions app/views/new_user/dossiers/identite.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
.two-columns
.columns-container
.column.preview
.procedure-logos
= image_tag @dossier.procedure.decorate.logo_img
- if @dossier.procedure.euro_flag
= image_tag "flag_of_europe.svg"

%h2.procedure-title
= @dossier.procedure.libelle
.procedure-description
= h string_to_html(@dossier.procedure.description)
= render partial: "new_user/dossiers/demarche_overview", locals: { procedure: @dossier.procedure }

.column.identity-form
= render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }
Expand Down
25 changes: 25 additions & 0 deletions app/views/new_user/dossiers/siret.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- content_for(:title, "Nouveau dossier (#{@dossier.procedure.libelle})")

- content_for :footer do
= render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier }

.two-columns
.columns-container
.column.preview
= render partial: "new_user/dossiers/demarche_overview", locals: { procedure: @dossier.procedure }

.column.identity-form
= render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }

- if !dossier_submission_is_closed?(@dossier)
= form_for current_user, url: siret_dossier_path(@dossier), html: { class: 'form', method: 'post' } do |f|
%h1 Identifier votre établissement

%p.mb-1 Merci de remplir le numéro de SIRET de votre entreprise, administration ou association pour commencer la démarche.

= f.label :siret, style: "display: none"
= f.text_field :siret, placeholder: "Numéro SIRET à 14 chiffres", required: true

= f.hidden_field :dossier_id, value: @dossier.id

= f.submit "Valider", class: "button large primary expand", data: { disable_with: "Récupération des informations…" }
12 changes: 11 additions & 1 deletion config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@
end
end

namespace :after_party do
desc "Run after_party tasks."
task :run do
queue %{
echo "-----> Running deploy tasks"
#{echo_cmd %[#{rake} after_party:run]}
}
end
end

desc "Deploys the current version to the server."
task :deploy => :environment do
queue 'export PATH=$PATH:/usr/local/rbenv/bin:/usr/local/rbenv/shims'
Expand All @@ -116,7 +126,7 @@
invoke :'bundle:install'
invoke :'yarn:install'
invoke :'rails:db_migrate'
invoke :'rake[after_party:run]'
invoke :'after_party:run'
invoke :'rails:assets_precompile:force'

to :launch do
Expand Down
3 changes: 3 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ fr:
activerecord:
attributes:
user:
siret: 'Numéro SIRET'
password: 'Le mot de passe'
gestionnaire:
password: 'Le mot de passe'
Expand Down Expand Up @@ -170,6 +171,8 @@ fr:
dossier_map_not_activated: "Le dossier n'a pas accès à la cartographie."
invalid_siret: "Le siret est incorrect"
procedure_not_found: "La démarche n'existe pas"
siret_unknown: 'Désolé, nous n’avons pas trouvé d’établissement enregistré correspondant à ce numéro SIRET'
etablissement_fail: 'Désolé, nous n’avons pas réussi à enregistrer l’établissement correspondant à ce numéro SIRET'
france_connect:
connexion: "Erreur lors de la connexion à France Connect."
extension_white_list_error: "Le format de fichier de la pièce jointe n'est pas valide."
Expand Down
12 changes: 12 additions & 0 deletions config/locales/models/siret/fr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fr:
activemodel:
models:
siret: 'SIRET'
errors:
models:
siret:
attributes:
siret:
format: 'Le numéro SIRET doit comporter 14 chiffres'
checksum: 'Le numéro SIRET comporte une erreur, vérifiez les chiffres composant le numéro'
invalid: 'Le numéro SIRET ne correspond pas à un établissement existant'
Loading

0 comments on commit c741d27

Please sign in to comment.