diff --git a/Gemfile b/Gemfile index 4b9bba0848..73a5473cf7 100644 --- a/Gemfile +++ b/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 diff --git a/Gemfile.lock b/Gemfile.lock index 92ce6878f0..cee44a7318 100644 --- a/Gemfile.lock +++ b/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 diff --git a/app/controllers/distributors_controller.rb b/app/controllers/distributors_controller.rb new file mode 100644 index 0000000000..5b95f601ff --- /dev/null +++ b/app/controllers/distributors_controller.rb @@ -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 \ No newline at end of file diff --git a/app/models/distributor.rb b/app/models/distributor.rb new file mode 100644 index 0000000000..42b3d016d6 --- /dev/null +++ b/app/models/distributor.rb @@ -0,0 +1,2 @@ +class Distributor < ActiveRecord::Base +end diff --git a/app/views/distributors/_form.html.erb b/app/views/distributors/_form.html.erb new file mode 100644 index 0000000000..f3fdc1b2c6 --- /dev/null +++ b/app/views/distributors/_form.html.erb @@ -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 %> \ No newline at end of file diff --git a/app/views/distributors/edit.html.erb b/app/views/distributors/edit.html.erb new file mode 100644 index 0000000000..02b6a80e2c --- /dev/null +++ b/app/views/distributors/edit.html.erb @@ -0,0 +1,2 @@ + +<%= render :partial => 'form', :locals => { :distributor => @distributor } %> \ No newline at end of file diff --git a/app/views/distributors/index.html.erb b/app/views/distributors/index.html.erb new file mode 100644 index 0000000000..d531fe7fc5 --- /dev/null +++ b/app/views/distributors/index.html.erb @@ -0,0 +1,31 @@ + +
+ +
+
+ + + + + + + + + + <% @distributors.each do |distributor| %> + + + + + <% end %> + <% if @distributors.empty? %> + + <% end %> + +
Name + Description +
<%= link_to distributor.name, distributor_path(distributor) %><%=distributor.description %>
<%= t(:none) %>
\ No newline at end of file diff --git a/app/views/distributors/new.html.erb b/app/views/distributors/new.html.erb new file mode 100644 index 0000000000..02b6a80e2c --- /dev/null +++ b/app/views/distributors/new.html.erb @@ -0,0 +1,2 @@ + +<%= render :partial => 'form', :locals => { :distributor => @distributor } %> \ No newline at end of file diff --git a/app/views/distributors/show.html b/app/views/distributors/show.html new file mode 100644 index 0000000000..5019b87958 --- /dev/null +++ b/app/views/distributors/show.html @@ -0,0 +1,72 @@ +

Distributor

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name + <%= @distributor.name %> +
Description + <%= @distributor.description %> +
Contact person + <%= @distributor.contact %> +
Phone number + <%= @distributor.phone %> +
Email + <%= @distributor.email %> +
Pickup address + <%= @distributor.pickup_address %> +
Pickup times + <%= @distributor.pickup_times %> +
ABN + <%= @distributor.abn %> +
ACN + <%= @distributor.acn %> +
URL + <%= @distributor.url %> +
+ +

+ <%= link_to :Edit, edit_distributor_path(@distributor), :class => 'edit_distributor' %> <%= t(:or) %> + <%= link_to t(:back), distributors_path %> +

\ No newline at end of file diff --git a/app/views/spree/admin/distributors/index.html.erb b/app/views/spree/admin/distributors/index.html.erb new file mode 100644 index 0000000000..14195a8c80 --- /dev/null +++ b/app/views/spree/admin/distributors/index.html.erb @@ -0,0 +1,31 @@ + +
+ +
+
+ + + + + + + + + + <% @distributors.each do |distributor| %> + + + + + <% end %> + <% if @distributors.empty? %> + + <% end %> + +
Name + Description +
<%=distributor.name %><%=distributor.description %>
<%= t(:none) %>
\ No newline at end of file diff --git a/config/locales/en-AU.yml b/config/locales/en-AU.yml new file mode 100644 index 0000000000..6952adfba2 --- /dev/null +++ b/config/locales/en-AU.yml @@ -0,0 +1,2 @@ +en-AU: + new_product: New Product \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index e5639324d6..885e098330 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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. diff --git a/db/migrate/20120331051742_create_distributors.rb b/db/migrate/20120331051742_create_distributors.rb new file mode 100644 index 0000000000..f9096b4fb8 --- /dev/null +++ b/db/migrate/20120331051742_create_distributors.rb @@ -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