Skip to content

Commit

Permalink
Correction de tests et factorisation de la barre de recherche
Browse files Browse the repository at this point in the history
  • Loading branch information
tnicolas1 committed Jan 24, 2025
1 parent fedce58 commit 04212bd
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 25 deletions.
12 changes: 9 additions & 3 deletions app/controllers/asp/schoolings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ module ASP
class SchoolingsController < ApplicationController
layout "application"

before_action :set_pfmps, only: :show
before_action :set_schooling, :set_pfmps, only: :show
before_action :set_search_result, :infer_page_title, only: :index

def index; end

def show; end
def show
infer_page_title(attributive_decision_number: @schooling.attributive_decision_number)
end

private

def set_schooling
@schooling = Schooling.find(params[:id])
end

def set_pfmps
return if @schooling.nil?

Expand All @@ -33,7 +39,7 @@ def set_search_result
def find_schooling_by_attributive_decision_filename
Schooling
.joins(:attributive_decision_blob)
.find_by("filename LIKE ?", "%_#{@attributive_decision_number.strip.upcase}.pdf")
.where("filename LIKE ?", "%#{@attributive_decision_number.strip.upcase}%")
end
end
end
6 changes: 6 additions & 0 deletions app/views/asp/schoolings/_search-bar.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.fr-mb-3w
= form_with method: :get, url: asp_schoolings_path do |form|
.fr-search-bar.fr-search-bar--lg.fr-col-md-8{id: "search", role: "search"}
= form.label :search, "Numéro de décision d'attribution...", class: "fr-label"
= form.text_field :search, placeholder: "Numéro de décision d'attribution", value: @attributive_decision_number, class: "fr-input"
= form.button "Rechercher", type: "submit", class: "fr-btn", name: nil
9 changes: 2 additions & 7 deletions app/views/asp/schoolings/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
.fr-mb-3w
= form_with method: :get, url: asp_schoolings_path do |form|
.fr-search-bar.fr-search-bar--lg.fr-col-md-8{id: "search", role: "search"}
= form.label :search, "Numéro de décision d'attribution...", class: "fr-label"
= form.text_field :search, placeholder: "Numéro de décision d'attribution", value: @attributive_decision_number, class: "fr-input"
= form.button "Rechercher", type: "submit", class: "fr-btn", name: nil
= render partial: 'search-bar'

- if @attributive_decision_number.blank?
.fr-mb-5w
Expand All @@ -24,7 +19,7 @@
%tbody
- @schoolings.each do |schooling|
%tr
%td= dsfr_link_to schooling.attributive_decision_number, asp_schoolings_path(schooling)
%td= dsfr_link_to schooling.attributive_decision_number, asp_schooling_path(schooling)
%td= schooling.student.full_name
%td= schooling.classe.label

26 changes: 15 additions & 11 deletions app/views/asp/schoolings/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
%h1
Dossier
= @schooling.attributive_decision_number
= render partial: 'search-bar'

%h1.fr-mb-5w= @page_title

.fr-my-3w
- if @schooling.attributive_decision.present?
= link_to "Télécharger la décision d'attribution", url_for(@schooling.attributive_decision), class: 'fr-btn fr-btn--secondary', target: :download
- else
Aucune décision d'attribution éditée

.fr-table
.fr-table.fr-table--no-caption
%table
%caption.fr-h2 Élève
%thead
%th{colspan: 2} Élève
%tbody
%tr
%td Nom
Expand All @@ -28,9 +29,10 @@
%td Code INSEE du pays de naissance
%td= display_insee_code(@schooling.student.birthplace_country_insee_code)

.fr-table
.fr-table.fr-table--no-caption
%table
%caption.fr-h2 Établissement
%thead
%th{colspan: 2} Établissement
%tbody
%tr
%td UAI
Expand All @@ -41,9 +43,10 @@
%tr
%td Email
%td= @schooling.establishment.email
.fr-table
.fr-table.fr-table--no-caption
%table
%caption.fr-h2 Formation
%thead
%th{colspan: 2} Formation
%tbody
%tr
%td Forfait journalier
Expand All @@ -53,9 +56,10 @@
%td= number_to_currency @schooling.mef.wage.yearly_cap


.fr-table
.fr-table.fr-table--no-caption
%table
%caption.fr-h2 Coordonnées bancaires
%thead
%th{colspan: 2} Coordonnées bancaires
%tbody
- rib = @schooling.student.rib(@schooling.establishment)
- if rib.blank?
Expand Down
2 changes: 1 addition & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fr:
login: Connexion à APLyPro
schoolings:
index: Recherche d'un dossier
show: Dossier
show: "Dossier %{attributive_decision_number}"
stats:
index: Statistiques
school_years:
Expand Down
6 changes: 3 additions & 3 deletions features/asp_consultation_de_dossier.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ Fonctionnalité: Le personnel ASP consulte des dossiers
Sachant que le numéro administratif de "Marie Curie" est "THEDOSS"
Et que je remplis "Numéro de décision d'attribution" avec "ENPUTHEDOSS20240"
Quand je clique sur "Rechercher"
Alors la page contient "ENPUTHEDOSS20240"
Et la page contient "3 jours x 10 € par jour = 30 €"
Quand je clique sur "ENPUTHEDOSS20240"
Alors la page contient "3 jours x 10 € par jour = 30 €"
Et la page contient "IBAN"

Scénario: Le personnel ASP n'a pas accès à l'interface principale
Quand je me rends sur la page d'accueil
Alors le titre de la page contient "Rechercher un dossier"
Alors le titre de la page contient "Recherche d'un dossier"
Et la page ne contient pas "Classes"
Et la page ne contient pas "Envoyer en paiement"

Expand Down

0 comments on commit 04212bd

Please sign in to comment.