From 6bc8d081c8b9bc1c36ea99d37763364557c516a3 Mon Sep 17 00:00:00 2001 From: Ryan Kendall Date: Tue, 19 Sep 2023 10:42:55 +0100 Subject: [PATCH] fix(fworks): frameworks lot field now saves correctly --- .rubocop_todo.yml | 2 ++ app/views/frameworks/frameworks/_form.html.erb | 6 +++--- .../frameworks/show/_framework_details.html.erb | 10 ++++++++++ .../20230919092926_update_lot_frameworks_framework.rb | 6 ++++++ db/schema.rb | 4 ++-- 5 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20230919092926_update_lot_frameworks_framework.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6a75bbb2a..997e95390 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -71,6 +71,7 @@ Rails/BulkChangeTable: - 'db/migrate/20220805130609_change_support_emails_in_reply_to_id.rb' - 'db/migrate/20221014140003_add_more_trust_fields_to_support_organisations.rb' - 'db/migrate/20230210133230_refactor_notifications_into_one_table.rb' + - 'db/migrate/20230919092926_update_lot_frameworks_framework.rb' # Offense count: 2 # Configuration parameters: Include. @@ -94,6 +95,7 @@ Rails/ReversibleMigration: - 'db/migrate/20201112123028_remove_answer_table.rb' - 'db/migrate/20210118110545_change_options_to_jsonb.rb' - 'db/migrate/20210125171840_remove_next_entry_id.rb' + - 'db/migrate/20230919092926_update_lot_frameworks_framework.rb' # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). diff --git a/app/views/frameworks/frameworks/_form.html.erb b/app/views/frameworks/frameworks/_form.html.erb index 164044f3e..d7967fc29 100644 --- a/app/views/frameworks/frameworks/_form.html.erb +++ b/app/views/frameworks/frameworks/_form.html.erb @@ -20,10 +20,10 @@ <%= f.govuk_fieldset legend: { text: 'Availability' } do %>
- <%= f.govuk_date_field :dfe_start_date, legend: { size: "s", text: "DfE start date", class: "" } %> + <%= f.govuk_date_field :dfe_start_date, legend: { size: "s", text: "DfE start date" } %>
- <%= f.govuk_date_field :dfe_end_date, legend: { size: "s", text: "DfE end date", class: "" } %> + <%= f.govuk_date_field :dfe_end_date, legend: { size: "s", text: "DfE end date" } %>
@@ -40,7 +40,7 @@ <% dps_options = [[true, 'Yes'], [false, 'No']] %> <%= f.govuk_collection_radio_buttons :dps, dps_options, :first, :last, inline: true, legend: { size: 's', text: 'Is this framework a DPS (Dynamic purchasing system)?' } %> - <% lot_options = [['single', 'Single-lot'], ['multi', 'Multi-lot']] %> + <% lot_options = Frameworks::Framework.lots.map {|status, id| [status, status.humanize + "-lot"] } %> <%= f.govuk_collection_radio_buttons :lot, lot_options, :first, :last, inline: true, legend: { size: 's', text: 'Is this framework a single or multi lot?' } %> <% status_options = Frameworks::Framework.statuses.map {|status, id| [status, status.humanize] } %> diff --git a/app/views/frameworks/frameworks/show/_framework_details.html.erb b/app/views/frameworks/frameworks/show/_framework_details.html.erb index 38c9d4564..88878f403 100644 --- a/app/views/frameworks/frameworks/show/_framework_details.html.erb +++ b/app/views/frameworks/frameworks/show/_framework_details.html.erb @@ -11,6 +11,16 @@
<%= link_to "Change", edit_frameworks_framework_categorisations_path(@framework, back_to: current_url_b64(:framework_details)), class: "govuk-link", "data-turbo" => false %>
+
+
Single / Multi-lot
+
<%= @framework.lot.humanize %>
+
+ +
+
DPS?
+
<%= @framework.dps? ? "Yes" : "No" %>
+
+
SCT Framework Owner
<%= @framework.sct_framework_owner %>
diff --git a/db/migrate/20230919092926_update_lot_frameworks_framework.rb b/db/migrate/20230919092926_update_lot_frameworks_framework.rb new file mode 100644 index 000000000..553902347 --- /dev/null +++ b/db/migrate/20230919092926_update_lot_frameworks_framework.rb @@ -0,0 +1,6 @@ +class UpdateLotFrameworksFramework < ActiveRecord::Migration[7.0] + def change + change_column_default :frameworks_frameworks, :lot, from: 0, to: nil + change_column :frameworks_frameworks, :lot, :integer, using: "lot::integer", default: 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index 801d7a338..357797a2a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_09_15_110928) do +ActiveRecord::Schema[7.0].define(version: 2023_09_19_092926) do # These are extensions that must be enabled in order to support this database enable_extension "citext" enable_extension "pg_trgm" @@ -254,7 +254,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.boolean "dps", default: true - t.boolean "lot", default: false + t.integer "lot", default: 0 end create_table "frameworks_provider_contacts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|