From 3162f0e72fd53bfd1cf87f5661bb198ff785940e Mon Sep 17 00:00:00 2001 From: Steve Laing Date: Tue, 4 Oct 2016 14:27:19 +0000 Subject: [PATCH] Remove specialist document models --- app/controllers/aaib_reports_controller.rb | 2 - .../abstract_documents_controller.rb | 208 -------------- .../asylum_support_decisions_controller.rb | 2 - app/controllers/cma_cases_controller.rb | 2 - ...untryside_stewardship_grants_controller.rb | 2 - .../drug_safety_updates_controller.rb | 2 - ...nt_appeal_tribunal_decisions_controller.rb | 2 - ...mployment_tribunal_decisions_controller.rb | 2 - app/controllers/esi_funds_controller.rb | 2 - ...ernational_development_funds_controller.rb | 2 - app/controllers/maib_reports_controller.rb | 2 - .../medical_safety_alerts_controller.rb | 2 - app/controllers/raib_reports_controller.rb | 2 - .../tax_tribunal_decisions_controller.rb | 2 - app/controllers/utaac_decisions_controller.rb | 2 - ...le_recalls_and_faults_alerts_controller.rb | 2 - app/importers/cma_import.rb | 134 ---------- .../cma_import/attachment_attacher.rb | 139 ---------- app/importers/cma_import/body_fixer.rb | 137 ---------- app/importers/cma_import/mapper.rb | 74 ----- .../cma_import/missing_body_generator.rb | 53 ---- app/importers/document_import.rb | 102 ------- .../document_import/attachment_helpers.rb | 35 --- app/importers/medical_safety_alert_import.rb | 89 ------ .../medical_safety_alert_import/mapper.rb | 56 ---- app/lib/manuals_publisher.rb | 66 +---- app/lib/manuals_publisher_wiring.rb | 136 ---------- app/models/aaib_report.rb | 12 - app/models/asylum_support_decision.rb | 13 - app/models/cma_case.rb | 12 - app/models/countryside_stewardship_grant.rb | 10 - app/models/document_factory_registry.rb | 253 ------------------ app/models/drug_safety_update.rb | 29 -- .../employment_appeal_tribunal_decision.rb | 11 - app/models/employment_tribunal_decision.rb | 10 - app/models/esi_fund.rb | 11 - app/models/international_development_fund.rb | 11 - app/models/maib_report.rb | 9 - app/models/medical_safety_alert.rb | 9 - app/models/raib_report.rb | 9 - app/models/tax_tribunal_decision.rb | 9 - app/models/utaac_decision.rb | 11 - .../validators/aaib_report_validator.rb | 15 -- .../asylum_support_decision_validator.rb | 30 --- app/models/validators/cma_case_validator.rb | 17 -- ...countryside_stewardship_grant_validator.rb | 12 - .../drug_safety_update_validator.rb | 10 - ...ment_appeal_tribunal_decision_validator.rb | 16 -- .../employment_tribunal_decision_validator.rb | 16 -- app/models/validators/esi_fund_validator.rb | 13 - ...nternational_development_fund_validator.rb | 10 - .../validators/maib_report_validator.rb | 13 - .../medical_safety_alert_validator.rb | 13 - .../validators/raib_report_validator.rb | 13 - .../tax_tribunal_decision_validator.rb | 15 -- ...ub_category_relates_to_parent_validator.rb | 68 ----- .../validators/utaac_decision_validator.rb | 16 -- ...icle_recalls_and_faults_alert_validator.rb | 24 -- .../vehicle_recalls_and_faults_alert.rb | 14 - .../aaib_report_observers_registry.rb | 20 -- ..._specialist_document_observers_registry.rb | 164 ------------ ...lum_support_decision_observers_registry.rb | 24 -- app/observers/cma_case_observers_registry.rb | 20 -- ...de_stewardship_grant_observers_registry.rb | 20 -- .../drug_safety_update_observers_registry.rb | 20 -- ...al_tribunal_decision_observers_registry.rb | 24 -- ...nt_tribunal_decision_observers_registry.rb | 24 -- app/observers/esi_fund_observers_registry.rb | 20 -- ...nal_development_fund_observers_registry.rb | 20 -- .../maib_report_observers_registry.rb | 20 -- ...medical_safety_alert_observers_registry.rb | 20 -- .../raib_report_observers_registry.rb | 20 -- ...ax_tribunal_decision_observers_registry.rb | 24 -- .../utaac_decision_observers_registry.rb | 24 -- ...lls_and_faults_alert_observers_registry.rb | 20 -- app/view_adapters/aaib_report_view_adapter.rb | 29 -- .../asylum_support_decision_view_adapter.rb | 31 --- app/view_adapters/cma_case_view_adapter.rb | 30 --- ...ntryside_stewardship_grant_view_adapter.rb | 28 -- .../drug_safety_update_view_adapter.rb | 34 --- ...t_appeal_tribunal_decision_view_adapter.rb | 29 -- ...ployment_tribunal_decision_view_adapter.rb | 28 -- app/view_adapters/esi_fund_view_adapter.rb | 29 -- ...rnational_development_fund_view_adapter.rb | 26 -- app/view_adapters/maib_report_view_adapter.rb | 26 -- .../medical_safety_alert_view_adapter.rb | 24 -- app/view_adapters/raib_report_view_adapter.rb | 26 -- .../tax_tribunal_decision_view_adapter.rb | 27 -- .../utaac_decision_view_adapter.rb | 29 -- ...e_recalls_and_faults_alert_view_adapter.rb | 31 --- app/view_adapters/view_adapter_registry.rb | 18 +- app/views/aaib_reports/_form.html.erb | 24 -- .../asylum_support_decisions/_form.html.erb | 25 -- app/views/cma_cases/_form.html.erb | 24 -- .../_form.html.erb | 22 -- app/views/drug_safety_updates/_form.html.erb | 20 -- .../_form.html.erb | 23 -- .../_form.html.erb | 22 -- app/views/esi_funds/_form.html.erb | 23 -- .../_form.html.erb | 24 -- app/views/maib_reports/_form.html.erb | 21 -- .../medical_safety_alerts/_form.html.erb | 22 -- app/views/raib_reports/_form.html.erb | 21 -- .../tax_tribunal_decisions/_form.html.erb | 21 -- app/views/utaac_decisions/_form.html.erb | 23 -- .../_form.html.erb | 29 -- .../downloads/162/2-1981 G-BAOZ.pdf | Bin 2414006 -> 0 bytes spec/fixtures/aaib_import/metadata/99.json | 31 --- .../dfid_import/100100/Attached-document.pdf | Bin 504794 -> 0 bytes .../fixtures/dfid_import/100100/metadata.json | 12 - spec/models/aaib_report_spec.rb | 11 - spec/models/asylum_support_decision_spec.rb | 11 - spec/models/cma_case_spec.rb | 11 - .../countryside_stewardship_grant_spec.rb | 11 - .../document_metadata_decorator_spec.rb | 91 ------- spec/models/drug_safety_update_spec.rb | 72 ----- ...mployment_appeal_tribunal_decision_spec.rb | 11 - .../employment_tribunal_decision_spec.rb | 11 - spec/models/esi_fund_spec.rb | 11 - .../international_development_fund_spec.rb | 13 - spec/models/maib_report_spec.rb | 11 - spec/models/tax_tribunal_decision_spec.rb | 11 - spec/models/utaac_decision_spec.rb | 11 - .../asylum_support_decision_validator_spec.rb | 42 --- ...appeal_tribunal_decision_validator_spec.rb | 25 -- ...oyment_tribunal_decision_validator_spec.rb | 22 -- .../tax_tribunal_decision_validator_spec.rb | 21 -- .../utaac_decision_validator_spec.rb | 25 -- 128 files changed, 3 insertions(+), 3727 deletions(-) delete mode 100644 app/controllers/aaib_reports_controller.rb delete mode 100644 app/controllers/abstract_documents_controller.rb delete mode 100644 app/controllers/asylum_support_decisions_controller.rb delete mode 100644 app/controllers/cma_cases_controller.rb delete mode 100644 app/controllers/countryside_stewardship_grants_controller.rb delete mode 100644 app/controllers/drug_safety_updates_controller.rb delete mode 100644 app/controllers/employment_appeal_tribunal_decisions_controller.rb delete mode 100644 app/controllers/employment_tribunal_decisions_controller.rb delete mode 100644 app/controllers/esi_funds_controller.rb delete mode 100644 app/controllers/international_development_funds_controller.rb delete mode 100644 app/controllers/maib_reports_controller.rb delete mode 100644 app/controllers/medical_safety_alerts_controller.rb delete mode 100644 app/controllers/raib_reports_controller.rb delete mode 100644 app/controllers/tax_tribunal_decisions_controller.rb delete mode 100644 app/controllers/utaac_decisions_controller.rb delete mode 100644 app/controllers/vehicle_recalls_and_faults_alerts_controller.rb delete mode 100644 app/importers/cma_import.rb delete mode 100644 app/importers/cma_import/attachment_attacher.rb delete mode 100644 app/importers/cma_import/body_fixer.rb delete mode 100644 app/importers/cma_import/mapper.rb delete mode 100644 app/importers/cma_import/missing_body_generator.rb delete mode 100644 app/importers/document_import.rb delete mode 100644 app/importers/document_import/attachment_helpers.rb delete mode 100644 app/importers/medical_safety_alert_import.rb delete mode 100644 app/importers/medical_safety_alert_import/mapper.rb delete mode 100644 app/models/aaib_report.rb delete mode 100644 app/models/asylum_support_decision.rb delete mode 100644 app/models/cma_case.rb delete mode 100644 app/models/countryside_stewardship_grant.rb delete mode 100644 app/models/drug_safety_update.rb delete mode 100644 app/models/employment_appeal_tribunal_decision.rb delete mode 100644 app/models/employment_tribunal_decision.rb delete mode 100644 app/models/esi_fund.rb delete mode 100644 app/models/international_development_fund.rb delete mode 100644 app/models/maib_report.rb delete mode 100644 app/models/medical_safety_alert.rb delete mode 100644 app/models/raib_report.rb delete mode 100644 app/models/tax_tribunal_decision.rb delete mode 100644 app/models/utaac_decision.rb delete mode 100644 app/models/validators/aaib_report_validator.rb delete mode 100644 app/models/validators/asylum_support_decision_validator.rb delete mode 100644 app/models/validators/cma_case_validator.rb delete mode 100644 app/models/validators/countryside_stewardship_grant_validator.rb delete mode 100644 app/models/validators/drug_safety_update_validator.rb delete mode 100644 app/models/validators/employment_appeal_tribunal_decision_validator.rb delete mode 100644 app/models/validators/employment_tribunal_decision_validator.rb delete mode 100644 app/models/validators/esi_fund_validator.rb delete mode 100644 app/models/validators/international_development_fund_validator.rb delete mode 100644 app/models/validators/maib_report_validator.rb delete mode 100644 app/models/validators/medical_safety_alert_validator.rb delete mode 100644 app/models/validators/raib_report_validator.rb delete mode 100644 app/models/validators/tax_tribunal_decision_validator.rb delete mode 100644 app/models/validators/tribunal_decision_sub_category_relates_to_parent_validator.rb delete mode 100644 app/models/validators/utaac_decision_validator.rb delete mode 100644 app/models/validators/vehicle_recalls_and_faults_alert_validator.rb delete mode 100644 app/models/vehicle_recalls_and_faults_alert.rb delete mode 100644 app/observers/aaib_report_observers_registry.rb delete mode 100644 app/observers/abstract_specialist_document_observers_registry.rb delete mode 100644 app/observers/asylum_support_decision_observers_registry.rb delete mode 100644 app/observers/cma_case_observers_registry.rb delete mode 100644 app/observers/countryside_stewardship_grant_observers_registry.rb delete mode 100644 app/observers/drug_safety_update_observers_registry.rb delete mode 100644 app/observers/employment_appeal_tribunal_decision_observers_registry.rb delete mode 100644 app/observers/employment_tribunal_decision_observers_registry.rb delete mode 100644 app/observers/esi_fund_observers_registry.rb delete mode 100644 app/observers/international_development_fund_observers_registry.rb delete mode 100644 app/observers/maib_report_observers_registry.rb delete mode 100644 app/observers/medical_safety_alert_observers_registry.rb delete mode 100644 app/observers/raib_report_observers_registry.rb delete mode 100644 app/observers/tax_tribunal_decision_observers_registry.rb delete mode 100644 app/observers/utaac_decision_observers_registry.rb delete mode 100644 app/observers/vehicle_recalls_and_faults_alert_observers_registry.rb delete mode 100644 app/view_adapters/aaib_report_view_adapter.rb delete mode 100644 app/view_adapters/asylum_support_decision_view_adapter.rb delete mode 100644 app/view_adapters/cma_case_view_adapter.rb delete mode 100644 app/view_adapters/countryside_stewardship_grant_view_adapter.rb delete mode 100644 app/view_adapters/drug_safety_update_view_adapter.rb delete mode 100644 app/view_adapters/employment_appeal_tribunal_decision_view_adapter.rb delete mode 100644 app/view_adapters/employment_tribunal_decision_view_adapter.rb delete mode 100644 app/view_adapters/esi_fund_view_adapter.rb delete mode 100644 app/view_adapters/international_development_fund_view_adapter.rb delete mode 100644 app/view_adapters/maib_report_view_adapter.rb delete mode 100644 app/view_adapters/medical_safety_alert_view_adapter.rb delete mode 100644 app/view_adapters/raib_report_view_adapter.rb delete mode 100644 app/view_adapters/tax_tribunal_decision_view_adapter.rb delete mode 100644 app/view_adapters/utaac_decision_view_adapter.rb delete mode 100644 app/view_adapters/vehicle_recalls_and_faults_alert_view_adapter.rb delete mode 100644 app/views/aaib_reports/_form.html.erb delete mode 100644 app/views/asylum_support_decisions/_form.html.erb delete mode 100644 app/views/cma_cases/_form.html.erb delete mode 100644 app/views/countryside_stewardship_grants/_form.html.erb delete mode 100644 app/views/drug_safety_updates/_form.html.erb delete mode 100644 app/views/employment_appeal_tribunal_decisions/_form.html.erb delete mode 100644 app/views/employment_tribunal_decisions/_form.html.erb delete mode 100644 app/views/esi_funds/_form.html.erb delete mode 100644 app/views/international_development_funds/_form.html.erb delete mode 100644 app/views/maib_reports/_form.html.erb delete mode 100644 app/views/medical_safety_alerts/_form.html.erb delete mode 100644 app/views/raib_reports/_form.html.erb delete mode 100644 app/views/tax_tribunal_decisions/_form.html.erb delete mode 100644 app/views/utaac_decisions/_form.html.erb delete mode 100644 app/views/vehicle_recalls_and_faults_alerts/_form.html.erb delete mode 100644 spec/fixtures/aaib_import/downloads/162/2-1981 G-BAOZ.pdf delete mode 100644 spec/fixtures/aaib_import/metadata/99.json delete mode 100644 spec/fixtures/dfid_import/100100/Attached-document.pdf delete mode 100644 spec/fixtures/dfid_import/100100/metadata.json delete mode 100644 spec/models/aaib_report_spec.rb delete mode 100644 spec/models/asylum_support_decision_spec.rb delete mode 100644 spec/models/cma_case_spec.rb delete mode 100644 spec/models/countryside_stewardship_grant_spec.rb delete mode 100644 spec/models/document_metadata_decorator_spec.rb delete mode 100644 spec/models/drug_safety_update_spec.rb delete mode 100644 spec/models/employment_appeal_tribunal_decision_spec.rb delete mode 100644 spec/models/employment_tribunal_decision_spec.rb delete mode 100644 spec/models/esi_fund_spec.rb delete mode 100644 spec/models/international_development_fund_spec.rb delete mode 100644 spec/models/maib_report_spec.rb delete mode 100644 spec/models/tax_tribunal_decision_spec.rb delete mode 100644 spec/models/utaac_decision_spec.rb delete mode 100644 spec/models/validators/asylum_support_decision_validator_spec.rb delete mode 100644 spec/models/validators/employment_appeal_tribunal_decision_validator_spec.rb delete mode 100644 spec/models/validators/employment_tribunal_decision_validator_spec.rb delete mode 100644 spec/models/validators/tax_tribunal_decision_validator_spec.rb delete mode 100644 spec/models/validators/utaac_decision_validator_spec.rb diff --git a/app/controllers/aaib_reports_controller.rb b/app/controllers/aaib_reports_controller.rb deleted file mode 100644 index 246eb815d..000000000 --- a/app/controllers/aaib_reports_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class AaibReportsController < AbstractDocumentsController -end diff --git a/app/controllers/abstract_documents_controller.rb b/app/controllers/abstract_documents_controller.rb deleted file mode 100644 index 1b2e1b39b..000000000 --- a/app/controllers/abstract_documents_controller.rb +++ /dev/null @@ -1,208 +0,0 @@ -require "manuals_publisher" - -class AbstractDocumentsController < ApplicationController - before_filter :authorize_user_for_editing - before_filter :authorize_user_for_publishing, only: [:publish] - before_filter :authorize_user_for_withdrawing, only: [:withdraw] - - rescue_from("SpecialistDocumentRepository::NotFoundError") do - redirect_to(index_path, flash: { error: "Document not found" }) - end - - def index - documents = services.list(search_adapter).call.map { |d| view_adapter(d) } - - truncate_and_warn(documents) if searching? && documents.size >= max_per_page - - flash.now[:alert] = "Your search returned 0 results." if searching? && documents.size == 0 - - paginated_docs = Kaminari.paginate_array(documents).page(params[:page]) - - render("specialist_documents/index", locals: { - documents: paginated_docs, - }) - end - - def show - document, other_metadata = services.show(document_id).call - slug_unique = other_metadata.fetch(:slug_unique) - publishable = other_metadata.fetch(:publishable) - - unless slug_unique - flash.now[:error] = "Warning: This document's URL is already used on GOV.UK. You can't publish it until you change the title." - end - - render("specialist_documents/show", locals: { - document: view_adapter(document), - slug_unique: slug_unique, - publishable: publishable, - }) - end - - def new - document = services.new.call - - render("specialist_documents/new", locals: { document: view_adapter(document) }) - end - - def edit - document, _metadata = services.show(document_id).call - - render("specialist_documents/edit", locals: { document: view_adapter(document) }) - end - - def create - document = services.create(document_params).call - - if document.valid? - redirect_to(show_path(document)) - else - render("specialist_documents/new", locals: { document: view_adapter(document) }) - end - end - - def update - document = services.update(document_id, document_params).call - - if document.valid? - redirect_to(show_path(document)) - else - render("specialist_documents/edit", locals: { document: view_adapter(document) }) - end - end - - def publish - document = services.publish(document_id).call - - redirect_to( - show_path(document), - flash: { notice: "Published #{document.title}" } - ) - end - - def withdraw - document = services.withdraw(document_id).call - - redirect_to( - show_path(document), - flash: { notice: "Withdrawn #{document.title}" } - ) - end - - def preview - document = services.preview(params["id"], document_params).call - - document.valid? # Force validation check or errors will be empty - - if document.errors[:body].blank? - render json: { preview_html: document.body } - else - render json: { - preview_html: render_to_string( - "shared/_preview_errors", - layout: false, - locals: { - errors: document.errors[:body] - } - ) - } - end - end - -private - def max_per_page - @max_per_page ||= Kaminari.config.default_per_page - end - - def truncate_and_warn(documents) - flash.now[:alert] = "Your search returned #{documents.size} results. Only the first #{max_per_page} are shown." - documents = documents.first(max_per_page) - end - - def searching? - search_query.present? - end - - def search_adapter - OpenStruct.new(query: search_query) - end - - def search_query - params.fetch(:query, nil) - end - - def document_id - params.fetch("id") - end - - def filtered_params(params_of_document) - # TODO: Make this work like the ManualsController parameter filtering - # We shouldn't make our hashes indifferent. Let's make the keys consistently symbols - filter_blank_multi_selects(params_of_document).with_indifferent_access - end - - # See http://stackoverflow.com/questions/8929230/why-is-the-first-element-always-blank-in-my-rails-multi-select - def filter_blank_multi_selects(values) - values.reduce({}) { |filtered_params, (key, value)| - filtered_value = value.is_a?(Array) ? value.reject(&:blank?) : value - filtered_params.merge(key => filtered_value) - } - end - - def authorize_user_for_editing - unless current_user_can_edit?(document_type) - redirect_to( - manuals_path, - flash: { error: "You don't have permission to do that." }, - ) - end - end - - def authorize_user_for_publishing - unless current_user_can_publish?(document_type) - redirect_to( - show_path(document_id), - flash: { error: "You don't have permission to publish." }, - ) - end - end - - def authorize_user_for_withdrawing - unless current_user_can_withdraw?(document_type) - redirect_to( - show_path(document_id), - flash: { error: "You don't have permission to withdraw." }, - ) - end - end - - def document_params - filtered_params(params.fetch(document_type, {})) - end - - def view_adapter(document) - ManualsPublisher.view_adapter(document) - end - - def services - ManualsPublisher.document_services(document_type) - end - - def index_path - send(resource_name + "_path") - end - - def show_path(document) - send(document_type + "_path", document) - end - - helper_method :document_type - def document_type - resource_name.singularize - end - - helper_method :resource_name - def resource_name - request.path.split("/").fetch(1).underscore - end -end diff --git a/app/controllers/asylum_support_decisions_controller.rb b/app/controllers/asylum_support_decisions_controller.rb deleted file mode 100644 index aeb92182e..000000000 --- a/app/controllers/asylum_support_decisions_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class AsylumSupportDecisionsController < AbstractDocumentsController -end diff --git a/app/controllers/cma_cases_controller.rb b/app/controllers/cma_cases_controller.rb deleted file mode 100644 index 9a04ad7f2..000000000 --- a/app/controllers/cma_cases_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class CmaCasesController < AbstractDocumentsController -end diff --git a/app/controllers/countryside_stewardship_grants_controller.rb b/app/controllers/countryside_stewardship_grants_controller.rb deleted file mode 100644 index 4e15319a1..000000000 --- a/app/controllers/countryside_stewardship_grants_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class CountrysideStewardshipGrantsController < AbstractDocumentsController -end diff --git a/app/controllers/drug_safety_updates_controller.rb b/app/controllers/drug_safety_updates_controller.rb deleted file mode 100644 index e9df08996..000000000 --- a/app/controllers/drug_safety_updates_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class DrugSafetyUpdatesController < AbstractDocumentsController -end diff --git a/app/controllers/employment_appeal_tribunal_decisions_controller.rb b/app/controllers/employment_appeal_tribunal_decisions_controller.rb deleted file mode 100644 index a71b51f1b..000000000 --- a/app/controllers/employment_appeal_tribunal_decisions_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class EmploymentAppealTribunalDecisionsController < AbstractDocumentsController -end diff --git a/app/controllers/employment_tribunal_decisions_controller.rb b/app/controllers/employment_tribunal_decisions_controller.rb deleted file mode 100644 index de72aa0db..000000000 --- a/app/controllers/employment_tribunal_decisions_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class EmploymentTribunalDecisionsController < AbstractDocumentsController -end diff --git a/app/controllers/esi_funds_controller.rb b/app/controllers/esi_funds_controller.rb deleted file mode 100644 index c6ce67269..000000000 --- a/app/controllers/esi_funds_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class EsiFundsController < AbstractDocumentsController -end diff --git a/app/controllers/international_development_funds_controller.rb b/app/controllers/international_development_funds_controller.rb deleted file mode 100644 index bd04a08fa..000000000 --- a/app/controllers/international_development_funds_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class InternationalDevelopmentFundsController < AbstractDocumentsController -end diff --git a/app/controllers/maib_reports_controller.rb b/app/controllers/maib_reports_controller.rb deleted file mode 100644 index 73353f98b..000000000 --- a/app/controllers/maib_reports_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class MaibReportsController < AbstractDocumentsController -end diff --git a/app/controllers/medical_safety_alerts_controller.rb b/app/controllers/medical_safety_alerts_controller.rb deleted file mode 100644 index da6cdae0e..000000000 --- a/app/controllers/medical_safety_alerts_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class MedicalSafetyAlertsController < AbstractDocumentsController -end diff --git a/app/controllers/raib_reports_controller.rb b/app/controllers/raib_reports_controller.rb deleted file mode 100644 index a82c5c7cb..000000000 --- a/app/controllers/raib_reports_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class RaibReportsController < AbstractDocumentsController -end diff --git a/app/controllers/tax_tribunal_decisions_controller.rb b/app/controllers/tax_tribunal_decisions_controller.rb deleted file mode 100644 index c4f5f3063..000000000 --- a/app/controllers/tax_tribunal_decisions_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class TaxTribunalDecisionsController < AbstractDocumentsController -end diff --git a/app/controllers/utaac_decisions_controller.rb b/app/controllers/utaac_decisions_controller.rb deleted file mode 100644 index b5da1c6dd..000000000 --- a/app/controllers/utaac_decisions_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class UtaacDecisionsController < AbstractDocumentsController -end diff --git a/app/controllers/vehicle_recalls_and_faults_alerts_controller.rb b/app/controllers/vehicle_recalls_and_faults_alerts_controller.rb deleted file mode 100644 index 6eb161bfb..000000000 --- a/app/controllers/vehicle_recalls_and_faults_alerts_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class VehicleRecallsAndFaultsAlertsController < AbstractDocumentsController -end diff --git a/app/importers/cma_import.rb b/app/importers/cma_import.rb deleted file mode 100644 index 9b8d4d694..000000000 --- a/app/importers/cma_import.rb +++ /dev/null @@ -1,134 +0,0 @@ -require "builders/specialist_document_builder" -require "cma_import/mapper" -require "cma_import/attachment_attacher" -require "cma_import/missing_body_generator" -require "cma_import/body_fixer" - -class CmaImport - def initialize(data_files_dir) - @data_files_dir = data_files_dir - end - - def call - importer.call - end - -private - attr_reader :data_files_dir - - def importer - DocumentImport::BulkImporter.new( - import_job_builder: import_job_builder, - data_enum: data_enum, - ) - end - - def import_job_builder - ->(data) { - DocumentImport::SingleImport.new( - document_creator: missing_body_generator, - logger: logger, - data: data, - ) - } - end - - def missing_body_generator - CmaImportMissingBodyGenerator.new( - create_document_service: body_fixer, - document_repository: cma_cases_repository, - ) - end - - def body_fixer - CmaImportBodyFixer.new( - create_document_service: attachment_attacher, - ) - end - - def attachment_attacher - CmaImportAttachmentAttacher.new( - create_document_service: attribute_mapper, - document_repository: cma_cases_repository, - assets_directory: data_files_dir, - ) - end - - def attribute_mapper - CmaImportAttributeMapper.new(create_cma_case_service) - end - - def create_cma_case_service - ->(attributes) { - DocumentPresenter.new( - CreateDocumentService.new( - cma_case_builder, - cma_cases_repository, - [], - attributes, - ).call - ) - } - end - - def cma_case_builder - SpecialistDocumentBuilder.new( - "cma_case", - cma_case_factory, - ) - end - - def cma_case_factory - ->(*args) { - NullValidator.new( - CmaCase.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "cma-cases"), - *args, - ), - ) - ) - } - end - - def cma_cases_repository - ManualsPublisherWiring.get(:repository_registry).for_type("cma_case") - end - - def logger - DocumentImport::Logger.new(STDOUT) - end - - def data_enum - data_files.lazy.map(&method(:parse_json_file)) - end - - def data_files - Dir.glob(File.join(data_files_dir, "*.json")).sort.reverse - end - - def parse_json_file(filename) - JSON.parse(File.read(filename)).merge ({ - "import_source" => File.basename(filename), - }) - end - - class DocumentPresenter < SimpleDelegator - def import_notes - [ - "id: #{id}", - "publisher_url: #{publisher_url}", - "slug: #{slug}", - ] - end - - private - def publisher_url - "#{publisher_host}/cma-cases/#{id}" - end - - def publisher_host - Plek.new.find("specialist-publisher") - end - end -end diff --git a/app/importers/cma_import/attachment_attacher.rb b/app/importers/cma_import/attachment_attacher.rb deleted file mode 100644 index b0549c211..000000000 --- a/app/importers/cma_import/attachment_attacher.rb +++ /dev/null @@ -1,139 +0,0 @@ -class CmaImportAttachmentAttacher - include ::DocumentImport::AttachmentHelpers - - def initialize(create_document_service:, document_repository:, assets_directory:) - @create_document_service = create_document_service - @document_repository = document_repository - @assets_directory = assets_directory - end - - def call(data) - document = create_document_service.call(data) - - assets = data.fetch("assets", []).map { |asset_data| - attach_asset_to_document(asset_data, document) - } - - document_repository.store(document) - - Presenter.new( - document, - assets, - ) - end - -private - attr_reader :create_document_service, :document_repository, :assets_directory - - def attach_asset_to_document(asset_data, document) - # Get the link markdown for this asset out of the document body - original_link = find_link_in_document(asset_data, document) - filename = File.basename(asset_data.fetch("filename")) - - asset_title = original_link ? original_link.title : filename - - # Turn the asset_data into attributes we can use to build an attachment - file_attributes = attachable_file_attributes( - assets_directory, - asset_data.merge("title" => asset_title), - ) - - # Make the attachment - attachment = document.add_attachment(file_attributes) - - # Update the link in the document body - if original_link - replace_in_body( - document, - original_link.match, - attachment.snippet, - ) - - valid_asset - else - unlinked_asset(filename) - end - rescue DocumentImport::FileNotFound => e - missing_asset(e) - end - - def find_link_in_document(asset_data, document) - url = asset_data.fetch("original_url") - - match = document.body.match( - %r! - # markdown link - \[([^\]]+)\] # link text - \(#{url}\) - - | - - # html link - - ([^<]+) # link text - - !x - ) - - if match - OpenStruct.new( - match: match.to_s, - title: match.captures.compact.first, - ) - end - end - - def valid_asset - OpenStruct.new( - valid?: true, - ) - end - - def unlinked_asset(filename) - OpenStruct.new( - valid?: false, - error: "#{filename} not linked from body", - ) - end - - def missing_asset(error) - OpenStruct.new( - valid?: false, - error: error.message, - ) - end - - class Presenter < SimpleDelegator - def initialize(document, assets) - @assets = assets - - super(document) - end - - def import_notes - super.concat(messages) - end - - private - attr_reader :assets - - def messages - [ - attachment_count_message, - invalid_attachments_message, - ].compact - end - - def attachment_count_message - "number of attachments: #{assets.count}" - end - - def invalid_attachments_message - errors = assets.reject(&:valid?).map(&:error).join(", ") - - if errors.present? - "attachments with problems: #{errors}" - end - end - end -end diff --git a/app/importers/cma_import/body_fixer.rb b/app/importers/cma_import/body_fixer.rb deleted file mode 100644 index ba0b74882..000000000 --- a/app/importers/cma_import/body_fixer.rb +++ /dev/null @@ -1,137 +0,0 @@ -# A number of the scraped JSON files contain markup_sections which aren't -# included in the body. This object: -# -# - works out which sections are missing -# - adds those sections into the body if it can -# - adds a warning to the import notes if it can't -class CmaImportBodyFixer - def initialize(create_document_service:) - @create_document_service = create_document_service - end - - def call(data) - massager = DataMassager.new(raw_data: data) - - document = create_document_service.call(massager.massaged_data) - - Presenter.new( - document: document, - massager: massager, - ) - end - -private - attr_reader :create_document_service - - class DataMassager - def initialize(raw_data:) - @raw_data = raw_data - end - - def massaged_data - raw_data.merge("body" => massaged_body) - end - - def body_complete? - missing_sections.empty? - end - - def missing_section_keys - missing_sections.keys - end - - def fixed_body? - only_missing_final_report_and_appendices_section? - end - - private - attr_reader :raw_data - - def massaged_body - if fixed_body? - [body, missing_content].join("\n\n") - else - body - end - end - - def body - raw_data.fetch("body", "") - end - - def normalised_body - body.gsub(/\s+/, " ") - end - - def markup_sections - raw_data.fetch("markup_sections", {}) - end - - def missing_content - missing_sections.values.map { |content| - down_level_headings(content) - } - end - - def missing_sections - markup_sections.reject { |_, content| - section_appears_in_body?(content) - } - end - - def section_appears_in_body?(section_content) - normalised_content = section_content.gsub(/\s+/, " ") - reheaded_content = down_level_headings(normalised_content) - - normalised_body.include?(normalised_content) || normalised_body.include?(reheaded_content) - end - - def only_missing_final_report_and_appendices_section? - missing_sections.keys == %w(final-report-and-appendices-glossary) - end - - # Swap all headings with a heading one level lower. This is done by finding - # all lines that start with a `#` and adding another one - def down_level_headings(content) - content.gsub(/^#/, "##") - end - end - - class Presenter < SimpleDelegator - def initialize(document:, massager:) - @massager = massager - - super(document) - end - - def import_notes - super + messages - end - - private - attr_reader :massager - - def messages - [ - incomplete_body_message, - body_fixed_automatically_message, - ].compact - end - - def incomplete_body_message - unless massager.body_complete? - "Body missing some markup sections: #{missing_sections}" - end - end - - def body_fixed_automatically_message - if massager.fixed_body? - "Missing body sections added automatically" - end - end - - def missing_sections - massager.missing_section_keys.join(", ") - end - end -end diff --git a/app/importers/cma_import/mapper.rb b/app/importers/cma_import/mapper.rb deleted file mode 100644 index 5ca2e0cf8..000000000 --- a/app/importers/cma_import/mapper.rb +++ /dev/null @@ -1,74 +0,0 @@ -class CmaImportAttributeMapper - def initialize(create_document_service) - @create_document_service = create_document_service - end - - def call(data) - document = create_document_service.call( - attributes(data) - ) - - Presenter.new( - document, - data, - ) - end - -private - attr_reader :create_document_service - - def attributes(data) - data - .slice(*attribute_keys) - .symbolize_keys - .merge( - body: data.fetch("body", ""), - ) - end - - def attribute_keys - %w( - title - summary - - opened_date - closed_date - case_type - case_state - market_sector - outcome_type - ) - end - - class Presenter < SimpleDelegator - def initialize(document, data) - @data = data - - super(document) - end - - def import_notes - super.concat(messages) - end - - private - attr_reader :data - - def messages - [ - original_url_message, - body_missing_message, - ].compact - end - - def body_missing_message - "`body` field not defined" unless data.has_key?("body") - end - - def original_url_message - url = data.fetch("original_url", "unknown") - - "original_url: #{url}" - end - end -end diff --git a/app/importers/cma_import/missing_body_generator.rb b/app/importers/cma_import/missing_body_generator.rb deleted file mode 100644 index 270e66524..000000000 --- a/app/importers/cma_import/missing_body_generator.rb +++ /dev/null @@ -1,53 +0,0 @@ -class CmaImportMissingBodyGenerator - def initialize(create_document_service:, document_repository:) - @create_document_service = create_document_service - @document_repository = document_repository - end - - def call(data) - document = create_document_service.call(data) - - if needs_body_generating?(document) - generate_body(document) - - document_repository.store(document) - - Presenter.new(document) - else - document - end - end - -private - attr_reader :create_document_service, :document_repository - - def needs_body_generating?(document) - document.body.empty? && document.attachments.size == 1 - end - - def default_body - "Full text of the decision" - end - - def generate_body(document) - attachment = document.attachments.first.snippet - document.update(body: "#{default_body} #{attachment}") - end - - class Presenter < SimpleDelegator - def import_notes - super.concat(messages) - end - - private - def messages - [ - body_missing_message, - ] - end - - def body_missing_message - "missing `body` field replaced with default" - end - end -end diff --git a/app/importers/document_import.rb b/app/importers/document_import.rb deleted file mode 100644 index 0ee85e114..000000000 --- a/app/importers/document_import.rb +++ /dev/null @@ -1,102 +0,0 @@ -module DocumentImport - class HasNewerVersionError < StandardError; end - class FileNotFound < StandardError; end - - class BulkImporter - def initialize(dependencies) - @import_job_builder = dependencies.fetch(:import_job_builder) - @data_enum = dependencies.fetch(:data_enum) - end - - def call - data_enum.lazy - .map { |data| import_job_builder.call(data) } - .each(&:call) - end - - private - attr_reader :import_job_builder, :data_enum - end - - class Logger - def initialize(output) - @output = output - end - - def success(document, data) - import_notes = document.respond_to?(:import_notes) ? document.import_notes : [] - write("SUCCESS", import_notes.join("\t"), data) - end - - def failure(document, data) - write("FAILURE", document.errors.to_h, data) - end - - def error(message, data) - write("ERROR", message, data) - end - - def warn(message, data) - write("WARNING", message, data) - end - - def skipped(message, data) - write("SKIPPED", message, data) - end - - private - def write(status, message, data) - line = [ - status, - message, - format_data(data), - ].join("\t") - - @output.puts(line) - end - - def format_data(data) - data.map { |kv| kv.join(": ") }.join("\t") - end - end - - class SingleImport - def initialize(dependencies) - @document_creator = dependencies.fetch(:document_creator) - @logger = dependencies.fetch(:logger) - @data = dependencies.fetch(:data) - @duration = "unknown" - end - - def call - import_with_benchmark - - if document.valid? - logger.success(document, logger_metadata) - else - logger.failure(document, logger_metadata) - end - rescue HasNewerVersionError => e - logger.skipped(e.message, logger_metadata) - rescue Object => e # ALL THE THINGS - logger.error(e.message, logger_metadata) - end - - private - - attr_reader :document_creator, :logger, :data, :duration - - def logger_metadata - {duration: duration, source: data["import_source"]} - end - - def document - @document ||= document_creator.call(data) - end - - def import_with_benchmark - seconds = Benchmark.realtime { document } - @duration = (seconds * 1000).round.to_s + "ms" - end - end -end diff --git a/app/importers/document_import/attachment_helpers.rb b/app/importers/document_import/attachment_helpers.rb deleted file mode 100644 index 890a30024..000000000 --- a/app/importers/document_import/attachment_helpers.rb +++ /dev/null @@ -1,35 +0,0 @@ -module DocumentImport - module AttachmentHelpers - private - def replace_in_body(document, search, replacement) - if document.body.include?(search) - new_body = document.body.gsub(search, replacement) - document.update(body: new_body) - end - end - - def attachable_file_attributes(base_path, asset_data) - original_filename = asset_data.fetch("original_filename", asset_data["filename"]) - - path_to_file = File.join(base_path, asset_data["filename"]) - - unless File.exist?(path_to_file) - raise FileNotFound.new("file #{path_to_file} does not exist") - end - - file = File.open(path_to_file) - - file.define_singleton_method(:original_filename) { original_filename } - - { - title: clean_title(asset_data.fetch("title")), - filename: original_filename, - file: file, - } - end - - def clean_title(string) - string.gsub("_", "-") - end - end -end diff --git a/app/importers/medical_safety_alert_import.rb b/app/importers/medical_safety_alert_import.rb deleted file mode 100644 index f996b9330..000000000 --- a/app/importers/medical_safety_alert_import.rb +++ /dev/null @@ -1,89 +0,0 @@ -require "medical_safety_alert_import/mapper" - -module MedicalSafetyAlertImport - def self.call(data_file) - DependencyContainer.new(data_file).get_instance.call - end - - class DependencyContainer - def initialize(data_file) - @data_file = data_file - end - - def get_instance - DocumentImport::BulkImporter.new( - import_job_builder: import_job_builder, - data_enum: data_enum - ) - end - - private - - def import_job_builder - ->(data) { - DocumentImport::SingleImport.new( - document_creator: import_mapper, - logger: DocumentImport::Logger.new(STDOUT), - data: data, - ) - } - end - - def data_enum - parse_json_file(@data_file).map do |item| - item.merge("import_source" => File.basename(@data_file)) - end - end - - def parse_json_file(filename) - JSON.parse(File.read(filename)) - end - - def import_mapper - public_updated_at_setter = Proc.new { |document| - document.latest_edition.public_updated_at = Date.parse(document.issued_date) - } - - Mapper.new( - ->(attrs) { - CreateDocumentService.new( - report_builder, - repo, - [], - attrs, - ).call - }, - ->(document_id) { - PublishDocumentService.new( - repo, - [public_updated_at_setter] + MedicalSafetyAlertObserversRegistry.new.republication, - document_id, - true - ).call - }, - repo, - ) - end - - def report_builder - SpecialistDocumentBuilder.new("medical_safety_alert", - ->(*args) { - null_validator( - ManualsPublisherWiring - .get(:validatable_document_factories) - .medical_safety_alert_factory - .call(*args) - ) - } - ) - end - - def repo - ManualsPublisherWiring.get(:repository_registry).for_type("medical_safety_alert") - end - - def null_validator(thing) - NullValidator.new(thing) - end - end -end diff --git a/app/importers/medical_safety_alert_import/mapper.rb b/app/importers/medical_safety_alert_import/mapper.rb deleted file mode 100644 index d732dee80..000000000 --- a/app/importers/medical_safety_alert_import/mapper.rb +++ /dev/null @@ -1,56 +0,0 @@ -module MedicalSafetyAlertImport - class Mapper - def initialize(document_creator, document_publisher, repo) - @document_creator = document_creator - @document_publisher = document_publisher - @repo = repo - end - - def call(raw_data) - document = document_creator.call(desired_attributes(raw_data)) - document = document_publisher.call(document.id) - puts "#{raw_data["slug"]} => #{document.slug}" - document - end - - private - attr_reader :document_creator, :document_publisher, :repo - - def desired_attributes(data) - massage(data) - .slice(*desired_keys) - .symbolize_keys - end - - def massage(data) - alert_type = case data["import_source"] - when /safety-information-from-manufacturers-field-safety-notices/ - "field-safety-notices" - when /medicines-company-led-recalls/ - "company-led-drugs" - end - - title_date = /\d\d? \w+ 2015/.match(data["title"]) - begin - issued_date = Date.parse(title_date[0]) - rescue ArgumentError - issued_date = Date.parse(data["issued_date"]) - end - - data.merge( - "alert_type" => alert_type, - "issued_date" => issued_date.strftime("%Y-%m-%d"), - ) - end - - def desired_keys - %w( - body - title - alert_type - issued_date - summary - ) - end - end -end diff --git a/app/lib/manuals_publisher.rb b/app/lib/manuals_publisher.rb index b6eab69e4..33d4297f9 100644 --- a/app/lib/manuals_publisher.rb +++ b/app/lib/manuals_publisher.rb @@ -24,71 +24,9 @@ def document_types end private - OBSERVER_MAP = { - "aaib_report" => AaibReportObserversRegistry, - "asylum_support_decision" => AsylumSupportDecisionObserversRegistry, - "cma_case" => CmaCaseObserversRegistry, - "countryside_stewardship_grant" => CountrysideStewardshipGrantObserversRegistry, - "drug_safety_update" => DrugSafetyUpdateObserversRegistry, - "employment_appeal_tribunal_decision" => EmploymentAppealTribunalDecisionObserversRegistry, - "employment_tribunal_decision" => EmploymentTribunalDecisionObserversRegistry, - "esi_fund" => EsiFundObserversRegistry, - "international_development_fund" => InternationalDevelopmentFundObserversRegistry, - "maib_report" => MaibReportObserversRegistry, - "medical_safety_alert" => MedicalSafetyAlertObserversRegistry, - "raib_report" => RaibReportObserversRegistry, - "tax_tribunal_decision" => TaxTribunalDecisionObserversRegistry, - "utaac_decision" => UtaacDecisionObserversRegistry, - "vehicle_recalls_and_faults_alert" => VehicleRecallsAndFaultsAlertObserversRegistry, - }.freeze + OBSERVER_MAP = {}.freeze - ORGANISATIONS = { - "aaib_report" => %w( - 38eb5d8f-2d89-480c-8655-e2e7ac23f8f4 - ), # air-accidents-investigation-branch - "asylum_support_decision" => %w( - 7141e343-e7bb-483b-920a-c6a5cf8f758c - ), # first-tier-tribunal-asylum-support - "cma_case" => %w( - 957eb4ec-089b-4f71-ba2a-dc69ac8919ea - ), # competition-and-markets-authority - "countryside_stewardship_grant" => %w( - 8bf5624b-dec2-44fa-9b6c-daed166333a5 - de4e9dc6-cca4-43af-a594-682023b84d6c - d3ce4ba7-bc75-46b4-89d9-38cb3240376d - ), # natural-england, department-for-environment-food-rural-affairs, forestry-commission - "drug_safety_update" => %w( - 240f72bd-9a4d-4f39-94d9-77235cadde8e - ), # medicines-and-healthcare-products-regulatory-agency - "employment_appeal_tribunal_decision" => %w( - caeb418c-d11c-4352-92e9-47b21289f696 - ), # employment-appeal-tribunal - "employment_tribunal_decision" => %w( - 8bb37087-a5a7-4493-8afe-900b36ebc927 - ), # employment-tribunal - "esi_fund" => %w(), # none - "international_development_fund" => %w( - db994552-7644-404d-a770-a2fe659c661f - ), # department-for-international-development - "maib_report" => %w( - 9c66b9a3-1e6a-48e8-974d-2a5635f84679 - ), # marine-accident-investigation-branch - "medical_safety_alert" => %w( - 240f72bd-9a4d-4f39-94d9-77235cadde8e - ), # medicines-and-healthcare-products-regulatory-agency - "raib_report" => %w( - 013872d8-8bbb-4e80-9b79-45c7c5cf9177 - ), # rail-accident-investigation-branch - "tax_tribunal_decision" => %w( - 1a68b2cc-eb52-4528-8989-429f710da00f - ), # upper-tribunal-tax-and-chancery-chamber - "utaac_decision" => %w( - 4c2e325a-2d95-442b-856a-e7fb9f9e3cf8 - ), # upper-tribunal-administrative-appeals-chamber - "vehicle_recalls_and_faults_alert" => %w( - d39237a5-678b-4bb5-a372-eb2cb036933d - ), # driver-and-vehicle-standards-agency - } + ORGANISATIONS = {} def view_adapters ManualsPublisherWiring.get(:view_adapter_registry) diff --git a/app/lib/manuals_publisher_wiring.rb b/app/lib/manuals_publisher_wiring.rb index 94a461153..de25302bc 100644 --- a/app/lib/manuals_publisher_wiring.rb +++ b/app/lib/manuals_publisher_wiring.rb @@ -3,7 +3,6 @@ require "builders/specialist_document_builder" require "dependency_container" require "document_factory_registry" -require "finder_schema" require "footnotes_section_heading_renderer" require "gds_api/email_alert_api" require "gds_api/publishing_api" @@ -70,81 +69,6 @@ define_singleton(:edition_factory) { SpecialistDocumentEdition.method(:new) } - define_factory(:cma_case_builder) { - SpecialistDocumentBuilder.new("cma_case", - get(:validatable_document_factories).cma_case_factory) - } - - define_factory(:aaib_report_builder) { - SpecialistDocumentBuilder.new("aaib_report", - get(:validatable_document_factories).aaib_report_factory) - } - - define_factory(:countryside_stewardship_grant_builder) { - SpecialistDocumentBuilder.new("countryside_stewardship_grant", - get(:validatable_document_factories).countryside_stewardship_grant_factory) - } - - define_factory(:drug_safety_update_builder) { - SpecialistDocumentBuilder.new("drug_safety_update", - get(:validatable_document_factories).drug_safety_update_factory) - } - - define_factory(:esi_fund_builder) { - SpecialistDocumentBuilder.new("esi_fund", - get(:validatable_document_factories).esi_fund_factory) - } - - define_factory(:maib_report_builder) { - SpecialistDocumentBuilder.new("maib_report", - get(:validatable_document_factories).maib_report_factory) - } - - define_factory(:medical_safety_alert_builder) { - SpecialistDocumentBuilder.new("medical_safety_alert", - get(:validatable_document_factories).medical_safety_alert_factory) - } - - define_factory(:international_development_fund_builder) { - SpecialistDocumentBuilder.new("international_development_fund", - get(:validatable_document_factories).international_development_fund_factory) - } - - define_factory(:raib_report_builder) { - SpecialistDocumentBuilder.new("raib_report", - get(:validatable_document_factories).raib_report_factory) - } - - define_factory(:vehicle_recalls_and_faults_alert_builder) { - SpecialistDocumentBuilder.new("vehicle_recalls_and_faults_alert", - get(:validatable_document_factories).vehicle_recalls_and_faults_alert_factory) - } - - define_factory(:asylum_support_decision_builder) { - SpecialistDocumentBuilder.new("asylum_support_decision", - get(:validatable_document_factories).asylum_support_decision_factory) - } - - define_factory(:utaac_decision_builder) { - SpecialistDocumentBuilder.new("utaac_decision", - get(:validatable_document_factories).utaac_decision_factory) - } - - define_factory(:tax_tribunal_decision_builder) { - SpecialistDocumentBuilder.new("tax_tribunal_decision", - get(:validatable_document_factories).tax_tribunal_decision_factory) - } - - define_factory(:employment_appeal_tribunal_decision_builder) { - SpecialistDocumentBuilder.new("employment_appeal_tribunal_decision", - get(:validatable_document_factories).employment_appeal_tribunal_decision_factory) - } - - define_factory(:employment_tribunal_decision_builder) { - SpecialistDocumentBuilder.new("employment_tribunal_decision", - get(:validatable_document_factories).employment_tribunal_decision_factory) - } - define_instance(:markdown_attachment_renderer) { MarkdownAttachmentProcessor.method(:new) } @@ -243,66 +167,6 @@ ) } - define_singleton(:aaib_report_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/aaib-reports.json")) - } - - define_singleton(:cma_case_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/cma-cases.json")) - } - - define_singleton(:countryside_stewardship_grant_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/countryside-stewardship-grants.json")) - } - - define_singleton(:drug_safety_update_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/drug-safety-updates.json")) - } - - define_singleton(:esi_fund_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/esi-funds.json")) - } - - define_singleton(:maib_report_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/maib-reports.json")) - } - - define_singleton(:medical_safety_alert_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/medical-safety-alerts.json")) - } - - define_singleton(:international_development_fund_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/international-development-funds.json")) - } - - define_singleton(:raib_report_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/raib-reports.json")) - } - - define_singleton(:vehicle_recalls_and_faults_alert_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/vehicle-recalls-and-faults-alert.json")) - } - - define_singleton(:asylum_support_decision_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/asylum-support-tribunal-decisions.json")) - } - - define_singleton(:utaac_decision_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/administrative-appeals-tribunal-decisions.json")) - } - - define_singleton(:tax_tribunal_decision_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/tax-tribunal-decisions.json")) - } - - define_singleton(:employment_appeal_tribunal_decision_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/employment-appeal-tribunal-decisions.json")) - } - - define_singleton(:employment_tribunal_decision_finder_schema) { - FinderSchema.new(Rails.root.join("finders/schemas/employment-tribunal-decisions.json")) - } - define_singleton(:organisations_api) { require "gds_api/organisations" GdsApi::Organisations.new(ORGANISATIONS_API_BASE_PATH) diff --git a/app/models/aaib_report.rb b/app/models/aaib_report.rb deleted file mode 100644 index 0ecc5d45d..000000000 --- a/app/models/aaib_report.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "document_metadata_decorator" - -class AaibReport < DocumentMetadataDecorator - set_extra_field_names [ - :date_of_occurrence, - :aircraft_category, - :report_type, - :location, - :aircraft_type, - :registration, - ] -end diff --git a/app/models/asylum_support_decision.rb b/app/models/asylum_support_decision.rb deleted file mode 100644 index 1505bfc74..000000000 --- a/app/models/asylum_support_decision.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "document_metadata_decorator" - -class AsylumSupportDecision < DocumentMetadataDecorator - set_extra_field_names [ - :hidden_indexable_content, - :tribunal_decision_category, - :tribunal_decision_decision_date, - :tribunal_decision_judges, - :tribunal_decision_landmark, - :tribunal_decision_reference_number, - :tribunal_decision_sub_category - ] -end diff --git a/app/models/cma_case.rb b/app/models/cma_case.rb deleted file mode 100644 index e06a4c652..000000000 --- a/app/models/cma_case.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "document_metadata_decorator" - -class CmaCase < DocumentMetadataDecorator - set_extra_field_names [ - :opened_date, - :closed_date, - :case_type, - :case_state, - :market_sector, - :outcome_type, - ] -end diff --git a/app/models/countryside_stewardship_grant.rb b/app/models/countryside_stewardship_grant.rb deleted file mode 100644 index 79c7175d9..000000000 --- a/app/models/countryside_stewardship_grant.rb +++ /dev/null @@ -1,10 +0,0 @@ -require "document_metadata_decorator" - -class CountrysideStewardshipGrant < DocumentMetadataDecorator - set_extra_field_names [ - :grant_type, - :land_use, - :tiers_or_standalone_items, - :funding_amount, - ] -end diff --git a/app/models/document_factory_registry.rb b/app/models/document_factory_registry.rb index 0b2f22ba0..e4e8a4db4 100644 --- a/app/models/document_factory_registry.rb +++ b/app/models/document_factory_registry.rb @@ -1,267 +1,14 @@ -require "validators/aaib_report_validator" require "validators/change_note_validator" -require "validators/cma_case_validator" -require "validators/countryside_stewardship_grant_validator" -require "validators/drug_safety_update_validator" -require "validators/esi_fund_validator" -require "validators/international_development_fund_validator" -require "validators/maib_report_validator" require "validators/manual_document_validator" require "validators/manual_validator" -require "validators/medical_safety_alert_validator" require "validators/null_validator" -require "validators/raib_report_validator" -require "validators/vehicle_recalls_and_faults_alert_validator" -require "validators/asylum_support_decision_validator" -require "validators/utaac_decision_validator" -require "validators/tax_tribunal_decision_validator" -require "validators/employment_appeal_tribunal_decision_validator" -require "validators/employment_tribunal_decision_validator" require "builders/manual_document_builder" require "manual_with_documents" require "slug_generator" require "specialist_document" -require "slug_generator" -require "specialist_document" -require "aaib_report" -require "cma_case" -require "drug_safety_update" -require "medical_safety_alert" -require "international_development_fund" -require "asylum_support_decision" -require "utaac_decision" -require "tax_tribunal_decision" -require "employment_appeal_tribunal_decision" -require "employment_tribunal_decision" - class DocumentFactoryRegistry - def aaib_report_factory - ->(*args) { - ChangeNoteValidator.new( - AaibReportValidator.new( - AaibReport.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "aaib-reports"), - *args, - ), - ) - ) - ) - } - end - - def cma_case_factory - ->(*args) { - ChangeNoteValidator.new( - CmaCaseValidator.new( - CmaCase.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "cma-cases"), - *args, - ), - ) - ) - ) - } - end - - def countryside_stewardship_grant_factory - ->(*args) { - ChangeNoteValidator.new( - CountrysideStewardshipGrantValidator.new( - CountrysideStewardshipGrant.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "countryside-stewardship-grants"), - *args, - ), - ) - ) - ) - } - end - - def drug_safety_update_factory - ->(*args) { - ChangeNoteValidator.new( - DrugSafetyUpdateValidator.new( - DrugSafetyUpdate.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "drug-safety-update"), - *args, - ) - ) - ) - ) - } - end - - def esi_fund_factory - ->(*args) { - ChangeNoteValidator.new( - EsiFundValidator.new( - EsiFund.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "european-structural-investment-funds"), - *args, - ) - ) - ) - ) - } - end - - def maib_report_factory - ->(*args) { - ChangeNoteValidator.new( - MaibReportValidator.new( - MaibReport.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "maib-reports"), - *args, - ), - ) - ) - ) - } - end - - def medical_safety_alert_factory - ->(*args) { - ChangeNoteValidator.new( - MedicalSafetyAlertValidator.new( - MedicalSafetyAlert.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "drug-device-alerts"), - *args, - ) - ) - ) - ) - } - end - - def international_development_fund_factory - ->(*args) { - ChangeNoteValidator.new( - InternationalDevelopmentFundValidator.new( - InternationalDevelopmentFund.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "international-development-funding"), - *args, - ), - ) - ) - ) - } - end - - def raib_report_factory - ->(*args) { - ChangeNoteValidator.new( - RaibReportValidator.new( - RaibReport.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "raib-reports"), - *args, - ), - ) - ) - ) - } - end - - def vehicle_recalls_and_faults_alert_factory - ->(*args) { - ChangeNoteValidator.new( - VehicleRecallsAndFaultsAlertValidator.new( - VehicleRecallsAndFaultsAlert.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "vehicle-recalls-faults"), - *args, - ) - ) - ) - ) - } - end - - def asylum_support_decision_factory - ->(*args) { - ChangeNoteValidator.new( - AsylumSupportDecisionValidator.new( - AsylumSupportDecision.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "asylum-support-tribunal-decisions"), - *args, - ), - ) - ) - ) - } - end - - def utaac_decision_factory - ->(*args) { - ChangeNoteValidator.new( - UtaacDecisionValidator.new( - UtaacDecision.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "administrative-appeals-tribunal-decisions"), - *args, - ), - ) - ) - ) - } - end - - def tax_tribunal_decision_factory - ->(*args) { - ChangeNoteValidator.new( - TaxTribunalDecisionValidator.new( - TaxTribunalDecision.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "tax-and-chancery-tribunal-decisions"), - *args, - ), - ) - ) - ) - } - end - - def employment_appeal_tribunal_decision_factory - ->(*args) { - ChangeNoteValidator.new( - EmploymentAppealTribunalDecisionValidator.new( - EmploymentAppealTribunalDecision.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "employment-appeal-tribunal-decisions"), - *args, - ), - ) - ) - ) - } - end - - def employment_tribunal_decision_factory - ->(*args) { - ChangeNoteValidator.new( - EmploymentTribunalDecisionValidator.new( - EmploymentTribunalDecision.new( - SpecialistDocument.new( - SlugGenerator.new(prefix: "employment-tribunal-decisions"), - *args, - ), - ) - ) - ) - } - end - def manual_with_documents ->(manual, attrs) { ManualValidator.new( diff --git a/app/models/drug_safety_update.rb b/app/models/drug_safety_update.rb deleted file mode 100644 index 50ba5d30d..000000000 --- a/app/models/drug_safety_update.rb +++ /dev/null @@ -1,29 +0,0 @@ -require "document_metadata_decorator" - -class DrugSafetyUpdate < DocumentMetadataDecorator - set_extra_field_names [ - :therapeutic_area, - :first_published_at, - ] - - def publish! - if document.extra_fields[:first_published_at].blank? - document.update( - extra_fields: extra_fields.merge( - first_published_at: Time.now, - ), - ) - end - document.publish! - end - - def withdraw! - document.update( - extra_fields: extra_fields.merge( - first_published_at: nil, - ) - ) - document.withdraw! - end - -end diff --git a/app/models/employment_appeal_tribunal_decision.rb b/app/models/employment_appeal_tribunal_decision.rb deleted file mode 100644 index 8f16c1430..000000000 --- a/app/models/employment_appeal_tribunal_decision.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "document_metadata_decorator" - -class EmploymentAppealTribunalDecision < DocumentMetadataDecorator - set_extra_field_names [ - :hidden_indexable_content, - :tribunal_decision_categories, - :tribunal_decision_decision_date, - :tribunal_decision_landmark, - :tribunal_decision_sub_categories - ] -end diff --git a/app/models/employment_tribunal_decision.rb b/app/models/employment_tribunal_decision.rb deleted file mode 100644 index f21982225..000000000 --- a/app/models/employment_tribunal_decision.rb +++ /dev/null @@ -1,10 +0,0 @@ -require "document_metadata_decorator" - -class EmploymentTribunalDecision < DocumentMetadataDecorator - set_extra_field_names [ - :hidden_indexable_content, - :tribunal_decision_categories, - :tribunal_decision_country, - :tribunal_decision_decision_date - ] -end diff --git a/app/models/esi_fund.rb b/app/models/esi_fund.rb deleted file mode 100644 index 7ac2f121b..000000000 --- a/app/models/esi_fund.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "document_metadata_decorator" - -class EsiFund < DocumentMetadataDecorator - set_extra_field_names [ - :fund_state, - :fund_type, - :location, - :funding_source, - :closing_date, - ] -end diff --git a/app/models/international_development_fund.rb b/app/models/international_development_fund.rb deleted file mode 100644 index dbd949639..000000000 --- a/app/models/international_development_fund.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "document_metadata_decorator" - -class InternationalDevelopmentFund < DocumentMetadataDecorator - set_extra_field_names [ - :fund_state, - :location, - :development_sector, - :eligible_entities, - :value_of_funding, - ] -end diff --git a/app/models/maib_report.rb b/app/models/maib_report.rb deleted file mode 100644 index 375a9c2b6..000000000 --- a/app/models/maib_report.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "document_metadata_decorator" - -class MaibReport < DocumentMetadataDecorator - set_extra_field_names [ - :date_of_occurrence, - :report_type, - :vessel_type, - ] -end diff --git a/app/models/medical_safety_alert.rb b/app/models/medical_safety_alert.rb deleted file mode 100644 index 56968ab06..000000000 --- a/app/models/medical_safety_alert.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "document_metadata_decorator" - -class MedicalSafetyAlert < DocumentMetadataDecorator - set_extra_field_names [ - :alert_type, - :issued_date, - :medical_specialism, - ] -end diff --git a/app/models/raib_report.rb b/app/models/raib_report.rb deleted file mode 100644 index 84e62fb1d..000000000 --- a/app/models/raib_report.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "document_metadata_decorator" - -class RaibReport < DocumentMetadataDecorator - set_extra_field_names [ - :date_of_occurrence, - :report_type, - :railway_type, - ] -end diff --git a/app/models/tax_tribunal_decision.rb b/app/models/tax_tribunal_decision.rb deleted file mode 100644 index 363d453f2..000000000 --- a/app/models/tax_tribunal_decision.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "document_metadata_decorator" - -class TaxTribunalDecision < DocumentMetadataDecorator - set_extra_field_names [ - :hidden_indexable_content, - :tribunal_decision_category, - :tribunal_decision_decision_date, - ] -end diff --git a/app/models/utaac_decision.rb b/app/models/utaac_decision.rb deleted file mode 100644 index b57399fd1..000000000 --- a/app/models/utaac_decision.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "document_metadata_decorator" - -class UtaacDecision < DocumentMetadataDecorator - set_extra_field_names [ - :hidden_indexable_content, - :tribunal_decision_categories, - :tribunal_decision_decision_date, - :tribunal_decision_judges, - :tribunal_decision_sub_categories - ] -end diff --git a/app/models/validators/aaib_report_validator.rb b/app/models/validators/aaib_report_validator.rb deleted file mode 100644 index 92b036858..000000000 --- a/app/models/validators/aaib_report_validator.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class AaibReportValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - - validates :date_of_occurrence, presence: true, date: true, unless: ->(report) { - report.report_type == "safety-study" && report.date_of_occurrence.blank? - } -end diff --git a/app/models/validators/asylum_support_decision_validator.rb b/app/models/validators/asylum_support_decision_validator.rb deleted file mode 100644 index ad5775b1e..000000000 --- a/app/models/validators/asylum_support_decision_validator.rb +++ /dev/null @@ -1,30 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" -require "validators/tribunal_decision_sub_category_relates_to_parent_validator" - -class AsylumSupportDecisionValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - - validates :tribunal_decision_category, presence: true - validates :tribunal_decision_decision_date, presence: true, date: true - validates :tribunal_decision_judges, presence: true - validates :tribunal_decision_landmark, presence: true - validates :tribunal_decision_reference_number, presence: true - validates :tribunal_decision_sub_category, tribunal_decision_sub_category_relates_to_parent: true - - def category_prefix_for(category) - case category - when "section-95-support-for-asylum-seekers" - "section-95" - when "section-4-2-support-for-failed-asylum-seekers" - "section-4-2" - when "section-4-1-support-for-persons-who-are-neither-an-asylum-seeker-nor-a-failed-asylum-seeker" - "section-4-1" - end - end -end diff --git a/app/models/validators/cma_case_validator.rb b/app/models/validators/cma_case_validator.rb deleted file mode 100644 index a06d5ed18..000000000 --- a/app/models/validators/cma_case_validator.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class CmaCaseValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - - validates :opened_date, allow_blank: true, date: true - validates :market_sector, presence: true - validates :case_type, presence: true - validates :case_state, presence: true - validates :closed_date, allow_blank: true, date: true -end diff --git a/app/models/validators/countryside_stewardship_grant_validator.rb b/app/models/validators/countryside_stewardship_grant_validator.rb deleted file mode 100644 index eee1c625a..000000000 --- a/app/models/validators/countryside_stewardship_grant_validator.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class CountrysideStewardshipGrantValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - -end diff --git a/app/models/validators/drug_safety_update_validator.rb b/app/models/validators/drug_safety_update_validator.rb deleted file mode 100644 index d0327575f..000000000 --- a/app/models/validators/drug_safety_update_validator.rb +++ /dev/null @@ -1,10 +0,0 @@ -require "delegate" -require "validators/safe_html_validator" - -class DrugSafetyUpdateValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true -end diff --git a/app/models/validators/employment_appeal_tribunal_decision_validator.rb b/app/models/validators/employment_appeal_tribunal_decision_validator.rb deleted file mode 100644 index 81794ddcd..000000000 --- a/app/models/validators/employment_appeal_tribunal_decision_validator.rb +++ /dev/null @@ -1,16 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class EmploymentAppealTribunalDecisionValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - - validates :tribunal_decision_categories, presence: true - validates :tribunal_decision_decision_date, presence: true, date: true - validates :tribunal_decision_landmark, presence: true - -end diff --git a/app/models/validators/employment_tribunal_decision_validator.rb b/app/models/validators/employment_tribunal_decision_validator.rb deleted file mode 100644 index 7fd5d4dc7..000000000 --- a/app/models/validators/employment_tribunal_decision_validator.rb +++ /dev/null @@ -1,16 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class EmploymentTribunalDecisionValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - - validates :tribunal_decision_categories, presence: true - validates :tribunal_decision_country, presence: true - validates :tribunal_decision_decision_date, presence: true, date: true - -end diff --git a/app/models/validators/esi_fund_validator.rb b/app/models/validators/esi_fund_validator.rb deleted file mode 100644 index 1fdbae302..000000000 --- a/app/models/validators/esi_fund_validator.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class EsiFundValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - - validates :closing_date, allow_blank: true, date: true -end diff --git a/app/models/validators/international_development_fund_validator.rb b/app/models/validators/international_development_fund_validator.rb deleted file mode 100644 index f62d3316b..000000000 --- a/app/models/validators/international_development_fund_validator.rb +++ /dev/null @@ -1,10 +0,0 @@ -require "delegate" -require "validators/safe_html_validator" - -class InternationalDevelopmentFundValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true -end diff --git a/app/models/validators/maib_report_validator.rb b/app/models/validators/maib_report_validator.rb deleted file mode 100644 index 284e33a99..000000000 --- a/app/models/validators/maib_report_validator.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class MaibReportValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - - validates :date_of_occurrence, presence: true, date: true -end diff --git a/app/models/validators/medical_safety_alert_validator.rb b/app/models/validators/medical_safety_alert_validator.rb deleted file mode 100644 index e8b15fe7a..000000000 --- a/app/models/validators/medical_safety_alert_validator.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "delegate" -require "validators/safe_html_validator" - -class MedicalSafetyAlertValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - - validates :alert_type, presence: true - validates :issued_date, presence: true, date: true -end diff --git a/app/models/validators/raib_report_validator.rb b/app/models/validators/raib_report_validator.rb deleted file mode 100644 index 48668b82e..000000000 --- a/app/models/validators/raib_report_validator.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class RaibReportValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - - validates :date_of_occurrence, presence: true, date: true -end diff --git a/app/models/validators/tax_tribunal_decision_validator.rb b/app/models/validators/tax_tribunal_decision_validator.rb deleted file mode 100644 index ca420450e..000000000 --- a/app/models/validators/tax_tribunal_decision_validator.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class TaxTribunalDecisionValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - - validates :tribunal_decision_category, presence: true - validates :tribunal_decision_decision_date, allow_blank: true, date: true - -end diff --git a/app/models/validators/tribunal_decision_sub_category_relates_to_parent_validator.rb b/app/models/validators/tribunal_decision_sub_category_relates_to_parent_validator.rb deleted file mode 100644 index e5fc4d546..000000000 --- a/app/models/validators/tribunal_decision_sub_category_relates_to_parent_validator.rb +++ /dev/null @@ -1,68 +0,0 @@ -class TribunalDecisionSubCategoryRelatesToParentValidator < ActiveModel::EachValidator - - def validate_each(validator, attribute, sub_category) - if sub_category.present? - validate_sub_category(validator, attribute, sub_category) - else - validate_sub_category_present_if_parent_has_sub_categories(validator, attribute) - end - end - - private - - def validate_sub_category_present_if_parent_has_sub_categories(validator, attribute) - if validator.tribunal_decision_category.present? && category_has_sub_categories?(validator) - validator.errors.add attribute, "must not be blank" - end - end - - def category_has_sub_categories?(validator) - prefix = category_prefix(validator) - sub_category_allowed_values(validator).any? do - |sub_category| sub_category[/^#{prefix}/] - end - end - - def sub_category_allowed_values(validator) - sub_category_options = FinderSchema.options_for(:tribunal_decision_sub_category, type(validator)) - sub_category_options.map(&:last) - end - - def validate_sub_category(validator, attribute, sub_category) - if !prefixed_by_parent_category?(sub_category, validator) - message = if category_has_sub_categories?(validator) - "change to be a sub-category of '#{category_label(validator)}' or change category" - else - "remove sub-category as '#{category_label(validator)}' category has no sub-categories" - end - validator.errors.add attribute, message - end - end - - private - - def category_prefix(validator) - category = validator.tribunal_decision_category - prefix = category - if validator.respond_to?(:category_prefix_for) - category_prefix = validator.category_prefix_for(category) - prefix = category_prefix if category_prefix.present? - end - prefix - end - - def prefixed_by_parent_category?(sub_category, validator) - prefix = category_prefix(validator) - sub_category[/^#{prefix}/] - end - - def category_label(validator) - labels = FinderSchema.humanized_facet_name(:tribunal_decision_category, validator, type(validator)) - labels.first - end - - def type(validator) - validator.class.name.underscore.sub("_validator", "") - end - -end diff --git a/app/models/validators/utaac_decision_validator.rb b/app/models/validators/utaac_decision_validator.rb deleted file mode 100644 index d04e204f9..000000000 --- a/app/models/validators/utaac_decision_validator.rb +++ /dev/null @@ -1,16 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class UtaacDecisionValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - - validates :tribunal_decision_categories, presence: true - validates :tribunal_decision_decision_date, presence: true, date: true - validates :tribunal_decision_judges, presence: true - -end diff --git a/app/models/validators/vehicle_recalls_and_faults_alert_validator.rb b/app/models/validators/vehicle_recalls_and_faults_alert_validator.rb deleted file mode 100644 index 1df00b564..000000000 --- a/app/models/validators/vehicle_recalls_and_faults_alert_validator.rb +++ /dev/null @@ -1,24 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class VehicleRecallsAndFaultsAlertValidator < SimpleDelegator - include ActiveModel::Validations - - validates :title, presence: true - validates :summary, presence: true - validates :body, presence: true, safe_html: true - - validates :alert_issue_date, allow_blank: true, date: true - validates :build_start_date, allow_blank: true, date: true - validates :build_end_date, allow_blank: true, date: true - - validate :build_dates - -private - - def build_dates - return unless build_start_date.present? && build_end_date.present? - errors.add(:build_start_date, "must be before build end date") if build_start_date > build_end_date - end -end diff --git a/app/models/vehicle_recalls_and_faults_alert.rb b/app/models/vehicle_recalls_and_faults_alert.rb deleted file mode 100644 index 848145e10..000000000 --- a/app/models/vehicle_recalls_and_faults_alert.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "document_metadata_decorator" - -class VehicleRecallsAndFaultsAlert < DocumentMetadataDecorator - set_extra_field_names [ - :fault_type, - :faulty_item_type, - :alert_issue_date, - :manufacturer, - :faulty_item_model, - :serial_number, - :build_start_date, - :build_end_date, - ] -end diff --git a/app/observers/aaib_report_observers_registry.rb b/app/observers/aaib_report_observers_registry.rb deleted file mode 100644 index 388221d9a..000000000 --- a/app/observers/aaib_report_observers_registry.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "formatters/aaib_report_indexable_formatter" -require "formatters/aaib_report_publication_alert_formatter" -require "markdown_attachment_processor" - -class AaibReportObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def format_document_for_indexing(document) - AaibReportIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - AaibReportPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/abstract_specialist_document_observers_registry.rb b/app/observers/abstract_specialist_document_observers_registry.rb deleted file mode 100644 index 8d735ea61..000000000 --- a/app/observers/abstract_specialist_document_observers_registry.rb +++ /dev/null @@ -1,164 +0,0 @@ -require "url_maker" -require "rummager_indexer" -require "publishing_api_withdrawer" -require "formatters/specialist_document_publishing_api_formatter" - -class AbstractSpecialistDocumentObserversRegistry - def initialize(organisation_content_ids) - @organisation_content_ids = organisation_content_ids - end - - def creation - [ - publishing_api_exporter, - ] - end - - def update - [ - publishing_api_exporter, - ] - end - - def publication - [ - publication_logger, - publishing_api_exporter, - rummager_exporter, - publication_alert_exporter, - ] - end - - def republication - [ - publishing_api_exporter, - rummager_exporter, - ] - end - - def draft_republication - [ - publishing_api_exporter, - ] - end - - def withdrawn_republication - [ - publishing_api_exporter(true), - publishing_api_draft_unpublisher, - ] - end - - def withdrawal - [ - publishing_api_withdrawer, - rummager_withdrawer, - ] - end - -private - attr_reader :organisation_content_ids - - def publishing_api_exporter(force_draft = false) - ->(document, update_type = nil) { - rendered_document = SpecialistDocumentPublishingAPIFormatter.new( - document, - specialist_document_renderer: ManualsPublisherWiring.get(:specialist_document_renderer), - publication_logs: PublicationLog, - links: format_links_for_publishing_api(document), - update_type: update_type - ) - - SpecialistDocumentPublishingAPIExporter.new( - publishing_api, - rendered_document, - force_draft || document.draft? - ).call - } - end - - def publishing_api_withdrawer - ->(document) { - PublishingAPIWithdrawer.new( - publishing_api: publishing_api, - entity: document, - ).call - } - end - - def publishing_api_draft_unpublisher - ->(document) { - publishing_api_v2.unpublish(document.id, type: "gone", allow_draft: true) - } - end - - def rummager_exporter - ->(document, _ = nil) { - RummagerIndexer.new.add( - format_document_for_indexing(document) - ) - } - end - - def rummager_withdrawer - ->(document) { - RummagerIndexer.new.delete( - format_document_for_indexing(document) - ) - } - end - - def format_document_for_indexing(document) - raise NotImplementedError - end - - def format_links_for_publishing_api(document) - { - organisations: organisation_content_ids - } - end - - def email_alert_api - ManualsPublisherWiring.get(:email_alert_api) - end - - def publication_alert_exporter - ->(document) { - if !document.minor_update - EmailAlertExporter.new( - email_alert_api: email_alert_api, - formatter: publication_alert_formatter(document), - ).call - end - } - end - - def publication_alert_formatter - raise NotImplementedError - end - - def publication_logger - ->(document) { - unless document.minor_update? - PublicationLog.create!( - title: document.title, - slug: document.slug, - version_number: document.version_number, - change_note: document.change_note, - ) - end - } - end - - def url_maker - UrlMaker.new - end - - def publishing_api - ManualsPublisherWiring.get(:publishing_api) - end - - def publishing_api_v2 - ManualsPublisherWiring.get(:publishing_api_v2) - end -end diff --git a/app/observers/asylum_support_decision_observers_registry.rb b/app/observers/asylum_support_decision_observers_registry.rb deleted file mode 100644 index cc2275f5f..000000000 --- a/app/observers/asylum_support_decision_observers_registry.rb +++ /dev/null @@ -1,24 +0,0 @@ -require "formatters/asylum_support_decision_indexable_formatter" -require "formatters/asylum_support_decision_publication_alert_formatter" -require "markdown_attachment_processor" - -class AsylumSupportDecisionObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def finder_schema - ManualsPublisherWiring.get(:asylum_support_decision_finder_schema) - end - - def format_document_for_indexing(document) - AsylumSupportDecisionIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - AsylumSupportDecisionPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/cma_case_observers_registry.rb b/app/observers/cma_case_observers_registry.rb deleted file mode 100644 index c112740f4..000000000 --- a/app/observers/cma_case_observers_registry.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "formatters/cma_case_indexable_formatter" -require "formatters/cma_case_publication_alert_formatter" -require "markdown_attachment_processor" - -class CmaCaseObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def format_document_for_indexing(document) - CmaCaseIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - CmaCasePublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/countryside_stewardship_grant_observers_registry.rb b/app/observers/countryside_stewardship_grant_observers_registry.rb deleted file mode 100644 index 615233f9c..000000000 --- a/app/observers/countryside_stewardship_grant_observers_registry.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "formatters/countryside_stewardship_grant_indexable_formatter" -require "formatters/countryside_stewardship_grant_publication_alert_formatter" -require "markdown_attachment_processor" - -class CountrysideStewardshipGrantObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def format_document_for_indexing(document) - CountrysideStewardshipGrantIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - CountrysideStewardshipGrantPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/drug_safety_update_observers_registry.rb b/app/observers/drug_safety_update_observers_registry.rb deleted file mode 100644 index ea14c9c90..000000000 --- a/app/observers/drug_safety_update_observers_registry.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "formatters/drug_safety_update_indexable_formatter" -require "markdown_attachment_processor" - -class DrugSafetyUpdateObserversRegistry < AbstractSpecialistDocumentObserversRegistry - # Overridden to not send publication alerts -- they're sent manually each month to the list - def publication - [ - publication_logger, - publishing_api_exporter, - rummager_exporter, - ] - end - -private - def format_document_for_indexing(document) - DrugSafetyUpdateIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end -end diff --git a/app/observers/employment_appeal_tribunal_decision_observers_registry.rb b/app/observers/employment_appeal_tribunal_decision_observers_registry.rb deleted file mode 100644 index 4ed1b9360..000000000 --- a/app/observers/employment_appeal_tribunal_decision_observers_registry.rb +++ /dev/null @@ -1,24 +0,0 @@ -require "formatters/employment_appeal_tribunal_decision_indexable_formatter" -require "formatters/employment_appeal_tribunal_decision_publication_alert_formatter" -require "markdown_attachment_processor" - -class EmploymentAppealTribunalDecisionObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def finder_schema - ManualsPublisherWiring.get(:employment_appeal_tribunal_decision_finder_schema) - end - - def format_document_for_indexing(document) - EmploymentAppealTribunalDecisionIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - EmploymentAppealTribunalDecisionPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/employment_tribunal_decision_observers_registry.rb b/app/observers/employment_tribunal_decision_observers_registry.rb deleted file mode 100644 index a6bd486ea..000000000 --- a/app/observers/employment_tribunal_decision_observers_registry.rb +++ /dev/null @@ -1,24 +0,0 @@ -require "formatters/employment_tribunal_decision_indexable_formatter" -require "formatters/employment_tribunal_decision_publication_alert_formatter" -require "markdown_attachment_processor" - -class EmploymentTribunalDecisionObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def finder_schema - ManualsPublisherWiring.get(:employment_tribunal_decision_finder_schema) - end - - def format_document_for_indexing(document) - EmploymentTribunalDecisionIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - EmploymentTribunalDecisionPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/esi_fund_observers_registry.rb b/app/observers/esi_fund_observers_registry.rb deleted file mode 100644 index a559fd7f9..000000000 --- a/app/observers/esi_fund_observers_registry.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "formatters/esi_fund_indexable_formatter" -require "formatters/esi_fund_publication_alert_formatter" -require "markdown_attachment_processor" - -class EsiFundObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def format_document_for_indexing(document) - EsiFundIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - EsiFundPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/international_development_fund_observers_registry.rb b/app/observers/international_development_fund_observers_registry.rb deleted file mode 100644 index 9a7f6d2ab..000000000 --- a/app/observers/international_development_fund_observers_registry.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "formatters/international_development_fund_indexable_formatter" -require "formatters/international_development_fund_publication_alert_formatter" -require "markdown_attachment_processor" - -class InternationalDevelopmentFundObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def format_document_for_indexing(document) - InternationalDevelopmentFundIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - InternationalDevelopmentFundPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/maib_report_observers_registry.rb b/app/observers/maib_report_observers_registry.rb deleted file mode 100644 index 74ea66c7d..000000000 --- a/app/observers/maib_report_observers_registry.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "formatters/maib_report_indexable_formatter" -require "formatters/maib_report_publication_alert_formatter" -require "markdown_attachment_processor" - -class MaibReportObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def format_document_for_indexing(document) - MaibReportIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - MaibReportPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/medical_safety_alert_observers_registry.rb b/app/observers/medical_safety_alert_observers_registry.rb deleted file mode 100644 index 2bf5748b0..000000000 --- a/app/observers/medical_safety_alert_observers_registry.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "formatters/medical_safety_alert_indexable_formatter" -require "formatters/medical_safety_alert_publication_alert_formatter" -require "markdown_attachment_processor" - -class MedicalSafetyAlertObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def format_document_for_indexing(document) - MedicalSafetyAlertIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - MedicalSafetyAlertPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/raib_report_observers_registry.rb b/app/observers/raib_report_observers_registry.rb deleted file mode 100644 index d404c7150..000000000 --- a/app/observers/raib_report_observers_registry.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "formatters/raib_report_indexable_formatter" -require "formatters/raib_report_publication_alert_formatter" -require "markdown_attachment_processor" - -class RaibReportObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def format_document_for_indexing(document) - RaibReportIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - RaibReportPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/tax_tribunal_decision_observers_registry.rb b/app/observers/tax_tribunal_decision_observers_registry.rb deleted file mode 100644 index 64c821f0d..000000000 --- a/app/observers/tax_tribunal_decision_observers_registry.rb +++ /dev/null @@ -1,24 +0,0 @@ -require "formatters/tax_tribunal_decision_indexable_formatter" -require "formatters/tax_tribunal_decision_publication_alert_formatter" -require "markdown_attachment_processor" - -class TaxTribunalDecisionObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def finder_schema - ManualsPublisherWiring.get(:tax_tribunal_decision_finder_schema) - end - - def format_document_for_indexing(document) - TaxTribunalDecisionIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - TaxTribunalDecisionPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/utaac_decision_observers_registry.rb b/app/observers/utaac_decision_observers_registry.rb deleted file mode 100644 index ebe277ac3..000000000 --- a/app/observers/utaac_decision_observers_registry.rb +++ /dev/null @@ -1,24 +0,0 @@ -require "formatters/utaac_decision_indexable_formatter" -require "formatters/utaac_decision_publication_alert_formatter" -require "markdown_attachment_processor" - -class UtaacDecisionObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def finder_schema - ManualsPublisherWiring.get(:utaac_decision_finder_schema) - end - - def format_document_for_indexing(document) - UtaacDecisionIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - UtaacDecisionPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/observers/vehicle_recalls_and_faults_alert_observers_registry.rb b/app/observers/vehicle_recalls_and_faults_alert_observers_registry.rb deleted file mode 100644 index 0f9a8528f..000000000 --- a/app/observers/vehicle_recalls_and_faults_alert_observers_registry.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "formatters/vehicle_recalls_and_faults_alert_indexable_formatter" -require "formatters/vehicle_recalls_and_faults_alert_publication_alert_formatter" -require "markdown_attachment_processor" - -class VehicleRecallsAndFaultsAlertObserversRegistry < AbstractSpecialistDocumentObserversRegistry - -private - def format_document_for_indexing(document) - VehicleRecallsAndFaultsAlertIndexableFormatter.new( - MarkdownAttachmentProcessor.new(document) - ) - end - - def publication_alert_formatter(document) - VehicleRecallsAndFaultsAlertPublicationAlertFormatter.new( - url_maker: url_maker, - document: document, - ) - end -end diff --git a/app/view_adapters/aaib_report_view_adapter.rb b/app/view_adapters/aaib_report_view_adapter.rb deleted file mode 100644 index e49a20359..000000000 --- a/app/view_adapters/aaib_report_view_adapter.rb +++ /dev/null @@ -1,29 +0,0 @@ -class AaibReportViewAdapter < DocumentViewAdapter - attributes = [ - :title, - :summary, - :body, - :date_of_occurrence, - :aircraft_category, - :report_type, - :aircraft_type, - :registration, - :location, - ] - - def self.model_name - ActiveModel::Name.new(self, nil, "AaibReport") - end - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - -private - - def finder_schema - ManualsPublisherWiring.get(:aaib_report_finder_schema) - end -end diff --git a/app/view_adapters/asylum_support_decision_view_adapter.rb b/app/view_adapters/asylum_support_decision_view_adapter.rb deleted file mode 100644 index ae70c7254..000000000 --- a/app/view_adapters/asylum_support_decision_view_adapter.rb +++ /dev/null @@ -1,31 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class AsylumSupportDecisionViewAdapter < DocumentViewAdapter - attributes = [ - :hidden_indexable_content, - :tribunal_decision_category, - :tribunal_decision_decision_date, - :tribunal_decision_judges, - :tribunal_decision_landmark, - :tribunal_decision_reference_number, - :tribunal_decision_sub_category, - ] - - def self.model_name - ActiveModel::Name.new(self, nil, "AsylumSupportDecision") - end - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - -private - - def finder_schema - ManualsPublisherWiring.get(:asylum_support_decision_finder_schema) - end -end diff --git a/app/view_adapters/cma_case_view_adapter.rb b/app/view_adapters/cma_case_view_adapter.rb deleted file mode 100644 index 0689d42e1..000000000 --- a/app/view_adapters/cma_case_view_adapter.rb +++ /dev/null @@ -1,30 +0,0 @@ -class CmaCaseViewAdapter < DocumentViewAdapter - attributes = [ - :title, - :summary, - :body, - :opened_date, - :closed_date, - :market_sector, - :case_type, - :case_state, - :outcome_type, - ] - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - - def self.model_name - ActiveModel::Name.new(self, nil, "CmaCase") - end - -private - - def finder_schema - ManualsPublisherWiring.get(:cma_case_finder_schema) - end - -end diff --git a/app/view_adapters/countryside_stewardship_grant_view_adapter.rb b/app/view_adapters/countryside_stewardship_grant_view_adapter.rb deleted file mode 100644 index 76f8663d9..000000000 --- a/app/view_adapters/countryside_stewardship_grant_view_adapter.rb +++ /dev/null @@ -1,28 +0,0 @@ -class CountrysideStewardshipGrantViewAdapter < DocumentViewAdapter - attributes = [ - :title, - :summary, - :body, - :grant_type, - :land_use, - :tiers_or_standalone_items, - :funding_amount, - ] - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - - def self.model_name - ActiveModel::Name.new(self, nil, "CountrysideStewardshipGrant") - end - - private - - def finder_schema - ManualsPublisherWiring.get(:countryside_stewardship_grant_finder_schema) - end - -end diff --git a/app/view_adapters/drug_safety_update_view_adapter.rb b/app/view_adapters/drug_safety_update_view_adapter.rb deleted file mode 100644 index 287dbef9c..000000000 --- a/app/view_adapters/drug_safety_update_view_adapter.rb +++ /dev/null @@ -1,34 +0,0 @@ -class DrugSafetyUpdateViewAdapter < DocumentViewAdapter - attributes = [ - :title, - :summary, - :body, - :therapeutic_area, - ] - - def self.model_name - ActiveModel::Name.new(self, nil, "DrugSafetyUpdate") - end - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - - def humanized_attributes - super.tap do |human_output| - human_output.merge!(first_published_at: human_first_published_at) if first_published_at.present? - end - end - -private - - def human_first_published_at - first_published_at.strftime("%-d %B %Y, %H:%M") - end - - def finder_schema - ManualsPublisherWiring.get(:drug_safety_update_finder_schema) - end -end diff --git a/app/view_adapters/employment_appeal_tribunal_decision_view_adapter.rb b/app/view_adapters/employment_appeal_tribunal_decision_view_adapter.rb deleted file mode 100644 index 51f6d17ad..000000000 --- a/app/view_adapters/employment_appeal_tribunal_decision_view_adapter.rb +++ /dev/null @@ -1,29 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class EmploymentAppealTribunalDecisionViewAdapter < DocumentViewAdapter - attributes = [ - :hidden_indexable_content, - :tribunal_decision_categories, - :tribunal_decision_decision_date, - :tribunal_decision_landmark, - :tribunal_decision_sub_categories, - ] - - def self.model_name - ActiveModel::Name.new(self, nil, "EmploymentAppealTribunalDecision") - end - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - -private - - def finder_schema - ManualsPublisherWiring.get(:employment_appeal_tribunal_decision_finder_schema) - end -end diff --git a/app/view_adapters/employment_tribunal_decision_view_adapter.rb b/app/view_adapters/employment_tribunal_decision_view_adapter.rb deleted file mode 100644 index af4b7cf4c..000000000 --- a/app/view_adapters/employment_tribunal_decision_view_adapter.rb +++ /dev/null @@ -1,28 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class EmploymentTribunalDecisionViewAdapter < DocumentViewAdapter - attributes = [ - :hidden_indexable_content, - :tribunal_decision_categories, - :tribunal_decision_country, - :tribunal_decision_decision_date, - ] - - def self.model_name - ActiveModel::Name.new(self, nil, "EmploymentTribunalDecision") - end - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - -private - - def finder_schema - ManualsPublisherWiring.get(:employment_tribunal_decision_finder_schema) - end -end diff --git a/app/view_adapters/esi_fund_view_adapter.rb b/app/view_adapters/esi_fund_view_adapter.rb deleted file mode 100644 index 4ba902600..000000000 --- a/app/view_adapters/esi_fund_view_adapter.rb +++ /dev/null @@ -1,29 +0,0 @@ -class EsiFundViewAdapter < DocumentViewAdapter - attributes = [ - :title, - :summary, - :body, - :fund_state, - :fund_type, - :location, - :funding_source, - :closing_date, - ] - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - - def self.model_name - ActiveModel::Name.new(self, nil, "EsiFund") - end - -private - - def finder_schema - ManualsPublisherWiring.get(:esi_fund_finder_schema) - end - -end diff --git a/app/view_adapters/international_development_fund_view_adapter.rb b/app/view_adapters/international_development_fund_view_adapter.rb deleted file mode 100644 index 9a2ea3a2f..000000000 --- a/app/view_adapters/international_development_fund_view_adapter.rb +++ /dev/null @@ -1,26 +0,0 @@ -class InternationalDevelopmentFundViewAdapter < DocumentViewAdapter - attributes = [ - :fund_state, - :location, - :development_sector, - :eligible_entities, - :value_of_funding, - ] - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - - def self.model_name - ActiveModel::Name.new(self, nil, "InternationalDevelopmentFund") - end - -private - - def finder_schema - ManualsPublisherWiring.get(:international_development_fund_finder_schema) - end - -end diff --git a/app/view_adapters/maib_report_view_adapter.rb b/app/view_adapters/maib_report_view_adapter.rb deleted file mode 100644 index c59455cea..000000000 --- a/app/view_adapters/maib_report_view_adapter.rb +++ /dev/null @@ -1,26 +0,0 @@ -class MaibReportViewAdapter < DocumentViewAdapter - attributes = [ - :title, - :summary, - :body, - :date_of_occurrence, - :report_type, - :vessel_type, - ] - - def self.model_name - ActiveModel::Name.new(self, nil, "MaibReport") - end - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - -private - - def finder_schema - ManualsPublisherWiring.get(:maib_report_finder_schema) - end -end diff --git a/app/view_adapters/medical_safety_alert_view_adapter.rb b/app/view_adapters/medical_safety_alert_view_adapter.rb deleted file mode 100644 index 6aae87fb0..000000000 --- a/app/view_adapters/medical_safety_alert_view_adapter.rb +++ /dev/null @@ -1,24 +0,0 @@ -class MedicalSafetyAlertViewAdapter < DocumentViewAdapter - attributes = [ - :alert_type, - :medical_specialism, - :issued_date, - ] - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - - def self.model_name - ActiveModel::Name.new(self, nil, "MedicalSafetyAlert") - end - -private - - def finder_schema - ManualsPublisherWiring.get(:medical_safety_alert_finder_schema) - end - -end diff --git a/app/view_adapters/raib_report_view_adapter.rb b/app/view_adapters/raib_report_view_adapter.rb deleted file mode 100644 index 1448a4c45..000000000 --- a/app/view_adapters/raib_report_view_adapter.rb +++ /dev/null @@ -1,26 +0,0 @@ -class RaibReportViewAdapter < DocumentViewAdapter - attributes = [ - :title, - :summary, - :body, - :date_of_occurrence, - :report_type, - :railway_type, - ] - - def self.model_name - ActiveModel::Name.new(self, nil, "RaibReport") - end - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - -private - - def finder_schema - ManualsPublisherWiring.get(:raib_report_finder_schema) - end -end diff --git a/app/view_adapters/tax_tribunal_decision_view_adapter.rb b/app/view_adapters/tax_tribunal_decision_view_adapter.rb deleted file mode 100644 index 9ae49a045..000000000 --- a/app/view_adapters/tax_tribunal_decision_view_adapter.rb +++ /dev/null @@ -1,27 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class TaxTribunalDecisionViewAdapter < DocumentViewAdapter - attributes = [ - :hidden_indexable_content, - :tribunal_decision_category, - :tribunal_decision_decision_date, - ] - - def self.model_name - ActiveModel::Name.new(self, nil, "TaxTribunalDecision") - end - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - -private - - def finder_schema - ManualsPublisherWiring.get(:tax_tribunal_decision_finder_schema) - end -end diff --git a/app/view_adapters/utaac_decision_view_adapter.rb b/app/view_adapters/utaac_decision_view_adapter.rb deleted file mode 100644 index 549243527..000000000 --- a/app/view_adapters/utaac_decision_view_adapter.rb +++ /dev/null @@ -1,29 +0,0 @@ -require "delegate" -require "validators/date_validator" -require "validators/safe_html_validator" - -class UtaacDecisionViewAdapter < DocumentViewAdapter - attributes = [ - :hidden_indexable_content, - :tribunal_decision_categories, - :tribunal_decision_decision_date, - :tribunal_decision_judges, - :tribunal_decision_sub_categories, - ] - - def self.model_name - ActiveModel::Name.new(self, nil, "UtaacDecision") - end - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - -private - - def finder_schema - ManualsPublisherWiring.get(:utaac_decision_finder_schema) - end -end diff --git a/app/view_adapters/vehicle_recalls_and_faults_alert_view_adapter.rb b/app/view_adapters/vehicle_recalls_and_faults_alert_view_adapter.rb deleted file mode 100644 index 440a9159b..000000000 --- a/app/view_adapters/vehicle_recalls_and_faults_alert_view_adapter.rb +++ /dev/null @@ -1,31 +0,0 @@ -class VehicleRecallsAndFaultsAlertViewAdapter < DocumentViewAdapter - attributes = [ - :title, - :summary, - :body, - :alert_issue_date, - :fault_type, - :faulty_item_type, - :manufacturer, - :faulty_item_model, - :serial_number, - :build_start_date, - :build_end_date, - ] - - attributes.each do |attribute_name| - define_method(attribute_name) do - delegate_if_document_exists(attribute_name) - end - end - - def self.model_name - ActiveModel::Name.new(self, nil, "VehicleRecallsAndFaultsAlert") - end - -private - - def finder_schema - ManualsPublisherWiring.get(:vehicle_recalls_and_faults_alert_finder_schema) - end -end diff --git a/app/view_adapters/view_adapter_registry.rb b/app/view_adapters/view_adapter_registry.rb index 336bd3b76..f3ce1b1e9 100644 --- a/app/view_adapters/view_adapter_registry.rb +++ b/app/view_adapters/view_adapter_registry.rb @@ -4,23 +4,7 @@ def for_document(document) end private - VIEW_ADAPTER_MAP = { - "aaib_report" => AaibReportViewAdapter, - "asylum_support_decision" => AsylumSupportDecisionViewAdapter, - "cma_case" => CmaCaseViewAdapter, - "countryside_stewardship_grant" => CountrysideStewardshipGrantViewAdapter, - "drug_safety_update" => DrugSafetyUpdateViewAdapter, - "employment_appeal_tribunal_decision" => EmploymentAppealTribunalDecisionViewAdapter, - "employment_tribunal_decision" => EmploymentTribunalDecisionViewAdapter, - "esi_fund" => EsiFundViewAdapter, - "international_development_fund" => InternationalDevelopmentFundViewAdapter, - "maib_report" => MaibReportViewAdapter, - "medical_safety_alert" => MedicalSafetyAlertViewAdapter, - "raib_report" => RaibReportViewAdapter, - "tax_tribunal_decision" => TaxTribunalDecisionViewAdapter, - "utaac_decision" => UtaacDecisionViewAdapter, - "vehicle_recalls_and_faults_alert" => VehicleRecallsAndFaultsAlertViewAdapter, - }.freeze + VIEW_ADAPTER_MAP = {}.freeze def get(type) VIEW_ADAPTER_MAP.fetch(type) diff --git a/app/views/aaib_reports/_form.html.erb b/app/views/aaib_reports/_form.html.erb deleted file mode 100644 index 6f88928d7..000000000 --- a/app/views/aaib_reports/_form.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.text_field :date_of_occurrence, placeholder: '2012-04-23', class: 'form-control' %> - <%= f.text_field :aircraft_type, class: 'form-control' %> - <%= f.text_field :registration, class: 'form-control' %> - <%= f.text_field :location, class: 'form-control' %> - <%= f.select :aircraft_category, f.object.facet_options(:aircraft_category), {}, { class: 'select2', multiple: true, data: {placeholder: 'Select an Aircraft category'} } %> - <%= f.select :report_type, f.object.facet_options(:report_type), {}, { class: 'form-control' } %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", locals: { document: document, form_namespace: "aaib_report" } %> diff --git a/app/views/asylum_support_decisions/_form.html.erb b/app/views/asylum_support_decisions/_form.html.erb deleted file mode 100644 index fc398fe85..000000000 --- a/app/views/asylum_support_decisions/_form.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.select :tribunal_decision_category, f.object.facet_options(:tribunal_decision_category), { label: "Category", prompt: "Select category" }, { class: 'form-control' } %> - <%= f.select :tribunal_decision_sub_category, f.object.facet_options(:tribunal_decision_sub_category), { label: "Sub-category", prompt: "Select sub-category" }, { class: "form-control" } %> - <%= f.select :tribunal_decision_judges, f.object.facet_options(:tribunal_decision_judges), { label: "Judges" }, { class: 'select2', multiple: true, data: { placeholder: 'Select judges' } } %> - <%= f.select :tribunal_decision_landmark, f.object.facet_options(:tribunal_decision_landmark), { label: "Landmark" }, { class: 'form-control' } %> - <%= f.text_field :tribunal_decision_reference_number, label: "Reference number", placeholder: '', class: 'form-control' %> - <%= f.text_field :tribunal_decision_decision_date, label: "Decision date", placeholder: '2015-07-30', class: 'form-control' %> - <%= f.text_area :hidden_indexable_content, class: 'form-control' %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", locals: { document: document, form_namespace: "asylum_support_decision" } %> diff --git a/app/views/cma_cases/_form.html.erb b/app/views/cma_cases/_form.html.erb deleted file mode 100644 index deb1ebbb6..000000000 --- a/app/views/cma_cases/_form.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.text_field :opened_date, placeholder: '2012-04-23', class: 'form-control' %> - <%= f.text_field :closed_date, placeholder: '2013-10-19', class: 'form-control' %> - <%= f.select :case_type, f.object.facet_options(:case_type), {}, { class: 'form-control' } %> - <%= f.select :case_state, f.object.facet_options(:case_state), {}, { class: 'form-control' } %> - <%= f.select :market_sector, f.object.facet_options(:market_sector), {}, { class: 'select2', multiple: true, data: { placeholder: 'Select a market sector' } } %> - <%= f.select :outcome_type, f.object.facet_options(:outcome_type), { include_blank: true }, { class: 'form-control' } %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", locals: { document: document, form_namespace: "cma_case" } %> diff --git a/app/views/countryside_stewardship_grants/_form.html.erb b/app/views/countryside_stewardship_grants/_form.html.erb deleted file mode 100644 index 9d524407a..000000000 --- a/app/views/countryside_stewardship_grants/_form.html.erb +++ /dev/null @@ -1,22 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.select :grant_type, f.object.facet_options(:grant_type), {}, { class: 'form-control' } %> - <%= f.select :land_use, f.object.facet_options(:land_use), {}, { class: 'select2', multiple: true, data: {placeholder: 'Select a location'} } %> - <%= f.select :tiers_or_standalone_items, f.object.facet_options(:tiers_or_standalone_items), {}, { class: 'select2', multiple: true, data: {placeholder: 'Select a Tier or Standalone Item'} } %> - <%= f.select :funding_amount, f.object.facet_options(:funding_amount), { label: 'Funding (per unit per year)'}, { class: 'select2', multiple: true, data: {placeholder: 'Select a level of funding (per unit per year) '} } %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", locals: { document: document, form_namespace: "countryside_stewardship_grant" } %> diff --git a/app/views/drug_safety_updates/_form.html.erb b/app/views/drug_safety_updates/_form.html.erb deleted file mode 100644 index f87a57213..000000000 --- a/app/views/drug_safety_updates/_form.html.erb +++ /dev/null @@ -1,20 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.select :therapeutic_area, f.object.facet_options(:therapeutic_area), {}, { class: 'select2', multiple: true, data: {placeholder: 'Select a Therapeutic area'} } %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", - locals: { document: document, form_namespace: "drug_safety_update" } %> diff --git a/app/views/employment_appeal_tribunal_decisions/_form.html.erb b/app/views/employment_appeal_tribunal_decisions/_form.html.erb deleted file mode 100644 index 7b8adafde..000000000 --- a/app/views/employment_appeal_tribunal_decisions/_form.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.select :tribunal_decision_categories, f.object.facet_options(:tribunal_decision_categories), { label: "Category" }, { class: 'select2', multiple: true, data: { placeholder: 'Select category' } } %> - <%= f.select :tribunal_decision_sub_categories, f.object.facet_options(:tribunal_decision_sub_categories), { label: "Sub-category" }, { class: 'select2', multiple: true, data: { placeholder: 'Select sub-category' } } %> - <%= f.select :tribunal_decision_landmark, f.object.facet_options(:tribunal_decision_landmark), { label: "Landmark" }, { class: 'form-control' } %> - <%= f.text_field :tribunal_decision_decision_date, label: "Decision date", placeholder: '2015-07-30', class: 'form-control' %> - <%= f.text_area :hidden_indexable_content, class: 'form-control' %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", locals: { document: document, form_namespace: "employment_appeal_tribunal_decision" } %> diff --git a/app/views/employment_tribunal_decisions/_form.html.erb b/app/views/employment_tribunal_decisions/_form.html.erb deleted file mode 100644 index b24845d8e..000000000 --- a/app/views/employment_tribunal_decisions/_form.html.erb +++ /dev/null @@ -1,22 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.select :tribunal_decision_country, f.object.facet_options(:tribunal_decision_country), { label: "Country" }, { class: 'form-control' } %> - <%= f.select :tribunal_decision_categories, f.object.facet_options(:tribunal_decision_categories), { label: "Jurisdiction code" }, { class: 'select2', multiple: true, data: { placeholder: '' } } %> - <%= f.text_field :tribunal_decision_decision_date, label: "Decision date", placeholder: '2015-07-30', class: 'form-control' %> - <%= f.text_area :hidden_indexable_content, class: 'form-control' %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", locals: { document: document, form_namespace: "employment_tribunal_decision" } %> diff --git a/app/views/esi_funds/_form.html.erb b/app/views/esi_funds/_form.html.erb deleted file mode 100644 index 53a0e9966..000000000 --- a/app/views/esi_funds/_form.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.select :fund_state, f.object.facet_options(:fund_state), {}, { class: 'form-control' } %> - <%= f.select :fund_type, f.object.facet_options(:fund_type), {}, { class: 'select2', multiple: true, data: {placeholder: 'Select a fund type'} } %> - <%= f.select :location, f.object.facet_options(:location), {}, { class: 'select2', multiple: true, data: {placeholder: 'Select a location'} } %> - <%= f.select :funding_source, f.object.facet_options(:funding_source), {}, { class: 'select2', multiple: true, data: {placeholder: 'Select a source'} } %> - <%= f.text_field :closing_date, placeholder: '2018-10-19', class: 'form-control' %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", locals: { document: document, form_namespace: "esi_fund" } %> diff --git a/app/views/international_development_funds/_form.html.erb b/app/views/international_development_funds/_form.html.erb deleted file mode 100644 index 7540b1317..000000000 --- a/app/views/international_development_funds/_form.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.select :fund_state, f.object.facet_options(:fund_state), {}, { class: 'form-control' } %> - <%= f.select :location, f.object.facet_options(:location), {}, { class: 'select2', multiple: true, data: {placeholder: 'Select a location'} } %> - <%= f.select :development_sector, f.object.facet_options(:development_sector), { label: 'Sector'}, { class: 'select2', multiple: true, data: {placeholder: 'Select a Sector'} } %> - <%= f.select :eligible_entities, f.object.facet_options(:eligible_entities), { label: 'Eligible Organisations'}, { class: 'select2', multiple: true, data: {placeholder: 'Select an eligible organisation'} } %> - <%= f.select :value_of_funding, f.object.facet_options(:value_of_funding), {}, { class: 'select2', multiple: true, data: {placeholder: 'Select a Value'} } %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", - locals: { document: document, form_namespace: "international_development_fund" } %> diff --git a/app/views/maib_reports/_form.html.erb b/app/views/maib_reports/_form.html.erb deleted file mode 100644 index 0e08d23b3..000000000 --- a/app/views/maib_reports/_form.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.text_field :date_of_occurrence, placeholder: '2012-04-23', class: 'form-control' %> - <%= f.select :vessel_type, f.object.facet_options(:vessel_type), {}, { class: 'select2', multiple: true, data: {placeholder: 'Select a Vessel type'} } %> - <%= f.select :report_type, f.object.facet_options(:report_type), {}, { class: 'form-control' } %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", locals: { document: document, form_namespace: "maib_report" } %> diff --git a/app/views/medical_safety_alerts/_form.html.erb b/app/views/medical_safety_alerts/_form.html.erb deleted file mode 100644 index d0f9324c5..000000000 --- a/app/views/medical_safety_alerts/_form.html.erb +++ /dev/null @@ -1,22 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.select :alert_type, f.object.facet_options(:alert_type), {include_blank: true}, { class: 'form-control' } %> - <%= f.select :medical_specialism, f.object.facet_options(:medical_specialism), {}, { class: 'select2', multiple: true, data: {placeholder: 'Select a Medical specialism'} } %> - <%= f.text_field :issued_date, placeholder: '2012-04-23', class: 'form-control' %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", - locals: { document: document, form_namespace: "medical_safety_alert" } %> diff --git a/app/views/raib_reports/_form.html.erb b/app/views/raib_reports/_form.html.erb deleted file mode 100644 index 4d6bded8c..000000000 --- a/app/views/raib_reports/_form.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.text_field :date_of_occurrence, placeholder: '2012-04-23', class: 'form-control' %> - <%= f.select :railway_type, f.object.facet_options(:railway_type), {}, { class: 'select2', multiple: true, data: {placeholder: 'Select a Railway type'} } %> - <%= f.select :report_type, f.object.facet_options(:report_type), {}, { class: 'form-control' } %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", locals: { document: document, form_namespace: "raib_report" } %> diff --git a/app/views/tax_tribunal_decisions/_form.html.erb b/app/views/tax_tribunal_decisions/_form.html.erb deleted file mode 100644 index 0faa3f3b4..000000000 --- a/app/views/tax_tribunal_decisions/_form.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.select :tribunal_decision_category, f.object.facet_options(:tribunal_decision_category), { label: "Category" }, { class: 'form-control' } %> - <%= f.text_field :tribunal_decision_decision_date, label: "Release date", placeholder: '2015-07-30', class: 'form-control' %> - <%= f.text_area :hidden_indexable_content, class: 'form-control' %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", locals: { document: document, form_namespace: "tax_tribunal_decision" } %> diff --git a/app/views/utaac_decisions/_form.html.erb b/app/views/utaac_decisions/_form.html.erb deleted file mode 100644 index 5b1459cf8..000000000 --- a/app/views/utaac_decisions/_form.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - <%= f.select :tribunal_decision_categories, f.object.facet_options(:tribunal_decision_categories), { label: "Categories" }, { class: 'select2', multiple: true, data: { placeholder: 'Select categories' } } %> - <%= f.select :tribunal_decision_sub_categories, f.object.facet_options(:tribunal_decision_sub_categories), { label: "Sub-categories" }, { class: 'select2', multiple: true, data: { placeholder: 'Select sub-categories' } } %> - <%= f.select :tribunal_decision_judges, f.object.facet_options(:tribunal_decision_judges), { label: "Judges" }, { class: 'select2', multiple: true, data: { placeholder: 'Select judges' } } %> - <%= f.text_field :tribunal_decision_decision_date, label: "Decision date", placeholder: '2015-08-30', class: 'form-control' %> - <%= f.text_area :hidden_indexable_content, class: 'form-control' %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", locals: { document: document, form_namespace: "utaac_decision" } %> diff --git a/app/views/vehicle_recalls_and_faults_alerts/_form.html.erb b/app/views/vehicle_recalls_and_faults_alerts/_form.html.erb deleted file mode 100644 index 5ea7e92cb..000000000 --- a/app/views/vehicle_recalls_and_faults_alerts/_form.html.erb +++ /dev/null @@ -1,29 +0,0 @@ -
- <%= form_for document do |f| %> - <%= render partial: "shared/form_errors", locals: { object: document } %> - <%= render partial: "shared/form_fields", locals: { f: f } %> - <%= render partial: "shared/form_preview" %> - - - <%= f.select :fault_type, f.object.facet_options(:fault_type), {}, { class: 'form-control' } %> - <%= f.text_field :alert_issue_date, placeholder: Date.today.to_s, class: 'form-control' %> - - <%= f.select :faulty_item_type, f.object.facet_options(:faulty_item_type), { label: "Item type" }, { class: 'form-control' } %> - <%= f.select :manufacturer, f.object.facet_options(:manufacturer), {}, { class: 'form-control' } %> - <%= f.text_field :faulty_item_model, placeholder: 'A80', class: 'form-control', label: "Model" %> - <%= f.text_field :serial_number, placeholder: 'XX YY 12345 - XX YY 22345', class: 'form-control', label: "Serial number/Vehicle ID" %> - - <%= f.text_field :build_start_date, placeholder: '2014-07-12', class: 'form-control' %> - <%= f.text_field :build_end_date, placeholder: '2014-10-15', class: 'form-control' %> - - <%= render partial: "specialist_documents/minor_major_update_fields", locals: { f: f, document: document } %> - -
- -
- <% end %> -
- -<%= render partial: "specialist_documents/attachments_form", locals: { document: document } %> - -<%= render partial: "specialist_documents/js_preview", locals: { document: document, form_namespace: "vehicle_recalls_and_faults_alert" } %> diff --git a/spec/fixtures/aaib_import/downloads/162/2-1981 G-BAOZ.pdf b/spec/fixtures/aaib_import/downloads/162/2-1981 G-BAOZ.pdf deleted file mode 100644 index 9e4c704716732a268e25443da60d1d067fe385c6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2414006 zcmd43dt6gj)<3+HK!TBr)}sPVxQIexs}M;w0RksdAPKi5*lCAai((~VS_J{oSR?_J zX@&-rRA~x$Bng+9p_gf>mx`h`qHTc?7<8zm3Koo%A~kqH)OW?sJkR|8doTaI_z}X% zIXio=z4p3&zl#;pR})upRNzn{Z(z2dBkSk2=Ft>dp*&0qU`jPxzJ-2Wbg3zLG!*SWs0dFA;a z9GLF!gK#5Vul_yA+BKZjoHhR$&vrGR_*1Y`EwhWsaf{X7tLMpz!s|!UE|#JL7k}m$zg4JKGC`;O6)p@9x-{ zk+(S;hI#d!UCQitNU4( z6p|2;7m_Fo$V@k9qX@3lNz^p^)7u?(S}GaAyg;hujvr zzYxq3QWwcK)0X99Ycz+BdxWh2;{0NH-`(YrTXvSsqc2(N>*v2BG>pYw$$e$*IvzhN z{?&xUB#~H>vEj8py#B@?Gqbn8vn@xV%q=J^+Eu)JkE(qCfrAx){y=-UM*q=~qqQF! z8jU7%Q*%q}U;pu?rTwcDCr_QeaPb@KrLN0YzP0xc{B!W?wSNuW92vd!^Vs-p$DQfl z?m1`fKX~|PmV_w3F9*K=zM%hF&q7!a+0BjOMsux)L@tK^l!b2Y!5r!fLK$sy{-R}T zG#=RcL&v{3KQAOwes}SfoqhBr%egmKOuLr!d`18F7F72CYDNFEp#NFVvmxY3A;E@G z7NR)xV3yUWrvLxM7I>So;BTp%_? zCMQMBrz*O!ZMwYAw`o~$Im^iXn5dKWELoyu8S7rgwpI2e@!m-3Gi-GI#FYwDFSp>p zf$mVHG7>Iq>@%d;$KdIYjofWz*Wd|1cv0Ecvt%iE|7iP*2VU%G8HbPP<-ui`0~w!4 zR4V7qDaPm1+3RG-ax?iCF60;@ClmL~$_y}7LnNN-8aPt;{E58Jb6mrncFnIQ&-`QJ zO#|QdM(QYUD*0G$WTIkRnAIJ6mt9Pcgq6%YBOm*4U^`60?S|~@I@xL0JQn4dud}Eh z4ip?H&x1KUf5F|3J%6Eo#r+ErgE4JCS_CWa_A?eC*IM8MzaDzNn4qjgW&F0Xe0)3K z*R?itqt^6mP@{I`ijy`uyZ2prpPVeW`)5+aBp#y%A2YMVfhav*n5;p8jIE7Y#7SgX zF;subjLD_sdkIVh7s2QaY#%PNlqihDYI>TppMJOy@I3XU^JUHE-74=CcFYv>tnh6oo(#S{o zrXIHXZ}ysU+>D{}HmsKP0i|Z}C__#nVHVktdO@B-kid4DVx)*?_BB1YOxEDkXqhH? zG8L5%sh3pV)4r|3`S%G5LtZ>mbC&(&Btcy{x_s9Dz&zScYZyRVsv8u3%~CQwzI%1F zyn#icWo{by*m#btCbPI5C!2H%G?~=Sc#5^1zfnZEJMSCK>(0_LH!`H;B7tg`d7~lP zX$*jIH2wDKt@bhX(sq`)vHjqM%?a3s@ABv=_C7gDjAQ=sbe5TL>*ABO>+>R$4JdL# z7&B{^+epJYr)wpi-tH`-QX6d}?=m;SKFzzWObB9(98oWFBq!w}f?Rz|u4R#YBpjic zp!hn(4f)#W5zS9rezJR9?u}8Zc^*_&D%+nqQQAM`|9~ z5^wfm=;Wv&%Ae}5Q;(?W(RO>mX*FV9N(~QeqpBBiiyL(p)Z{!ir$H$+R@%svy8BkP zA2(1U9Jo)o6ZwNjKaRDf zLhwYA$|sHeIg0SYDychZT%$S2bL-fVno}lzZ+irTEnvm<=!;Bbe?iN{L#aCoHe>pF z)ih2=6sEE?O0p5Qd9YlpQ~uaOLfq{3)f_R1Cf^WiDJGttl4^&3cGoxhqJRQqy z0ueE9cl()0lZlE(wf8}7%4i$Qfx8Ed9d!u1QCJ80NI6brVf1JlDFLhZLaQ+EIvWdd z_4G`{YCH_;mu3klvHB6{Zi!-?n{&_DfdUUu%nVye3&Kj25s?$gL!glX&hoa^N_At6 zMo9SMWW8*-Is?(P(JEV9)KdPKnlgB(HJzJd4q9--ZZG6n0}mkP6Bbi&d$w;-jgcIp z{Nbb1rdcWCPe}Fz=)DzBS0b9kCzDOO96Nya+VWJk-Iu`RlutaAkKZ+4@(N48q+WVV zmU?Hmd0DlM{1o#s` z9j>J+Li*d7QTa(+HCyRHR0%ktxj(toFRI*~EEZBk$C1|L2y@0Kf zqu2rcDX;>wQkIqCz-cOEbO;H`T|&}7u~+sDR(lU1iwqPn zLyVibsJ>Ov%Pmtcsc8>arMDr>|6TQHThQg0Is;NQ@Cn(W;j#i8S;Gn>ya^b%BgCf4 z7ey5e)_PO5Ud!&DnHEvZEQggnAyTUM`twcW+>@6SBp-nS%c-&Y&6vniG3N7g8k`5x zSfzi2cJ)sBPt)23{z?;qA#KshH9({tTX zNa2LUhZ}H;VH0#CCf~>-j%AXZ80u(EShd)+b`b0xrTw9E{A z-qpM2DbXHcZwA5wSY0XpX#?tw_r#U*`(xEbT+~s*!m?ytxmlEEZiRsaJ9kHs-5ne= zqAp2AJpcIbkkU`ukS}g<78v3Vs!3P583k7{0vy7GShvSWF~Dxi zbZ2A@7s`h#v)d5uQC~l{%hb#8)}v;7dFOreteip7;`95llVj!hTni~mX4gF(2+*T? zM@ctr=%}EDF`hfe}dBEUT~HQcR)HHFXnsUd+^NE9UU#?%Xt5%X602Yz%(#2s+o zKo*Cbn!@Sl>ixKu{dM5Bb$lYQM=zI>9?2>heRT{u9TkP{RL~mqbd=GLH6Hn28!H>u zu1v)0{MkyRm+qut87QWxQP-#uk;}USGouTv2&-3+kErQvftA*bA#e9^M*_2jB)H8~ zOeJfoGLdAXDn9{38F=sqGmhj$d_=v7&yc2L-nHhK!Z9@|A#@K>kU~<7Vjr7%%hdiK z_oV-vJ}DLtS9?#2cuftKj)aH>KB_2x!Q;NKzhaS8heYEw+U>up&RsNIwwIEa$0yuY^~T5y8L7gC6{mk1}L z4Qb;CkG71d$qD2#CFycEist4i_vXV%b7zlFB>mP{?V*^^M%!=Y8&Fy#&d9fyYm&BG zPz5(2&fn)D#&Qg?W+k3>m}ky5G#Yr=||Y-J=q-=SS!(!x}xq99`j zWw2@-M^9LSgL{k}zFb6)Dq;DKcQBvoLA{eCnJW|zSiwAy^v9UOZGMSpnCBsQ&{D$reFDE zAAQ2)V}C@)tETgv=8P#TZP}qu3;{Rjirx-C=7G>(?((eBsC=-}zP0}fv&BZjyO&pt zH8DoDJL`&?3GYAj>@i&t+zx3{?$dvyCh^C)rnz&H?7D2)gyip$=S}1YL6Rh*;3~J- zZ|vj4UIO%%(|D*(zWu@R+G*{s1;-sP?%HkoZdY@nZw}YuJ1y+V6?6$4H?(@nTc^x4 zN?Y*e1`Bb>`kH!Y-E^8j5nx%=E&8VGI1zB6F1;;e-v%``0t7>$mJdkD0UgSGYcOUs zM=a14{LsNDG>2e5D%@|ZCX9P#OpDkB))fKz&Xh7mx7#R%ON><0RPmR)SNV;pJ#9W6 zlwnPGgm=F1yeVKrztF6+rngn)R97G