diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 53052dd1c..0b1f1995e 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -170,7 +170,6 @@ class OrganisationsController < ApplicationController @organisation.data_protection_confirmation.update!( confirmed: true, data_protection_officer: current_user, - created_at: Time.zone.now, signed_at: Time.zone.now, organisation_name: @organisation.name, organisation_address: @organisation.address_row, diff --git a/app/helpers/data_sharing_agreement_helper.rb b/app/helpers/data_sharing_agreement_helper.rb index c6a088461..662f1b30b 100644 --- a/app/helpers/data_sharing_agreement_helper.rb +++ b/app/helpers/data_sharing_agreement_helper.rb @@ -23,7 +23,7 @@ module DataSharingAgreementHelper def name_for_data_sharing_agreement(data_protection_confirmation, user) if data_protection_confirmation&.confirmed? - data_protection_confirmation.data_protection_officer.name + data_protection_confirmation.data_protection_officer_name elsif user.is_dpo? user.name else @@ -33,7 +33,7 @@ module DataSharingAgreementHelper def org_name_for_data_sharing_agreement(data_protection_confirmation, user) if data_protection_confirmation&.confirmed? - data_protection_confirmation.organisation.name + data_protection_confirmation.organisation_name else user.organisation.name end @@ -42,11 +42,11 @@ module DataSharingAgreementHelper # rubocop:disable Rails/HelperInstanceVariable def present_section_12_2(data_protection_confirmation:, user:, organisation:) if data_protection_confirmation&.confirmed? - @org_address = data_protection_confirmation.organisation.address_row - @org_name = data_protection_confirmation.organisation.name - @org_phone = data_protection_confirmation.organisation.phone - @dpo_name = data_protection_confirmation.data_protection_officer.name - @dpo_email = data_protection_confirmation.data_protection_officer.email + @org_address = data_protection_confirmation.organisation_address + @org_name = data_protection_confirmation.organisation_name + @org_phone = data_protection_confirmation.organisation_phone_number + @dpo_name = data_protection_confirmation.data_protection_officer_name + @dpo_email = data_protection_confirmation.data_protection_officer_email else @org_name = organisation.name @org_address = organisation.address_row @@ -83,7 +83,7 @@ private def data_sharing_agreement_second_line(organisation:, user:) if organisation.data_protection_confirmed? - organisation.data_protection_confirmation.data_protection_officer.name if user.support? + organisation.data_protection_confirmation.data_protection_officer_name if user.support? else "Data protection officer must sign" unless user.is_dpo? end diff --git a/app/services/imports/data_protection_confirmation_import_service.rb b/app/services/imports/data_protection_confirmation_import_service.rb index abf187f3c..0ee936433 100644 --- a/app/services/imports/data_protection_confirmation_import_service.rb +++ b/app/services/imports/data_protection_confirmation_import_service.rb @@ -37,7 +37,6 @@ module Imports data_protection_officer: dp_officer, old_id: record_field_value(xml_document, "id"), old_org_id: record_field_value(xml_document, "institution"), - created_at: record_field_value(xml_document, "change-date").to_time(:utc), signed_at: record_field_value(xml_document, "change-date").to_time(:utc), organisation_name: org.name, organisation_address: org.address_row, diff --git a/app/views/organisations/data_sharing_agreement.html.erb b/app/views/organisations/data_sharing_agreement.html.erb index f60d64b7c..ea752ce7b 100644 --- a/app/views/organisations/data_sharing_agreement.html.erb +++ b/app/views/organisations/data_sharing_agreement.html.erb @@ -7,7 +7,7 @@
<% if @data_protection_confirmation&.confirmed? %> - This agreement is made the <%= @data_protection_confirmation.created_at.day.ordinalize %> day of <%= @data_protection_confirmation.created_at.strftime("%B") %> <%= @data_protection_confirmation.created_at.year %> + This agreement is made the <%= @data_protection_confirmation.signed_at.day.ordinalize %> day of <%= @data_protection_confirmation.signed_at.strftime("%B") %> <%= @data_protection_confirmation.signed_at.year %> <% elsif current_user.is_dpo? %> This agreement is made the <%= Time.zone.now.day.ordinalize %> day of <%= Time.zone.now.strftime("%B") %> <%= Time.zone.now.year %> <% else %> @@ -16,7 +16,7 @@
between
<% if @data_protection_confirmation&.confirmed? %> -1) <%= @data_protection_confirmation.organisation.name %> of <%= @data_protection_confirmation.organisation.address_row %> (“CORE Data Provider”)
+1) <%= @data_protection_confirmation.organisation_name %> of <%= @data_protection_confirmation.organisation_address %> (“CORE Data Provider”)
<% else %>1) <%= @organisation.name %> of <%= @organisation.address_row %> (“CORE Data Provider”)
<% end %> diff --git a/lib/tasks/data_import.rake b/lib/tasks/data_import.rake index 6e0fdd4b9..0dede82a3 100644 --- a/lib/tasks/data_import.rake +++ b/lib/tasks/data_import.rake @@ -28,21 +28,4 @@ namespace :core do raise "Type #{type} is not supported by data_import" end end - - desc "Persist user and org data on data sharing confirmations" - task persist_user_and_org_data_on_data_sharing_confirmations: :environment do |_task| - DataProtectionConfirmation.all.includes(:data_protection_officer, :organisation).each do |dpc| - dpc.update!( - organisation_name: dpc.organisation.name, - organisation_address: dpc.organisation.address_row, - signed_at: dpc.created_at, - organisation_phone_number: dpc.organisation.phone, - data_protection_officer_email: dpc.data_protection_officer.email, - data_protection_officer_name: dpc.data_protection_officer.name, - ) - print "." - end - - puts "done" - end end diff --git a/spec/factories/data_protection_confirmation.rb b/spec/factories/data_protection_confirmation.rb index 3646ea735..24ef504df 100644 --- a/spec/factories/data_protection_confirmation.rb +++ b/spec/factories/data_protection_confirmation.rb @@ -3,11 +3,18 @@ FactoryBot.define do organisation { association :organisation, data_protection_confirmation: instance } data_protection_officer { association :user, :data_protection_officer, organisation: (instance.organisation || organisation) } + organisation_name { organisation.name } + organisation_address { organisation.address_row } + organisation_phone_number { organisation.phone } + data_protection_officer_name { data_protection_officer.name } + data_protection_officer_email { data_protection_officer.email } + confirmed { true } old_org_id { "7c5bd5fb549c09a2c55d7cb90d7ba84927e64618" } old_id { "7c5bd5fb549c09a2c55d7cb90d7ba84927e64618" } created_at { Time.zone.now } updated_at { Time.zone.now } + signed_at { Time.zone.now } end end diff --git a/spec/services/imports/data_protection_confirmation_import_service_spec.rb b/spec/services/imports/data_protection_confirmation_import_service_spec.rb index 8b021cca8..fb3a1f9d2 100644 --- a/spec/services/imports/data_protection_confirmation_import_service_spec.rb +++ b/spec/services/imports/data_protection_confirmation_import_service_spec.rb @@ -50,7 +50,6 @@ RSpec.describe Imports::DataProtectionConfirmationImportService do expect(confirmation.organisation_address).to eq("2 Marsham Street, London, SW1P 4DF") expect(confirmation.organisation_name).to eq("DLUHC") expect(confirmation.organisation_phone_number).to eq("123") - expect(Time.zone.local_to_utc(confirmation.created_at)).to eq(Time.utc(2018, 0o6, 0o5, 10, 36, 49)) expect(Time.zone.local_to_utc(confirmation.signed_at)).to eq(Time.utc(2018, 0o6, 0o5, 10, 36, 49)) end end @@ -73,7 +72,6 @@ RSpec.describe Imports::DataProtectionConfirmationImportService do expect(confirmation.organisation_address).to eq("2 Marsham Street, London, SW1P 4DF") expect(confirmation.organisation_name).to eq("DLUHC") expect(confirmation.organisation_phone_number).to eq("123") - expect(Time.zone.local_to_utc(confirmation.created_at)).to eq(Time.utc(2018, 0o6, 0o5, 10, 36, 49)) expect(Time.zone.local_to_utc(confirmation.signed_at)).to eq(Time.utc(2018, 0o6, 0o5, 10, 36, 49)) end diff --git a/spec/views/organisations/data_sharing_agreement.html.erb_spec.rb b/spec/views/organisations/data_sharing_agreement.html.erb_spec.rb index 9fda45274..3c57dcf8a 100644 --- a/spec/views/organisations/data_sharing_agreement.html.erb_spec.rb +++ b/spec/views/organisations/data_sharing_agreement.html.erb_spec.rb @@ -41,7 +41,7 @@ RSpec.describe "organisations/data_sharing_agreement.html.erb", :aggregate_failu create( :data_protection_confirmation, organisation:, - created_at: Time.zone.now - 1.day, + signed_at: Time.zone.now - 1.day, ) end @@ -85,7 +85,7 @@ RSpec.describe "organisations/data_sharing_agreement.html.erb", :aggregate_failu create( :data_protection_confirmation, organisation:, - created_at: Time.zone.now - 1.day, + signed_at: Time.zone.now - 1.day, data_protection_officer: dpo, ) end @@ -137,7 +137,7 @@ RSpec.describe "organisations/data_sharing_agreement.html.erb", :aggregate_failu create( :data_protection_confirmation, organisation:, - created_at: Time.zone.now - 1.day, + signed_at: Time.zone.now - 1.day, ) end