Browse Source

controller action plus other bits

pull/662/head
JG 3 years ago
parent
commit
d80b9aea1c
  1. 4
      app/controllers/schemes_controller.rb
  2. 2
      app/models/scheme.rb
  3. 4
      app/views/schemes/show.html.erb
  4. 2
      db/seeds.rb

4
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

2
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",

4
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 %>
</div>
</div>
<%= govuk_back_link(href: "#{request.referrer}")%>

2
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"

Loading…
Cancel
Save