mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-12 18:36:49 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa336d9b9f | ||
|
|
ff029b8903 | ||
|
|
51850be83e | ||
|
|
32db258db0 | ||
|
|
4c0109bccc | ||
|
|
f83a5b0ba8 | ||
|
|
87a89324d9 | ||
|
|
4fc7295b97 | ||
|
|
5b025a6cba | ||
|
|
9166829930 | ||
|
|
8c7a02ec10 | ||
|
|
f4f250675c | ||
|
|
394a269df2 | ||
|
|
41dcc85ad1 | ||
|
|
9be9d75cb5 | ||
|
|
11483a77e8 | ||
|
|
ba895ed486 | ||
|
|
36d342f216 | ||
|
|
d09123eb22 | ||
|
|
642f58551c | ||
|
|
9fbcd8c01b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -27,4 +27,5 @@ public/stylesheets
|
||||
public/images
|
||||
public/spree
|
||||
config/abr.yml
|
||||
config/heroku_env.rb
|
||||
NERD_tree*
|
||||
|
||||
6
Gemfile
6
Gemfile
@@ -6,7 +6,7 @@ gem 'rails', '3.2.8'
|
||||
gem 'pg'
|
||||
gem 'spree', :git => 'git://github.com/spree/spree.git', :branch => '1-1-stable'
|
||||
gem 'spree_i18n', :git => 'git://github.com/spree/spree_i18n.git'
|
||||
gem 'spree_paypal_express', :git => 'git://github.com/spree/spree_paypal_express.git', :branch => '1-1-stable'
|
||||
gem 'spree_paypal_express', :git => 'git://github.com/eaterprises/spree_paypal_express.git', :branch => '1-1-stable'
|
||||
gem 'spree_last_address', :git => 'git://github.com/dancinglightning/spree-last-address.git'
|
||||
|
||||
gem 'comfortable_mexican_sofa'
|
||||
@@ -17,9 +17,9 @@ gem 'simple_form', :git => 'git://github.com/RohanM/simple_form.git'
|
||||
|
||||
gem 'unicorn'
|
||||
gem 'bugsnag'
|
||||
gem 'spree_heroku', :git => 'git://github.com/joneslee85/spree-heroku.git'
|
||||
gem 'spree_heroku', :git => 'git://github.com/eaterprises/spree-heroku.git'
|
||||
gem 'haml'
|
||||
gem 'aws-s3'
|
||||
gem 'aws-sdk'
|
||||
gem 'andand'
|
||||
gem 'truncate_html'
|
||||
|
||||
|
||||
51
Gemfile.lock
51
Gemfile.lock
@@ -14,16 +14,25 @@ GIT
|
||||
spree_core (>= 1.1)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/joneslee85/spree-heroku.git
|
||||
revision: 63f0cfa47089cae50365e226ec7dd1eccde0ac05
|
||||
remote: git://github.com/eaterprises/spree-heroku.git
|
||||
revision: a1e07bf7a22fc0c07a1be9148f477d20b557dbf6
|
||||
specs:
|
||||
spree_heroku (1.0)
|
||||
aws-sdk (~> 1.3.4)
|
||||
spree_core (>= 0.70.0)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/eaterprises/spree_paypal_express.git
|
||||
revision: ec7fd298f117fe6c598070dc0e7a38887b9bcbc4
|
||||
branch: 1-1-stable
|
||||
specs:
|
||||
spree_paypal_express (1.1.0)
|
||||
spree_auth (>= 1.0.0)
|
||||
spree_core (>= 1.0.0)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/spree/spree.git
|
||||
revision: d66ffac9088d0d5d0b0d146f305044ce619f0464
|
||||
revision: 46691e075129fd3d7b59e296d73149a9066c1b9d
|
||||
branch: 1-1-stable
|
||||
specs:
|
||||
spree (1.1.3)
|
||||
@@ -54,7 +63,7 @@ GIT
|
||||
jquery-rails (~> 2.0)
|
||||
kaminari (= 0.13.0)
|
||||
nested_set (= 1.7.0)
|
||||
paperclip (~> 2.7)
|
||||
paperclip (~> 2.8)
|
||||
rails (~> 3.2.8)
|
||||
ransack (~> 0.6.0)
|
||||
state_machine (= 1.1.2)
|
||||
@@ -77,15 +86,6 @@ GIT
|
||||
i18n (~> 0.5)
|
||||
spree (~> 1.1)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/spree/spree_paypal_express.git
|
||||
revision: 2c61f1700ef853e3d4f39739793dc3308422e94b
|
||||
branch: 1-1-stable
|
||||
specs:
|
||||
spree_paypal_express (1.1.0)
|
||||
spree_auth (>= 1.0.0)
|
||||
spree_core (>= 1.0.0)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
@@ -134,20 +134,16 @@ GEM
|
||||
ansi (1.4.2)
|
||||
arel (3.0.2)
|
||||
awesome_print (1.0.2)
|
||||
aws-s3 (0.6.3)
|
||||
builder
|
||||
mime-types
|
||||
xml-simple
|
||||
aws-sdk (1.3.9)
|
||||
httparty (~> 0.7)
|
||||
json (~> 1.4)
|
||||
nokogiri (>= 1.4.4)
|
||||
uuidtools (~> 2.1)
|
||||
bcrypt-ruby (3.0.1)
|
||||
bugsnag (1.1.2)
|
||||
httparty (~> 0.8.3)
|
||||
multi_json (~> 1.3.4)
|
||||
builder (3.0.3)
|
||||
bugsnag (1.2.4)
|
||||
httparty (>= 0.5, < 1.0)
|
||||
multi_json (~> 1.0)
|
||||
builder (3.0.4)
|
||||
cancan (1.6.7)
|
||||
capybara (1.1.2)
|
||||
mime-types (>= 1.16)
|
||||
@@ -158,7 +154,7 @@ GEM
|
||||
xpath (~> 0.1.4)
|
||||
childprocess (0.3.2)
|
||||
ffi (~> 1.0.6)
|
||||
cocaine (0.3.0)
|
||||
cocaine (0.4.2)
|
||||
coderay (1.0.7)
|
||||
coffee-rails (3.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
@@ -209,7 +205,7 @@ GEM
|
||||
multi_xml
|
||||
i18n (0.6.1)
|
||||
journey (1.0.4)
|
||||
jquery-rails (2.1.2)
|
||||
jquery-rails (2.1.3)
|
||||
railties (>= 3.1.0, < 5.0)
|
||||
thor (~> 0.14)
|
||||
json (1.7.5)
|
||||
@@ -237,7 +233,7 @@ GEM
|
||||
railties (>= 3.0.0)
|
||||
nokogiri (1.5.5)
|
||||
orm_adapter (0.0.7)
|
||||
paperclip (2.7.0)
|
||||
paperclip (2.8.0)
|
||||
activerecord (>= 2.3.0)
|
||||
activesupport (>= 2.3.2)
|
||||
cocaine (>= 0.0.2)
|
||||
@@ -261,7 +257,7 @@ GEM
|
||||
rack (>= 0.4)
|
||||
rack-ssl (1.3.2)
|
||||
rack
|
||||
rack-test (0.6.1)
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
rails (3.2.8)
|
||||
actionmailer (= 3.2.8)
|
||||
@@ -325,7 +321,7 @@ GEM
|
||||
libv8 (~> 3.3.10)
|
||||
thor (0.16.0)
|
||||
tilt (1.3.3)
|
||||
treetop (1.4.10)
|
||||
treetop (1.4.11)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
truncate_html (0.5.5)
|
||||
@@ -342,7 +338,6 @@ GEM
|
||||
uuidtools (2.1.3)
|
||||
warden (1.1.1)
|
||||
rack (>= 1.0)
|
||||
xml-simple (1.1.1)
|
||||
xpath (0.1.4)
|
||||
nokogiri (~> 1.3)
|
||||
|
||||
@@ -352,7 +347,7 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
andand
|
||||
awesome_print
|
||||
aws-s3
|
||||
aws-sdk
|
||||
bugsnag
|
||||
capybara
|
||||
coffee-rails (~> 3.2.1)
|
||||
|
||||
@@ -20,11 +20,11 @@ hosted at GitHub.
|
||||
|
||||
You can view the code at:
|
||||
|
||||
https://github.com/andrewspinks/openfoodweb
|
||||
https://github.com/eaterprises/openfoodweb
|
||||
|
||||
You can download the source with the command:
|
||||
|
||||
git clone git@github.com:andrewspinks/openfoodweb
|
||||
git clone git@github.com:eaterprises/openfoodweb
|
||||
|
||||
|
||||
## Get it running
|
||||
@@ -80,6 +80,7 @@ speak to Andrew Spinks.
|
||||
|
||||
* Andrew Spinks (http://github.com/andrewspinks)
|
||||
* Rohan Mitchell (http://github.com/rohanm)
|
||||
* Rob Harrington (http://github.com/oeoeaio)
|
||||
|
||||
|
||||
## Licence
|
||||
|
||||
@@ -2,6 +2,10 @@ module Spree
|
||||
class SuppliersController < BaseController
|
||||
helper 'spree/products'
|
||||
|
||||
def index
|
||||
@suppliers = Supplier.all
|
||||
end
|
||||
|
||||
def show
|
||||
options = {:supplier_id => params[:id]}
|
||||
options.merge(params.reject { |k,v| k == :id })
|
||||
|
||||
@@ -6,7 +6,7 @@ Spree::Product.class_eval do
|
||||
|
||||
accepts_nested_attributes_for :product_distributions, :allow_destroy => true
|
||||
|
||||
attr_accessible :supplier_id, :distributor_ids, :product_distributions_attributes, :group_buy
|
||||
attr_accessible :supplier_id, :distributor_ids, :product_distributions_attributes, :group_buy, :group_buy_unit_size
|
||||
|
||||
validates_presence_of :supplier
|
||||
|
||||
|
||||
@@ -12,6 +12,17 @@ module Spree
|
||||
after_initialize :initialize_country
|
||||
before_validation :set_unused_address_fields
|
||||
|
||||
def has_products_on_hand?
|
||||
self.products.where('count_on_hand > 0').present?
|
||||
end
|
||||
|
||||
def to_param
|
||||
"#{id}-#{name.parameterize}"
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def initialize_country
|
||||
self.address ||= Address.new
|
||||
self.address.country = Country.find_by_id(Spree::Config[:default_country_id]) if self.address.new_record?
|
||||
@@ -21,8 +32,5 @@ module Spree
|
||||
address.firstname = address.lastname = address.phone = 'unused' if address.present?
|
||||
end
|
||||
|
||||
def to_param
|
||||
"#{id}-#{name.parameterize}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
4
app/overrides/add_feedback_script.rb
Normal file
4
app/overrides/add_feedback_script.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
Deface::Override.new(:virtual_path => "spree/layouts/spree_application",
|
||||
:insert_bottom => "[data-hook='inside_head']",
|
||||
:partial => "layouts/feedback_script",
|
||||
:name => "feedback_script")
|
||||
8
app/views/layouts/_feedback_script.html
Normal file
8
app/views/layouts/_feedback_script.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<script type="text/javascript">
|
||||
var uvOptions = {};
|
||||
(function() {
|
||||
var uv = document.createElement('script'); uv.type = 'text/javascript'; uv.async = true;
|
||||
uv.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'widget.uservoice.com/mCbT1cbjQZkPELXOix9Ag.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(uv, s);
|
||||
})();
|
||||
</script>
|
||||
@@ -1,14 +1 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Openfoodweb</title>
|
||||
<%= stylesheet_link_tag "application" %>
|
||||
<%= javascript_include_tag "application" %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<%= render :file => 'spree/layouts/spree_application' %>
|
||||
|
||||
@@ -5,3 +5,8 @@
|
||||
= f.label :group_buy_1, 'Yes'
|
||||
= f.radio_button :group_buy, '0', :checked => !f.object.group_buy
|
||||
= f.label :group_buy_0, 'No'
|
||||
|
||||
= f.field_container :group_buy_unit_size do
|
||||
= f.label :group_buy_unit_size
|
||||
%br
|
||||
= f.text_field :group_buy_unit_size
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
%h6.filter_name Shop by Supplier
|
||||
%ul.filter_choices
|
||||
- @suppliers.each do |supplier|
|
||||
%li.nowrap= link_to supplier.name, supplier
|
||||
- if supplier.has_products_on_hand?
|
||||
%li.nowrap= link_to supplier.name, supplier
|
||||
= button_to 'Browse All Suppliers', suppliers_path, :method => :get
|
||||
|
||||
%h6.filter_name Shop by Distributor
|
||||
%ul.filter_choices
|
||||
|
||||
12
app/views/spree/suppliers/index.html.haml
Normal file
12
app/views/spree/suppliers/index.html.haml
Normal file
@@ -0,0 +1,12 @@
|
||||
- content_for :sidebar do
|
||||
%div{'data-hook' => "homepage_sidebar_navigation"}
|
||||
= render 'spree/sidebar'
|
||||
|
||||
|
||||
%h1 Suppliers
|
||||
|
||||
= cms_page_content(:content, Cms::Page.find_by_full_path('/suppliers'))
|
||||
|
||||
%ul.suppliers
|
||||
- @suppliers.each do |supplier|
|
||||
%li= link_to supplier.name, supplier
|
||||
@@ -28,3 +28,8 @@ Openfoodweb::Application.configure do
|
||||
# Expands the lines which load the assets
|
||||
config.assets.debug = true
|
||||
end
|
||||
|
||||
|
||||
# Load heroku vars from local file
|
||||
heroku_env = File.join(Rails.root, 'config', 'heroku_env.rb')
|
||||
load(heroku_env) if File.exists?(heroku_env)
|
||||
|
||||
@@ -34,8 +34,15 @@ ComfortableMexicanSofa.configure do |config|
|
||||
# the upload method and appropriate settings based on Paperclip. For S3 see:
|
||||
# http://rdoc.info/gems/paperclip/2.3.8/Paperclip/Storage/S3, and for
|
||||
# filesystem see: http://rdoc.info/gems/paperclip/2.3.8/Paperclip/Storage/Filesystem
|
||||
# config.upload_file_options = {:url => '/system/:class/:id/:attachment/:style/:filename'}
|
||||
|
||||
config.upload_file_options = {
|
||||
:storage => 's3',
|
||||
:s3_credentials => {
|
||||
:bucket => ENV['S3_BUCKET'],
|
||||
:access_key_id => ENV['S3_KEY'],
|
||||
:secret_access_key => ENV['S3_SECRET']
|
||||
}
|
||||
}
|
||||
|
||||
# Sofa allows you to setup entire site from files. Database is updated with each
|
||||
# request (if necessary). Please note that database entries are destroyed if there's
|
||||
# no corresponding file. Fixtures are disabled by default.
|
||||
@@ -118,3 +125,10 @@ ComfortableMexicanSofa::HttpAuth.password = 'password'
|
||||
# ComfortableMexicanSofa::ViewHooks.add(:html_head, '/layouts/admin/html_head')
|
||||
# ComfortableMexicanSofa::ViewHooks.add(:page_form, '/layouts/admin/page_form')
|
||||
ComfortableMexicanSofa::ViewHooks.add(:navigation, 'layouts/cms_nav_spree')
|
||||
|
||||
# Provide some Spree helpers to the CMS controller so it can render Spree's layout
|
||||
ComfortableMexicanSofa::CmsContentController.class_eval do
|
||||
helper 'spree/base'
|
||||
include Spree::Core::ControllerHelpers
|
||||
include Spree::Core::Engine.routes.url_helpers
|
||||
end
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
developement:
|
||||
bucket: openfoodweb_test
|
||||
access_key_id: AKIAJ3EE2EKGP36D4PUA
|
||||
secret_access_key: GUvfWLC5G5bpcjqRYOa9/IyxofIPjKQjgJonJuTW
|
||||
production:
|
||||
bucket: openfoodweb_production
|
||||
access_key_id: AKIAJ3EE2EKGP36D4PUA
|
||||
secret_access_key: GUvfWLC5G5bpcjqRYOa9/IyxofIPjKQjgJonJuTW
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddGroupBuyUnitSizeToProducts < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :spree_products, :group_buy_unit_size, :string
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20121010004400) do
|
||||
ActiveRecord::Schema.define(:version => 20121018002907) do
|
||||
|
||||
create_table "cms_blocks", :force => true do |t|
|
||||
t.integer "page_id", :null => false
|
||||
@@ -487,6 +487,7 @@ ActiveRecord::Schema.define(:version => 20121010004400) do
|
||||
t.integer "count_on_hand", :default => 0, :null => false
|
||||
t.integer "supplier_id"
|
||||
t.boolean "group_buy"
|
||||
t.string "group_buy_unit_size"
|
||||
end
|
||||
|
||||
add_index "spree_products", ["available_on"], :name => "index_products_on_available_on"
|
||||
|
||||
@@ -8,14 +8,32 @@ module Spree
|
||||
it { should belong_to(:address) }
|
||||
end
|
||||
|
||||
it "should default country to system country" do
|
||||
supplier = Supplier.new
|
||||
supplier.address.country.should == Country.find_by_id(Config[:default_country_id])
|
||||
end
|
||||
|
||||
describe "validations" do
|
||||
it { should validate_presence_of(:name) }
|
||||
end
|
||||
|
||||
it "should default country to system country" do
|
||||
subject.address.country.should == Country.find_by_id(Config[:default_country_id])
|
||||
end
|
||||
|
||||
context "has_products_on_hand?" do
|
||||
before :each do
|
||||
@supplier = create(:supplier)
|
||||
end
|
||||
|
||||
it "returns false when no products" do
|
||||
@supplier.should_not have_products_on_hand
|
||||
end
|
||||
|
||||
it "returns false when the product is out of stock" do
|
||||
create(:product, :supplier => @supplier, :on_hand => 0)
|
||||
@supplier.should_not have_products_on_hand
|
||||
end
|
||||
|
||||
it "returns true when the product is in stock" do
|
||||
create(:product, :supplier => @supplier, :on_hand => 1)
|
||||
@supplier.should have_products_on_hand
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,12 +49,14 @@ feature %q{
|
||||
fill_in 'product_price', :with => '19.99'
|
||||
select 'New supplier', :from => 'product_supplier_id'
|
||||
choose 'product_group_buy_1'
|
||||
fill_in 'Group buy unit size', :with => '10 kg'
|
||||
|
||||
click_button 'Create'
|
||||
|
||||
flash_message.should == 'Product "A new product !!!" has been successfully created!'
|
||||
product = Spree::Product.find_by_name('A new product !!!')
|
||||
product.group_buy.should be_true
|
||||
product.group_buy_unit_size.should == '10 kg'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,17 +8,43 @@ feature %q{
|
||||
include AuthenticationWorkflow
|
||||
include WebHelper
|
||||
|
||||
scenario "viewing a list of suppliers" do
|
||||
scenario "viewing a list of suppliers in the sidebar" do
|
||||
# Given some suppliers
|
||||
s1 = create(:supplier)
|
||||
s2 = create(:supplier)
|
||||
s3 = create(:supplier)
|
||||
|
||||
# And some of those suppliers have a product
|
||||
create(:product, :supplier => s1)
|
||||
create(:product, :supplier => s3)
|
||||
|
||||
# When I go to the home page
|
||||
visit spree.root_path
|
||||
|
||||
# Then I should see a list containing all the suppliers that have products in stock
|
||||
page.should have_selector 'a', :text => s1.name
|
||||
page.should have_selector 'a', :text => s3.name
|
||||
page.should_not have_selector 'a', :text => s2.name
|
||||
end
|
||||
|
||||
scenario "viewing a list of all suppliers" do
|
||||
# Given some suppliers
|
||||
s1 = create(:supplier)
|
||||
s2 = create(:supplier)
|
||||
s3 = create(:supplier)
|
||||
|
||||
# And some of those suppliers have a product
|
||||
create(:product, :supplier => s1)
|
||||
create(:product, :supplier => s3)
|
||||
|
||||
# When I go to the suppliers listing page
|
||||
visit spree.root_path
|
||||
click_button 'Browse All Suppliers'
|
||||
|
||||
# Then I should see a list containing all the suppliers
|
||||
[s1, s2, s3].each { |s| page.should have_selector 'a', :text => s.name }
|
||||
page.should have_selector '#content a', :text => s1.name
|
||||
page.should have_selector '#content a', :text => s2.name
|
||||
page.should have_selector '#content a', :text => s3.name
|
||||
end
|
||||
|
||||
scenario "viewing products provided by a supplier" do
|
||||
|
||||
Reference in New Issue
Block a user