From 41ecad24c40b321f49c193e3af608ae77473a9bb Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Tue, 30 Nov 2021 09:34:30 +0000 Subject: [PATCH] Add basic info read page --- app/controllers/organisations_controller.rb | 7 +++++++ app/models/organisation.rb | 17 +++++++++++++++++ app/views/layouts/application.html.erb | 1 + app/views/organisations/show.html.erb | 19 +++++++++++++++++++ config/routes.rb | 2 ++ 5 files changed, 46 insertions(+) create mode 100644 app/controllers/organisations_controller.rb create mode 100644 app/views/organisations/show.html.erb diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb new file mode 100644 index 000000000..796c1eded --- /dev/null +++ b/app/controllers/organisations_controller.rb @@ -0,0 +1,7 @@ +class OrganisationsController < ApplicationController + before_action :authenticate_user! + + def show + @organisation = Organisation.find(params[:id]) + end +end diff --git a/app/models/organisation.rb b/app/models/organisation.rb index fb6dab181..392f6366f 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -14,4 +14,21 @@ class Organisation < ApplicationRecord def not_completed_case_logs case_logs.not_completed end + + def address_string + %i[address_line1 address_line2 postcode].map { |field| public_send(field) }.join("\n") + end + + def display_attributes + { + name: name, + address: address_string, + telephone_number: phone, + type: org_type, + local_authorities_operated_in: local_authorities, + holds_own_stock: holds_own_stock, + other_stock_owners: other_stock_owners, + managing_agents: managing_agents, + } + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7cfc25059..4ad2ae7a4 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -40,6 +40,7 @@ component.navigation_item(text: 'Case logs', href: '/case_logs') elsif component.navigation_item(text: 'Your account', href: '/users/account') + component.navigation_item(text: 'Organisation', href: "/organisations/#{current_user.organisation.id}") component.navigation_item(text: 'Sign out', href: destroy_user_session_path, options: {:method => :delete}) end end diff --git a/app/views/organisations/show.html.erb b/app/views/organisations/show.html.erb new file mode 100644 index 000000000..33fdb552d --- /dev/null +++ b/app/views/organisations/show.html.erb @@ -0,0 +1,19 @@ +<% content_for :before_content do %> + <%= govuk_back_link( + text: 'Back', + href: :back, + ) %> +<% end %> + +
+ <% @organisation.display_attributes.each do |attr, val| %> +
+
+ <%= attr.to_s.humanize %> +
+
+ <%= simple_format(val, {}, wrapper_tag: "div") %> +
+
+ <% end %> +
diff --git a/config/routes.rb b/config/routes.rb index 6c4fd7946..af7981407 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,6 +18,8 @@ Rails.application.routes.draw do form_handler = FormHandler.instance form = form_handler.get_form("2021_2022") + resources :organisations + resources :case_logs do collection do post "/bulk_upload", to: "bulk_upload#bulk_upload"