mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
begin adding suppliers
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -44,7 +44,7 @@ gem 'jquery-rails'
|
||||
# To use debugger
|
||||
# gem 'ruby-debug19', :require => 'ruby-debug'
|
||||
|
||||
group :test do
|
||||
group :test, :development do
|
||||
# Pretty printed test output
|
||||
gem 'turn', '~> 0.8.3', :require => false
|
||||
gem 'rspec-rails'
|
||||
|
||||
12
app/controllers/spree/admin/suppliers_controller.rb
Normal file
12
app/controllers/spree/admin/suppliers_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class SuppliersController < ResourceController
|
||||
# before_filter :load_data, :except => [:index]
|
||||
|
||||
private
|
||||
def collection
|
||||
super.order(:name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
17
app/models/spree/supplier.rb
Normal file
17
app/models/spree/supplier.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
module Spree
|
||||
class Supplier < ActiveRecord::Base
|
||||
set_table_name 'suppliers'
|
||||
belongs_to :address
|
||||
# has_many :orders
|
||||
# belongs_to :country
|
||||
# belongs_to :state
|
||||
|
||||
# validates :name, :pickup_address, :country_id, :state_id, :city, :post_code, :presence => true
|
||||
|
||||
# after_initialize :initialize_country
|
||||
|
||||
# def initialize_country
|
||||
# self.country = Spree::Country.find_by_id(Spree::Config[:default_country_id])
|
||||
# end
|
||||
end
|
||||
end
|
||||
@@ -3,3 +3,9 @@ Deface::Override.new(:virtual_path => "spree/layouts/admin",
|
||||
:insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]",
|
||||
:text => "<%= tab(:distributors, :url => spree.admin_distributors_path) %>",
|
||||
:disabled => false)
|
||||
|
||||
Deface::Override.new(:virtual_path => "spree/layouts/admin",
|
||||
:name => "suppliers_admin_tabs",
|
||||
:insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]",
|
||||
:text => "<%= tab(:suppliers, :url => spree.admin_suppliers_path) %>",
|
||||
:disabled => false)
|
||||
37
app/views/spree/admin/suppliers/index.html.erb
Normal file
37
app/views/spree/admin/suppliers/index.html.erb
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
<div class="toolbar" data-hook="toolbar">
|
||||
<ul class="actions">
|
||||
<li>
|
||||
<%= button_link_to "New Supplier", spree.new_admin_supplier_path, :icon => 'add', :id => 'admin_new_supplier_link' %>
|
||||
</li>
|
||||
</ul>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<table class="index" id='listing_suppliers'>
|
||||
<thead>
|
||||
<tr data-hook="suppliers_header">
|
||||
<th>Name</th>
|
||||
<th>
|
||||
Description
|
||||
</th>
|
||||
<th>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @suppliers.each do |supplier| %>
|
||||
<tr >
|
||||
<td><%= link_to supplier.name, spree.admin_supplier_path(supplier) %></td>
|
||||
<td><%=supplier.description %></td>
|
||||
<td data-hook="admin_supplier_index_row_actions">
|
||||
<%= link_to_edit supplier, :class => 'edit' %>
|
||||
<%= link_to_delete supplier %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if @suppliers.empty? %>
|
||||
<tr><td colspan="2"><%= t(:none) %></td></tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -13,5 +13,5 @@ Spree.config do |config|
|
||||
# config.shipping_instructions = true
|
||||
config.checkout_zone = 'Australia'
|
||||
config.address_requires_state = true
|
||||
config.default_country_id = Spree::Country.find_by_name('Australia').id
|
||||
config.default_country_id = Spree::Country.find_by_name('Australia').id if Spree::Country.find_by_name('Australia')
|
||||
end
|
||||
|
||||
@@ -65,5 +65,6 @@ end
|
||||
Spree::Core::Engine.routes.prepend do
|
||||
namespace :admin do
|
||||
resources :distributors
|
||||
resources :suppliers
|
||||
end
|
||||
end
|
||||
|
||||
16
db/migrate/20120422042134_add_supplier.rb
Normal file
16
db/migrate/20120422042134_add_supplier.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class AddSupplier < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :suppliers do |t|
|
||||
t.string :name
|
||||
t.string :description
|
||||
t.string :url
|
||||
t.string :email
|
||||
t.string :twitter
|
||||
t.string :website
|
||||
|
||||
t.integer :address_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
9
spec/models/distributors_spec.rb
Normal file
9
spec/models/distributors_spec.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Spree::Distributor do
|
||||
|
||||
it "should default the country to the default spree country" do
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
9
spec/models/suppliers_spec.rb
Normal file
9
spec/models/suppliers_spec.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Spree::Supplier do
|
||||
|
||||
it "should have an address"
|
||||
|
||||
it "should add an address on save"
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user