mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
added distributors.
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -11,6 +11,7 @@ gem 'spree_i18n', :git => 'git://github.com/spree/spree_i18n.git'
|
||||
|
||||
gem 'spree_usa_epay'
|
||||
gem 'spree_skrill'
|
||||
gem 'simple_form'
|
||||
|
||||
gem 'unicorn'
|
||||
# gem 'spree_heroku'
|
||||
@@ -48,5 +49,6 @@ group :test do
|
||||
gem 'rspec-rails'
|
||||
gem 'shoulda-matchers'
|
||||
gem 'machinist'
|
||||
gem "capybara"
|
||||
end
|
||||
|
||||
|
||||
23
Gemfile.lock
23
Gemfile.lock
@@ -57,6 +57,15 @@ GEM
|
||||
builder (>= 2.0.0)
|
||||
builder (3.0.0)
|
||||
cancan (1.6.7)
|
||||
capybara (1.1.2)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
selenium-webdriver (~> 2.0)
|
||||
xpath (~> 0.1.4)
|
||||
childprocess (0.3.1)
|
||||
ffi (~> 1.0.6)
|
||||
cocaine (0.2.1)
|
||||
coffee-rails (3.1.1)
|
||||
coffee-script (>= 2.2.0)
|
||||
@@ -77,6 +86,7 @@ GEM
|
||||
execjs (1.3.0)
|
||||
multi_json (~> 1.0)
|
||||
ffaker (1.12.1)
|
||||
ffi (1.0.11)
|
||||
gyoku (0.4.4)
|
||||
builder (>= 2.1.2)
|
||||
highline (1.6.8)
|
||||
@@ -163,6 +173,7 @@ GEM
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec (~> 2.9.0)
|
||||
rubyzip (0.9.6.1)
|
||||
sass (3.1.15)
|
||||
sass-rails (3.1.6)
|
||||
actionpack (~> 3.1.0)
|
||||
@@ -177,7 +188,15 @@ GEM
|
||||
nokogiri (>= 1.4.0)
|
||||
nori (~> 1.1)
|
||||
wasabi (~> 2.1)
|
||||
selenium-webdriver (2.20.0)
|
||||
childprocess (>= 0.2.5)
|
||||
ffi (~> 1.0)
|
||||
multi_json (~> 1.0)
|
||||
rubyzip
|
||||
shoulda-matchers (1.0.0)
|
||||
simple_form (2.0.1)
|
||||
actionpack (~> 3.0)
|
||||
activemodel (~> 3.0)
|
||||
spree (1.0.2)
|
||||
spree_api (= 1.0.2)
|
||||
spree_auth (= 1.0.2)
|
||||
@@ -245,11 +264,14 @@ GEM
|
||||
rack (>= 1.0)
|
||||
wasabi (2.1.0)
|
||||
nokogiri (>= 1.4.0)
|
||||
xpath (0.1.4)
|
||||
nokogiri (~> 1.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
capybara
|
||||
coffee-rails (~> 3.1.1)
|
||||
jquery-rails
|
||||
machinist
|
||||
@@ -258,6 +280,7 @@ DEPENDENCIES
|
||||
rspec-rails
|
||||
sass-rails (~> 3.1.5)
|
||||
shoulda-matchers
|
||||
simple_form
|
||||
spree
|
||||
spree_i18n!
|
||||
spree_skrill
|
||||
|
||||
45
app/controllers/distributors_controller.rb
Normal file
45
app/controllers/distributors_controller.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
class DistributorsController < ApplicationController
|
||||
force_ssl
|
||||
|
||||
respond_to :html
|
||||
|
||||
helper 'spree/admin/navigation'
|
||||
layout '/spree/layouts/admin'
|
||||
|
||||
def index
|
||||
@distributors = Distributor.all
|
||||
respond_with(@distributors)
|
||||
end
|
||||
|
||||
def new
|
||||
@distributor = Distributor.new
|
||||
end
|
||||
|
||||
def edit
|
||||
@distributor = Distributor.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@distributor = Distributor.find(params[:id])
|
||||
|
||||
if @distributor.update_attributes(params[:distributor])
|
||||
redirect_to distributors_path
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@distributor = Distributor.find(params[:id])
|
||||
respond_with(@distributor)
|
||||
end
|
||||
|
||||
def create
|
||||
@distributor = Distributor.new(params[:distributor])
|
||||
if @distributor.save
|
||||
redirect_to distributors_path
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
end
|
||||
2
app/models/distributor.rb
Normal file
2
app/models/distributor.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Distributor < ActiveRecord::Base
|
||||
end
|
||||
13
app/views/distributors/_form.html.erb
Normal file
13
app/views/distributors/_form.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<%= simple_form_for distributor do |f| %>
|
||||
<%= f.input :name %>
|
||||
<%= f.input :description %>
|
||||
<%= f.input :contact %>
|
||||
<%= f.input :phone %>
|
||||
<%= f.input :email %>
|
||||
<%= f.input :pickup_address %>
|
||||
<%= f.input :pickup_times %>
|
||||
<%= f.input :url %>
|
||||
<%= f.input :abn %>
|
||||
<%= f.input :acn %>
|
||||
<%= f.button :submit %>
|
||||
<% end %>
|
||||
2
app/views/distributors/edit.html.erb
Normal file
2
app/views/distributors/edit.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
<%= render :partial => 'form', :locals => { :distributor => @distributor } %>
|
||||
31
app/views/distributors/index.html.erb
Normal file
31
app/views/distributors/index.html.erb
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
<div class="toolbar" data-hook="toolbar">
|
||||
<ul class="actions">
|
||||
<li>
|
||||
<%= button_link_to "New Distributor", new_distributor_path, :icon => 'add', :id => 'admin_new_distributor_link' %>
|
||||
</li>
|
||||
</ul>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<table class="index" id='listing_distributors'>
|
||||
<thead>
|
||||
<tr data-hook="distributors_header">
|
||||
<th>Name</th>
|
||||
<th>
|
||||
Description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @distributors.each do |distributor| %>
|
||||
<tr >
|
||||
<td><%= link_to distributor.name, distributor_path(distributor) %></td>
|
||||
<td><%=distributor.description %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if @distributors.empty? %>
|
||||
<tr><td colspan="2"><%= t(:none) %></td></tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
2
app/views/distributors/new.html.erb
Normal file
2
app/views/distributors/new.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
<%= render :partial => 'form', :locals => { :distributor => @distributor } %>
|
||||
72
app/views/distributors/show.html
Normal file
72
app/views/distributors/show.html
Normal file
@@ -0,0 +1,72 @@
|
||||
<h1>Distributor</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td>
|
||||
<%= @distributor.name %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Description</th>
|
||||
<td>
|
||||
<%= @distributor.description %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Contact person</th>
|
||||
<td>
|
||||
<%= @distributor.contact %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Phone number</th>
|
||||
<td>
|
||||
<%= @distributor.phone %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Email</th>
|
||||
<td>
|
||||
<%= @distributor.email %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<th>Pickup address</th>
|
||||
<td>
|
||||
<%= @distributor.pickup_address %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<th>Pickup times</th>
|
||||
<td>
|
||||
<%= @distributor.pickup_times %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<th>ABN</th>
|
||||
<td>
|
||||
<%= @distributor.abn %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<th>ACN</th>
|
||||
<td>
|
||||
<%= @distributor.acn %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<th>URL</th>
|
||||
<td>
|
||||
<%= @distributor.url %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<%= link_to :Edit, edit_distributor_path(@distributor), :class => 'edit_distributor' %> <%= t(:or) %>
|
||||
<%= link_to t(:back), distributors_path %>
|
||||
</p>
|
||||
31
app/views/spree/admin/distributors/index.html.erb
Normal file
31
app/views/spree/admin/distributors/index.html.erb
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
<div class="toolbar" data-hook="toolbar">
|
||||
<ul class="actions">
|
||||
<li>
|
||||
<%= link_to "New Distributor", "new", :icon => 'add', :id => 'admin_new_distributor_link' %>
|
||||
</li>
|
||||
</ul>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<table class="index" id='listing_distributors'>
|
||||
<thead>
|
||||
<tr data-hook="distributors_header">
|
||||
<th>Name</th>
|
||||
<th>
|
||||
Description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @distributors.each do |distributor| %>
|
||||
<tr >
|
||||
<td><%=distributor.name %></td>
|
||||
<td><%=distributor.description %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if @distributors.empty? %>
|
||||
<tr><td colspan="2"><%= t(:none) %></td></tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
2
config/locales/en-AU.yml
Normal file
2
config/locales/en-AU.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
en-AU:
|
||||
new_product: New Product
|
||||
@@ -1,6 +1,9 @@
|
||||
Openfoodweb::Application.routes.draw do
|
||||
resources :distributors
|
||||
|
||||
# Mount Spree's routes
|
||||
mount Spree::Core::Engine, :at => '/'
|
||||
|
||||
# The priority is based upon order of creation:
|
||||
# first created -> highest priority.
|
||||
|
||||
|
||||
18
db/migrate/20120331051742_create_distributors.rb
Normal file
18
db/migrate/20120331051742_create_distributors.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class CreateDistributors < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :distributors do |t|
|
||||
t.string :name
|
||||
t.string :contact
|
||||
t.string :phone
|
||||
t.string :email
|
||||
t.string :pickup_address
|
||||
t.string :pickup_times
|
||||
t.string :url
|
||||
t.string :abn
|
||||
t.string :acn
|
||||
t.string :description
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user