begin adding suppliers

This commit is contained in:
Andrew Spinks
2012-04-22 14:51:24 +10:00
parent 4ad11c1faf
commit 7ea0f73398
10 changed files with 109 additions and 2 deletions

View File

@@ -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'

View 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

View 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

View File

@@ -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)

View 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' %> &nbsp;
<%= link_to_delete supplier %>
</td>
</tr>
<% end %>
<% if @suppliers.empty? %>
<tr><td colspan="2"><%= t(:none) %></td></tr>
<% end %>
</tbody>
</table>

View File

@@ -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

View File

@@ -65,5 +65,6 @@ end
Spree::Core::Engine.routes.prepend do
namespace :admin do
resources :distributors
resources :suppliers
end
end

View 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

View 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

View 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