mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-20 04:59:16 +00:00
Skeleton for the search results.
This commit is contained in:
@@ -31,4 +31,10 @@ class EnterprisesController < BaseController
|
||||
@searcher = Spree::Config.searcher_class.new(options)
|
||||
@products = @searcher.retrieve_products
|
||||
end
|
||||
|
||||
def search
|
||||
suburb = Suburb.find_by_postcode(params[:postcode])
|
||||
@enterpsises = Enterprise.all
|
||||
render :layout => "landing_page"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,6 +65,10 @@ class Enterprise < ActiveRecord::Base
|
||||
count(distinct: true)
|
||||
end
|
||||
|
||||
def self.search_near(suburb)
|
||||
Enterprise.near [suburb.latitude, suburb.longitude]
|
||||
end
|
||||
|
||||
def has_supplied_products_on_hand?
|
||||
self.supplied_products.where('count_on_hand > 0').present?
|
||||
end
|
||||
|
||||
4
app/views/enterprises/search.html.haml
Normal file
4
app/views/enterprises/search.html.haml
Normal file
@@ -0,0 +1,4 @@
|
||||
- @enterpsises.each do |enterprise|
|
||||
.row
|
||||
.large-12.columns
|
||||
= enterprise.name
|
||||
@@ -5,7 +5,7 @@
|
||||
.large-10.large-centered.columns
|
||||
#postcode_select_box
|
||||
.row
|
||||
= form_tag do
|
||||
= form_tag search_enterprises_path do
|
||||
.large-10.columns
|
||||
= text_field_tag :postcode, "", class: "right", placeholder: "Enter your postcode..."
|
||||
.large-2.columns
|
||||
|
||||
@@ -4,6 +4,7 @@ Openfoodweb::Application.routes.draw do
|
||||
resources :enterprises do
|
||||
get :suppliers, :on => :collection
|
||||
get :distributors, :on => :collection
|
||||
post :search, :on => :collection
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
|
||||
Reference in New Issue
Block a user