spree_retailers 0.50.0.0 → 0.70.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.travis.yml +8 -0
- data/Gemfile +2 -0
- data/LICENSE +27 -0
- data/README.md +24 -9
- data/Rakefile +3 -22
- data/Versionfile +4 -0
- data/app/controllers/admin/retailers_controller.rb +6 -27
- data/app/controllers/retailers_controller.rb +1 -1
- data/app/helpers/retailers_helper.rb +5 -2
- data/app/models/retailer.rb +3 -1
- data/app/overrides/spree_retailers.rb +5 -0
- data/app/views/admin/hooks/_retailers_tab.html.erb +1 -1
- data/app/views/admin/retailers/_form.html.erb +50 -8
- data/app/views/admin/retailers/edit.html.erb +1 -1
- data/app/views/admin/retailers/index.html.erb +19 -12
- data/app/views/retailers/_list.html.erb +16 -8
- data/app/views/retailers/index.html.erb +4 -8
- data/config/locales/en.yml +11 -1
- data/config/routes.rb +2 -1
- data/lib/generators/spree_retailers/install_generator.rb +32 -0
- data/{db → lib/generators/templates/db}/migrate/install_spree_retailers.rb +0 -0
- data/lib/spree_core/action_callbacks.rb +26 -0
- data/lib/spree_retailers.rb +15 -7
- data/lib/spree_retailers/version.rb +2 -2
- data/spree_retailers.gemspec +31 -0
- data/test/dummy_hooks/after_migrate.rb.sample +7 -0
- data/test/dummy_hooks/before_migrate.rb +13 -0
- data/test/dummy_hooks/templates/admin/all.css +3 -0
- data/test/dummy_hooks/templates/admin/all.js +1 -0
- data/test/dummy_hooks/templates/store/all.css +3 -0
- data/test/dummy_hooks/templates/store/all.js +1 -0
- data/test/fixtures/retailers.yml +29 -0
- data/test/fixtures/states.yml +256 -0
- data/test/functional/admin/retailers_controller_test.rb +54 -0
- data/test/functional/retailers_controller_test.rb +12 -0
- data/test/test_helper.rb +30 -0
- data/test/unit/retailer_test.rb +134 -0
- metadata +106 -100
- data/lib/spree_retailers/custom_hooks.rb +0 -7
- data/lib/spree_retailers/generators/test_app_generator.rb +0 -69
- data/lib/spree_retailers/templates/config/boot.rb +0 -13
- data/lib/tasks/install.rake +0 -36
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2011 Spencer Steffen and Citrus Media Group.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
* Neither the name of Citrus Media Group nor the names of its
|
15
|
+
contributors may be used to endorse or promote products derived from this
|
16
|
+
software without specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
19
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
20
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
22
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
23
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
24
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
25
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
26
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
27
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -1,24 +1,39 @@
|
|
1
1
|
Spree Retailers
|
2
2
|
===============
|
3
3
|
|
4
|
-
Spree Retailers is a
|
4
|
+
Spree Retailers is a Spree extension for listing your company's retail stores on your web site.
|
5
5
|
|
6
6
|
|
7
7
|
Installation
|
8
8
|
------------
|
9
9
|
|
10
|
-
As usual, add 'spree_retailers' to your Gemfile
|
11
|
-
|
10
|
+
As usual, add 'spree_retailers' to your Gemfile and run bundle install:
|
12
11
|
|
13
|
-
# 0.
|
12
|
+
# Spree 0.70.x
|
13
|
+
gem 'spree_retailers', '0.70.0.0'
|
14
|
+
|
15
|
+
# Spree 0.50.x, 0.60.x
|
14
16
|
gem 'spree_retailers', '0.50.0.0'
|
15
17
|
|
16
|
-
# 0.40.x
|
18
|
+
# Spree 0.40.x
|
17
19
|
gem 'spree_retailers', '0.40.0.4'
|
18
20
|
|
19
|
-
#
|
21
|
+
# install from git
|
22
|
+
gem 'spree_retailers', :git => 'git://github.com/citrus/spree_retailers.git'
|
23
|
+
|
24
|
+
|
25
|
+
Next, copy the migration file to your project:
|
26
|
+
|
27
|
+
# Spree 0.40.x, 0.50.x and 0.60.x
|
28
|
+
rake spree_retailers:install
|
20
29
|
|
21
|
-
|
30
|
+
# 0.70.x and above
|
31
|
+
rails g spree_retailers:install
|
32
|
+
|
33
|
+
|
34
|
+
Now, migrate your database with:
|
35
|
+
|
36
|
+
rake db:migrate
|
22
37
|
|
23
38
|
|
24
39
|
To Do
|
@@ -27,10 +42,10 @@ To Do
|
|
27
42
|
* Write controller tests
|
28
43
|
* Write admin tests
|
29
44
|
* Google map integration (we're already geocoding, so why not?)
|
30
|
-
* Add International Support
|
45
|
+
* Add (better) International Support
|
31
46
|
|
32
47
|
|
33
48
|
License
|
34
49
|
-------
|
35
50
|
|
36
|
-
Copyright (c) 2011 Spencer Steffen, released under the New BSD License All rights reserved.
|
51
|
+
Copyright (c) 2011 Spencer Steffen and Citrus, released under the New BSD License All rights reserved.
|
data/Rakefile
CHANGED
@@ -1,29 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
3
|
-
begin
|
4
|
-
require 'bundler/setup'
|
5
|
-
rescue LoadError
|
6
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'rake'
|
2
|
+
require "bundler/gem_tasks"
|
10
3
|
require 'rake/testtask'
|
11
|
-
#require 'rake/rdoctask'
|
12
|
-
|
13
|
-
Bundler::GemHelper.install_tasks
|
14
4
|
|
15
|
-
Rake::TestTask.new
|
16
|
-
t.libs << 'lib'
|
17
|
-
t.libs << 'test'
|
5
|
+
Rake::TestTask.new do |t|
|
6
|
+
t.libs << 'lib' << 'test'
|
18
7
|
t.pattern = 'test/**/*_test.rb'
|
19
|
-
t.verbose = false
|
20
8
|
end
|
21
9
|
|
22
10
|
task :default => :test
|
23
|
-
|
24
|
-
|
25
|
-
desc "Builds dummy app for testing"
|
26
|
-
task :test_app do
|
27
|
-
require 'spree_retailers/generators/test_app_generator'
|
28
|
-
SpreeRetailers::Generators::TestAppGenerator.start
|
29
|
-
end
|
data/Versionfile
ADDED
@@ -1,39 +1,18 @@
|
|
1
|
-
class Admin::RetailersController < Admin::
|
1
|
+
class Admin::RetailersController < Admin::ResourceController
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
actions :all
|
6
|
-
|
7
|
-
create.response do |wants|
|
8
|
-
wants.html {redirect_to admin_retailers_path}
|
9
|
-
end
|
10
|
-
|
11
|
-
update.response do |wants|
|
12
|
-
wants.html {redirect_to admin_retailers_path}
|
13
|
-
end
|
14
|
-
|
15
|
-
index.response do |wants|
|
16
|
-
wants.html { render :action => :index }
|
17
|
-
wants.json { render :json => @collection.to_json() }
|
18
|
-
end
|
19
|
-
|
20
|
-
destroy.success.wants.js { render_js_for_destroy }
|
3
|
+
before_filter :get_locations, :except => [:index,:destroy]
|
21
4
|
|
22
5
|
private
|
23
6
|
|
24
|
-
def object
|
25
|
-
get_states
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
7
|
def collection
|
30
8
|
params[:search] ||= {}
|
31
9
|
params[:search][:meta_sort] ||= "name.asc"
|
32
|
-
@search =
|
33
|
-
@collection = @search.
|
10
|
+
@search = super.search(params[:search])
|
11
|
+
@collection = @search.page(params[:page]).per(Spree::Config[:orders_per_page])
|
34
12
|
end
|
35
13
|
|
36
|
-
def
|
14
|
+
def get_locations
|
15
|
+
@countries = Country.all.collect{|country| country.name }.sort
|
37
16
|
@states = State.where(:country_id => 214).collect{|state| [state.name, state.abbr] }.sort
|
38
17
|
end
|
39
18
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class RetailersController < Spree::BaseController
|
2
2
|
|
3
3
|
def index
|
4
|
-
@retailers = Retailer.order(:state, :name)
|
4
|
+
@retailers = Retailer.order(:country, :state, :name)
|
5
5
|
@states = {}
|
6
6
|
State.where(:abbr => @retailers.collect(&:state).uniq).all.each do |state|
|
7
7
|
@states[state.abbr] = state.name
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module RetailersHelper
|
2
2
|
|
3
|
-
def state_nav_helper
|
4
|
-
states =
|
3
|
+
def state_nav_helper(retailers=[])
|
4
|
+
states = retailers.collect(&:state).uniq
|
5
|
+
|
6
|
+
puts states
|
7
|
+
|
5
8
|
return "" unless 1 < states.length
|
6
9
|
states.collect{|state| link_to(state, "##{state.downcase}") }.join(" | ").html_safe
|
7
10
|
end
|
data/app/models/retailer.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
class Retailer < ActiveRecord::Base
|
2
2
|
|
3
|
-
|
3
|
+
validates :name, :address, :city, :presence => true
|
4
|
+
validates :state, :zipcode, :presence => true, :if => Proc.new{|record| record.country == "United States" }
|
5
|
+
|
4
6
|
validates :email, :email => true, :allow_blank => true
|
5
7
|
|
6
8
|
validates_numericality_of :latitude, :longitude, :allow_blank => true
|
@@ -1 +1 @@
|
|
1
|
-
<%= tab :retailers %>
|
1
|
+
<%= tab :retailers %>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
<%= f.field_container :address2 do %>
|
14
14
|
<%= f.label :address2, "Address (cont)" %><br />
|
15
|
-
<%= f.text_field :address2, :class => 'text'
|
15
|
+
<%= f.text_field :address2, :class => 'text' %>
|
16
16
|
<%= error_message_on :retailer, :address2 %>
|
17
17
|
<% end %>
|
18
18
|
|
@@ -23,12 +23,18 @@
|
|
23
23
|
<%= error_message_on :retailer, :city %>
|
24
24
|
<% end %>
|
25
25
|
|
26
|
+
|
27
|
+
|
26
28
|
<%= f.field_container :state do %>
|
27
29
|
<%= f.label :state, "State" %><br />
|
28
|
-
|
30
|
+
<% if @retailer.new_record? || @retailer.country == "United States" %>
|
31
|
+
<%= f.select :state, @states %>
|
32
|
+
<% else %>
|
33
|
+
<%= f.text_field :state, :class => 'text' %>
|
34
|
+
<% end %>
|
29
35
|
<%= error_message_on :retailer, :state %>
|
30
36
|
<% end %>
|
31
|
-
|
37
|
+
|
32
38
|
|
33
39
|
<%= f.field_container :zipcode do %>
|
34
40
|
<%= f.label :zipcode, "Zip" %><br />
|
@@ -37,6 +43,12 @@
|
|
37
43
|
<% end %>
|
38
44
|
|
39
45
|
|
46
|
+
<%= f.field_container :country do %>
|
47
|
+
<%= f.label :country, "Country" %><br />
|
48
|
+
<%= f.select :country, @countries, :selected => @retailer.new_record? ? "United States" : @retailer.country %>
|
49
|
+
<%= error_message_on :retailer, :country %>
|
50
|
+
<% end %>
|
51
|
+
|
40
52
|
|
41
53
|
<%= f.field_container :phone do %>
|
42
54
|
<%= f.label :phone, "Phone" %><br />
|
@@ -46,7 +58,7 @@
|
|
46
58
|
|
47
59
|
<%= f.field_container :email do %>
|
48
60
|
<%= f.label :email, "Email" %><br />
|
49
|
-
<%= f.
|
61
|
+
<%= f.email_field :email, :class => 'text' %>
|
50
62
|
<%= error_message_on :retailer, :email %>
|
51
63
|
<% end %>
|
52
64
|
|
@@ -56,8 +68,38 @@
|
|
56
68
|
<%= error_message_on :retailer, :url %>
|
57
69
|
<% end %>
|
58
70
|
|
59
|
-
|
60
|
-
<%= f.
|
61
|
-
|
62
|
-
|
71
|
+
<% if @retailer.has_logo? %>
|
72
|
+
<%= f.field_container :logo do %>
|
73
|
+
<p class="current-logo">
|
74
|
+
<%= label_tag 'current_logo', "Current Logo:" %><br />
|
75
|
+
<%= image_tag @retailer.logo.url(:thumb) %>
|
76
|
+
</p>
|
77
|
+
<%= f.label :logo, "Replace Image:" %><br />
|
78
|
+
<%= f.file_field :logo, :class => 'file' %>
|
79
|
+
<%= error_message_on :retailer, :logo %>
|
80
|
+
<% end %>
|
81
|
+
<% else %>
|
82
|
+
<%= f.field_container :logo do %>
|
83
|
+
<%= f.label :logo, "Logo Image:" %><br />
|
84
|
+
<%= f.file_field :logo, :class => 'file' %>
|
85
|
+
<%= error_message_on :retailer, :logo %>
|
86
|
+
<% end %>
|
63
87
|
<% end %>
|
88
|
+
|
89
|
+
<script type="text/javascript">
|
90
|
+
//<![CDATA[
|
91
|
+
|
92
|
+
$(document).ready(function() {
|
93
|
+
$('#retailer_country').change(function(evt) {
|
94
|
+
if (this.options[this.selectedIndex].value == 'United States') {
|
95
|
+
$('#retailer_state').remove();
|
96
|
+
$('#retailer_state_select').attr('id', 'retailer_state').show();
|
97
|
+
} else {
|
98
|
+
var p = $('#retailer_state').hide().attr('id', 'retailer_state_select').removeAttr('name').parent('p');
|
99
|
+
p.append('<input type="text" name="retailer[state]" id="retailer_state" class="text" />');
|
100
|
+
}
|
101
|
+
});
|
102
|
+
});
|
103
|
+
|
104
|
+
//]]>
|
105
|
+
</script>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h1>Edit Retailer</h1>
|
2
2
|
|
3
|
-
|
3
|
+
<%= form_for(@retailer, :url => object_url, :html => { :multipart => true, :method => :put }) do |f| %>
|
4
4
|
<%= render :partial => "form", :locals => { :f => f } %>
|
5
5
|
<p class="form-buttons">
|
6
6
|
<%= button t("update") %> <%= link_to t('cancel'), collection_url %>
|
@@ -28,7 +28,7 @@
|
|
28
28
|
<td><%= retailer.address %></td>
|
29
29
|
<td><%= retailer.state %></td>
|
30
30
|
<td><%= retailer.email %></td>
|
31
|
-
<td><%= retailer.phone %></td>
|
31
|
+
<td><%= number_to_phone retailer.phone %></td>
|
32
32
|
<td>
|
33
33
|
<%= link_to_edit retailer %>
|
34
34
|
<%= link_to_delete retailer %>
|
@@ -38,7 +38,7 @@
|
|
38
38
|
</tbody>
|
39
39
|
</table>
|
40
40
|
|
41
|
-
<%=
|
41
|
+
<%= paginate @collection %>
|
42
42
|
|
43
43
|
|
44
44
|
|
@@ -49,16 +49,23 @@
|
|
49
49
|
|
50
50
|
<% @retailer = Retailer.metasearch %>
|
51
51
|
<%= form_for [:admin, @retailer] do |f| %>
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
52
|
+
<p>
|
53
|
+
<label><%= t '.name_contains' %></label><br />
|
54
|
+
<%= f.text_field :name_contains, :size => 25 %>
|
55
|
+
</p>
|
56
|
+
<p>
|
57
|
+
<label><%= t '.email_contains' %></label><br />
|
58
|
+
<%= f.text_field :email_contains, :size => 25 %>
|
59
|
+
</p>
|
60
|
+
<p>
|
61
|
+
<label><%= t '.country_contains' %></label><br />
|
62
|
+
<%= f.text_field :country_contains, :size => 25 %>
|
63
|
+
</p>
|
64
|
+
<p>
|
65
|
+
<label><%= t '.state_contains' %></label><br />
|
66
|
+
<%= f.text_field :state_contains, :size => 25 %>
|
67
|
+
</p>
|
68
|
+
<p><%= button t("search") %></p>
|
62
69
|
<% end %>
|
63
70
|
</div>
|
64
71
|
<% end %>
|
@@ -2,14 +2,22 @@
|
|
2
2
|
<div class="retailers">
|
3
3
|
<h3>Find <%= Spree::Config[:site_name] %> at the following retail locations:</h3>
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
<% retailers.group_by(&:country).each do |country, country_retailers| %>
|
6
|
+
|
7
|
+
<h3><%= country %></h3>
|
8
|
+
|
9
|
+
<% if country == "United States" %>
|
10
|
+
<div class="state-nav">
|
11
|
+
<%= state_nav_helper(country_retailers) %>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<% country_retailers.group_by(&:state).each do |state, state_retailers| %>
|
16
|
+
<hr/>
|
17
|
+
<h4 id="<%= state.downcase %>"><%= @states[state] %></h4>
|
18
|
+
<%= render :partial => 'retailer', :collection => state_retailers %>
|
19
|
+
<% end %>
|
20
|
+
|
13
21
|
<% end %>
|
14
22
|
|
15
23
|
</div>
|
@@ -1,17 +1,13 @@
|
|
1
1
|
<h1><%= t('retailers') %></h1>
|
2
2
|
|
3
3
|
<div class="left">
|
4
|
-
|
5
|
-
<p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin vel ante a orci tempus eleifend ut et magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus urna sed urna ultricies ac tempor dui sagittis. In condimentum facilisis porta. Sed nec diam eu diam mattis viverra. Nulla fringilla, orci ac euismod semper, magna diam porttitor mauris, quis sollicitudin sapien justo in libero. Vestibulum mollis mauris enim. Morbi euismod magna ac lorem rutrum elementum. Donec viverra auctor lobortis. Pellentesque eu est.</p>
|
6
|
-
<% end %>
|
4
|
+
<p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin vel ante a orci tempus eleifend ut et magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus urna sed urna ultricies ac tempor dui sagittis. In condimentum facilisis porta. Sed nec diam eu diam mattis viverra. Nulla fringilla, orci ac euismod semper, magna diam porttitor mauris, quis sollicitudin sapien justo in libero. Vestibulum mollis mauris enim. Morbi euismod magna ac lorem rutrum elementum. Donec viverra auctor lobortis. Pellentesque eu est.</p>
|
7
5
|
</div>
|
8
6
|
|
9
7
|
<div class="right">
|
10
|
-
|
11
|
-
|
12
|
-
<%= render 'list', :retailers => @retailers %>
|
13
|
-
<% end %>
|
8
|
+
<% unless !@retailers || @retailers.empty? %>
|
9
|
+
<%= render 'list', :retailers => @retailers %>
|
14
10
|
<% end %>
|
15
11
|
</div>
|
16
12
|
|
17
|
-
<div class="clear"> </div>
|
13
|
+
<div class="clear"> </div>
|