From d80b9aea1c61b7e04c7e9418e55567b004f699c7 Mon Sep 17 00:00:00 2001 From: JG Date: Wed, 15 Jun 2022 07:31:38 +0100 Subject: [PATCH] controller action plus other bits --- app/controllers/schemes_controller.rb | 4 ++++ app/models/scheme.rb | 2 +- app/views/schemes/show.html.erb | 4 ++-- db/seeds.rb | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index d9dccab5d..1615a1e33 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -19,6 +19,10 @@ class SchemesController < ApplicationController render_not_found and return unless (current_user.organisation == @scheme.organisation) || current_user.support? end + def locations + @scheme = Scheme.find_by(id: params[:id]) + end + private def search_term diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 422f34b3b..357847180 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -1,10 +1,10 @@ class Scheme < ApplicationRecord belongs_to :organisation + has_many :locations scope :search_by_code, ->(code) { where("code ILIKE ?", "%#{code}%") } scope :search_by_service_name, ->(name) { where("service_name ILIKE ?", "%#{name}%") } scope :search_by, ->(param) { search_by_code(param).or(search_by_service_name(param)) } - has_many :locations SCHEME_TYPE = { 0 => "Missings", diff --git a/app/views/schemes/show.html.erb b/app/views/schemes/show.html.erb index 99d677999..b255fa518 100644 --- a/app/views/schemes/show.html.erb +++ b/app/views/schemes/show.html.erb @@ -1,6 +1,8 @@ <% title = @scheme.service_name %> <% content_for :title, title %> +<%= govuk_back_link(href: "#{request.referrer}")%> + <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> @@ -20,5 +22,3 @@ <% end %> - -<%= govuk_back_link(href: "#{request.referrer}")%> diff --git a/db/seeds.rb b/db/seeds.rb index ad1fc1ac4..65bac030d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -114,6 +114,8 @@ unless Rails.env.test? organisation: dummy_org, created_at: Time.zone.now, ) + + Location.create(scheme: scheme, location_code: "7XYZ") end pp "Seeded 3 dummy schemes"