Skip to content

Commit

Permalink
BSP-72 text changes and new skills field
Browse files Browse the repository at this point in the history
  • Loading branch information
apricot13 committed Jun 14, 2024
1 parent 1f47318 commit aa9d718
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 290 deletions.
2 changes: 2 additions & 0 deletions app/controllers/concerns/employee_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def employee_params
:safeguarding_achieved_on,
:has_senco_early_years,
:senco_early_years_achieved_on,
:has_designated_safeguarding_lead,
:designated_safeguarding_lead_achieved_on,

employee_qualifications_attributes: [:id, :qualification_id, :achieved_on, :_destroy],

Expand Down
11 changes: 10 additions & 1 deletion app/models/employee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Employee < ApplicationRecord
# ----------
attr_accessor :skip_validations
validates_presence_of :surname, :forenames, :employed_from, :date_of_birth, :street_address, :job_title, unless: :skip_validations
validate :employed_to_or_currently_employed, :has_food_hygiene_qualification_or_achieved_on, :has_dbs_check_or_achieved_on, :has_first_aid_training_or_achieved_on, :has_senco_or_achieved_on, :has_senco_early_years_or_achieved_on, :has_safeguarding_or_achieved_on, unless: :skip_validations
validate :employed_to_or_currently_employed, :has_food_hygiene_qualification_or_achieved_on, :has_dbs_check_or_achieved_on, :has_first_aid_training_or_achieved_on, :has_senco_or_achieved_on, :has_senco_early_years_or_achieved_on, :has_safeguarding_or_achieved_on, :has_designated_safeguarding_lead_or_achieved_on, unless: :skip_validations
validates :job_title, inclusion: { in: :accepted_job_titles, message: "%{value} is not a valid job title" }, unless: :skip_validations

def accepted_job_titles
Expand Down Expand Up @@ -318,4 +318,13 @@ def has_safeguarding_or_achieved_on
end
end

def has_designated_safeguarding_lead_or_achieved_on
if (has_designated_safeguarding_lead && !designated_safeguarding_lead_achieved_on)
errors.add(:base, "Please add the date this person achieved Designated Safeguarding Lead training course")
elsif (!has_designated_safeguarding_lead && designated_safeguarding_lead_achieved_on)
errors.add(:base, "Please tick Designated Safeguarding Lead field or remove the date achieved")
end
end


end
9 changes: 8 additions & 1 deletion app/views/admin/employees/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@
@employee.has_food_hygiene,
@employee.has_senco_training,
@employee.has_safeguarding,
@employee.has_senco_early_years].any? %>
@employee.has_senco_early_years,
@employee.has_designated_safeguarding_lead].any? %>
<table class="table--employee-info">
<tr class="table-column">
<th>Skill</th>
Expand Down Expand Up @@ -158,6 +159,12 @@
<td><%= @employee.senco_early_years_achieved_on.strftime("%d/%m/%Y") %></td>
</tr>
<% end %>
<% if @employee.has_designated_safeguarding_lead %>
<tr class="table-column">
<td>Designated Safeguarding Lead training</td>
<td><%= @employee.designated_safeguarding_lead_achieved_on.strftime("%d/%m/%Y") %></td>
</tr>
<% end %>
</table>
<% else %>
<p>No skills added</p>
Expand Down
28 changes: 19 additions & 9 deletions app/views/employees/editors/_skills.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="checkbox field">
<%= f.check_box :has_food_hygiene, {class: "checkbox__input"} %>
<%= f.label :has_food_hygiene, "Does this person have food hygiene qualification?", class: "checkbox__label" %>
<%= f.label :has_food_hygiene, "Does this person have a food hygiene qualification?", class: "checkbox__label" %>
</div>

<div class="field">
Expand All @@ -14,33 +14,33 @@
</div>

<div class="field">
<%= f.label :dbs_achieved_on, "If so, when did they achieve it?", class: "field__label" %>
<%= f.label :dbs_achieved_on, "If so, when was the check made?", class: "field__label" %>
<%= f.date_field :dbs_achieved_on, class: "field__input", min: Date.today - 80.years, max: Date.today %>
</div>

<div class="checkbox field">
<%= f.check_box :has_first_aid_training, {class: "checkbox__input"} %>
<%= f.label :has_first_aid_training, "Does this person have paediatric first aid training?", class: "checkbox__label" %>
<%= f.label :has_first_aid_training, "Has this person attended a Paediatric First Aid training course?", class: "checkbox__label" %>
</div>

<div class="field">
<%= f.label :first_aid_achieved_on, "If so, when did they achieve it?", class: "field__label" %>
<%= f.label :first_aid_achieved_on, "If so, when did they attend?", class: "field__label" %>
<%= f.date_field :first_aid_achieved_on, class: "field__input", min: Date.today - 80.years, max: Date.today %>
</div>

<div class="checkbox field">
<%= f.check_box :has_senco_training, {class: "checkbox__input"} %>
<%= f.label :has_senco_training, "Does this person have SENCO training?", class: "checkbox__label" %>
<%= f.label :has_senco_training, "Has this person completed their initial SENCO training?", class: "checkbox__label" %>
</div>

<div class="field">
<%= f.label :senco_achieved_on, "If so, when did they achieve it?", class: "field__label" %>
<%= f.label :senco_achieved_on, "If so, when did they complete it?", class: "field__label" %>
<%= f.date_field :senco_achieved_on, class: "field__input", min: Date.today - 80.years, max: Date.today %>
</div>

<div class="checkbox field">
<%= f.check_box :has_senco_early_years, {class: "checkbox__input"} %>
<%= f.label :has_senco_early_years, "Does this person have early years level 3 SENCO?", class: "checkbox__label" %>
<%= f.label :has_senco_early_years, "Has this person completed the Level 3 Award for SENCOs in the Early Years?", class: "checkbox__label" %>
</div>

<div class="field">
Expand All @@ -50,10 +50,20 @@

<div class="checkbox field">
<%= f.check_box :has_safeguarding, {class: "checkbox__input"} %>
<%= f.label :has_safeguarding, "Does this person have (Other Safeguarding) Safeguarding for all training?", class: "checkbox__label" %>
<%= f.label :has_safeguarding, "Has this person attended a Safeguarding For All training course?", class: "checkbox__label" %>
</div>

<div class="field">
<%= f.label :safeguarding_achieved_on, "If so, when did they achieve it?", class: "field__label" %>
<%= f.label :safeguarding_achieved_on, "If so, when did they attend?", class: "field__label" %>
<%= f.date_field :safeguarding_achieved_on, class: "field__input", min: Date.today - 80.years, max: Date.today %>
</div>

<div class="checkbox field">
<%= f.check_box :has_designated_safeguarding_lead, {class: "checkbox__input"} %>
<%= f.label :has_designated_safeguarding_lead, "Has this person attended a Designated Safeguarding Lead training course?", class: "checkbox__label" %>
</div>

<div class="field">
<%= f.label :designated_safeguarding_lead_achieved_on, "If so, when did they attend?", class: "field__label" %>
<%= f.date_field :designated_safeguarding_lead_achieved_on, class: "field__input", min: Date.today - 80.years, max: Date.today %>
</div>
6 changes: 6 additions & 0 deletions db/migrate/20240614193034_add_designated_safeguarding_lead.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddDesignatedSafeguardingLead < ActiveRecord::Migration[6.1]
def change
add_column :employees, :has_designated_safeguarding_lead, :boolean
add_column :employees, :designated_safeguarding_lead_achieved_on, :date
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2024_05_22_121053) do
ActiveRecord::Schema.define(version: 2024_06_14_193034) do

# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
Expand Down Expand Up @@ -64,6 +64,8 @@
t.datetime "marked_for_deletion"
t.boolean "early_years_children"
t.boolean "outside_school_hours"
t.boolean "has_designated_safeguarding_lead"
t.date "designated_safeguarding_lead_achieved_on"
end

create_table "qualifications", force: :cascade do |t|
Expand Down
3 changes: 3 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def employee_attributes
has_senco_training = [true, false].sample
has_senco_early_years = [true, false].sample
has_safeguarding = [true, false].sample
has_designated_safeguarding_lead = [true, false].sample

accepted_roles = Employee.new.accepted_roles

Expand Down Expand Up @@ -61,6 +62,8 @@ def employee_attributes
senco_early_years_achieved_on: has_senco_early_years ? FFaker::Time.date(year_latest: 18, year_range: 65 - 18) : nil,
has_safeguarding: has_safeguarding,
safeguarding_achieved_on: has_safeguarding ? FFaker::Time.date(year_latest: 18, year_range: 65 - 18) : nil,
has_designated_safeguarding_lead: has_designated_safeguarding_lead,
designated_safeguarding_lead_achieved_on: has_designated_safeguarding_lead ? FFaker::Time.date(year_latest: 18, year_range: 65 - 18) : nil,

}

Expand Down
Loading

0 comments on commit aa9d718

Please sign in to comment.