spree_wholesale 0.40.0.beta4.1 → 0.40.0.beta4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/README.md +4 -4
  2. data/Rakefile +81 -17
  3. data/app/controllers/admin/base_controller_decorator.rb +11 -0
  4. data/app/controllers/admin/wholesalers_controller.rb +70 -0
  5. data/app/controllers/checkout_controller_decorator.rb +15 -0
  6. data/app/controllers/wholesalers_controller.rb +5 -0
  7. data/app/models/ability.rb +71 -0
  8. data/app/models/{application_controller_decorator.rb → application_helper_decorator.rb} +1 -2
  9. data/app/models/country_decorator.rb +3 -0
  10. data/app/models/order_decorator.rb +0 -2
  11. data/app/models/spree_current_order_decorator.rb +0 -13
  12. data/app/models/user_decorator.rb +5 -0
  13. data/app/models/wholesaler.rb +45 -0
  14. data/app/views/admin/hooks/_wholesale_tab.html.erb +1 -0
  15. data/app/views/admin/wholesalers/_form.html.erb +129 -0
  16. data/app/views/admin/wholesalers/_user_options.html.erb +6 -0
  17. data/app/views/admin/wholesalers/edit.html.erb +13 -0
  18. data/app/views/admin/wholesalers/index.html.erb +88 -0
  19. data/app/views/admin/wholesalers/new.html.erb +13 -0
  20. data/app/views/admin/wholesalers/show.html.erb +68 -0
  21. data/app/views/hooks/_wholesale_static_content.html.erb +3 -0
  22. data/app/views/shared/_address_form.html.erb +77 -0
  23. data/app/views/shared/_store_menu.html.erb +4 -0
  24. data/app/views/wholesalers/_fields.html.erb +91 -0
  25. data/app/views/wholesalers/index.html.erb +21 -0
  26. data/app/views/wholesalers/new.html.erb +8 -0
  27. data/config/locales/en.yml +45 -1
  28. data/config/routes.rb +11 -0
  29. data/db/migrate/install_spree_wholesale.rb +36 -0
  30. data/lib/spree_wholesale/wholesaler_controller.rb +122 -0
  31. data/lib/spree_wholesale_hooks.rb +4 -0
  32. data/lib/tasks/install.rake +0 -14
  33. data/lib/tasks/spree_wholesale.rake +11 -2
  34. data/public/stylesheets/admin/wholesalers.css +14 -0
  35. metadata +28 -6
  36. data/db/migrate/add_wholesale_price_to_variants.rb +0 -9
  37. data/db/migrate/add_wholesale_to_orders.rb +0 -9
@@ -0,0 +1,6 @@
1
+ <% wholesaler ||= @wholesaler %>
2
+ <% if wholesaler.active? %>
3
+ <%= link_to "deny", reject_admin_wholesaler_path(wholesaler) %>
4
+ <% else %>
5
+ <%= link_to "approve", approve_admin_wholesaler_path(wholesaler) %>
6
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <%= hook :admin_wholesaler_edit_form_header do %>
2
+ <h1><%= t("editing_wholesaler") %></h1>
3
+ <% end %>
4
+
5
+ <%= hook :admin_wholesaler_edit_form do %>
6
+ <%= form_for(:wholesaler, :url => object_url, :html => { :method => :put }) do |f| %>
7
+ <%= render :partial => "form", :locals => { :f => f } %>
8
+
9
+ <%= hook :admin_wholesaler_edit_form_buttons do %>
10
+ <%= render :partial => "admin/shared/edit_resource_links" %>
11
+ <% end %>
12
+ <% end %>
13
+ <% end %>
@@ -0,0 +1,88 @@
1
+ <div class='toolbar'>
2
+ <ul class='actions'>
3
+ <li>
4
+ <p><%= button_link_to t("new_wholesaler"), new_object_url, :icon => 'add' %></p>
5
+ </li>
6
+ </ul>
7
+ <br class='clear' />
8
+ </div>
9
+
10
+
11
+ <h1><%= t("listing_wholesalers") %></h1>
12
+
13
+
14
+ <table class="index">
15
+ <thead>
16
+ <tr>
17
+ <%= hook :admin_wholesalers_index_headers do %>
18
+ <th><%= order @search, :by => :company, :as => t("wholesaler") %></th>
19
+ <th><%= order @search, :by => :buyer_contact, :as => t("buyer_contact") %></th>
20
+ <th><%= order @search, :by => :email, :as => t("email") %></th>
21
+ <th><%= order @search, :by => :phone, :as => t("phone") %></th>
22
+ <th><%= t('active') %></th>
23
+ <th>
24
+ <%= hook :admin_wholesalers_index_header_actions %>
25
+ </th>
26
+ <% end %>
27
+ </tr>
28
+ </thead>
29
+ <tbody>
30
+ <% @wholesalers.each do |wholesaler|%>
31
+ <tr id="<%= dom_id wholesaler %>">
32
+ <%- locals = {:wholesaler => wholesaler} %>
33
+ <%= hook :admin_wholesalers_index_rows, locals do %>
34
+ <td><%=link_to wholesaler.company, object_url(wholesaler) %></td>
35
+ <td><%= wholesaler.buyer_contact %></td>
36
+ <td><%= mail_to wholesaler.email %></td>
37
+ <td><%= wholesaler.phone %></td>
38
+ <td width="50px"><%= wholesaler.roles.include?(wholesale_role) ? 'yes' : 'no' %></td>
39
+ <% end %>
40
+ <td>
41
+ <%= hook :admin_wholesalers_index_row_actions, locals do %>
42
+ <%= link_to_edit wholesaler %> &nbsp;
43
+ <%= link_to_delete wholesaler %> &nbsp;
44
+ <%= render 'user_options', :wholesaler => wholesaler %>
45
+ <% end %>
46
+ </td>
47
+ </tr>
48
+ <% end %>
49
+ </tbody>
50
+ </table>
51
+
52
+ <%= will_paginate(:previous_label => "&#171; #{t('previous')}", :next_label => "#{t('next')} &#187;") %>
53
+
54
+
55
+ <% content_for :sidebar do %>
56
+ <div class="box">
57
+ <h3><%= t(:search) %></h3>
58
+ <%= form_for @search do |f| %>
59
+ <%- locals = {:f => f} %>
60
+ <%= hook :admin_wholesalers_index_search, locals do %>
61
+ <p>
62
+ <%= t(".company") %><br />
63
+ <%= f.text_field :company_contains, :size=>18 %>
64
+ </p>
65
+ <p>
66
+ <%= t(".buyer_contact") %><br />
67
+ <%= f.text_field :buyer_contact_contains, :size=>18 %>
68
+ </p>
69
+ <p>
70
+ <%= t(".manager_contact") %><br />
71
+ <%= f.text_field :manager_contact_contains, :size=>18 %>
72
+ </p>
73
+ <p>
74
+ <%= t("phone") %><br />
75
+ <%= f.text_field :phone_contains, :size=>18 %>
76
+ </p>
77
+ <p>
78
+ <%= t(".notes") %><br />
79
+ <%= f.text_field :notes_contains, :size=>18 %>
80
+ </p>
81
+
82
+ <% end %>
83
+ <%= hook :admin_wholesalers_index_search_buttons, locals do %>
84
+ <p><%= button t("search") %></p>
85
+ <% end %>
86
+ <% end %>
87
+ </div>
88
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <%= hook :admin_wholesaler_new_form_header do %>
2
+ <h1><%= t("new_wholesaler") %></h1>
3
+ <% end %>
4
+
5
+ <%= hook :admin_wholesaler_new_form do %>
6
+ <%= form_for(:wholesaler, :url => collection_url) do |f| %>
7
+ <%= render :partial => "form", :locals => { :f => f } %>
8
+
9
+ <%= hook :admin_wholesaler_new_form_buttons do %>
10
+ <%= render :partial => "admin/shared/new_resource_links" %>
11
+ <% end %>
12
+ <% end %>
13
+ <% end %>
@@ -0,0 +1,68 @@
1
+ <h1><%= t("wholesaler_account") %></h1>
2
+
3
+ <div class="leftie">
4
+
5
+ <h5>Company:</h5>
6
+ <h3><%= @wholesaler.company %></h3>
7
+
8
+ <h5>Buyer_contact:</h5>
9
+ <h3><%= @wholesaler.buyer_contact %></h3>
10
+
11
+ <h5>Manager_contact:</h5>
12
+ <h3><%= @wholesaler.manager_contact %></h3>
13
+
14
+ <h5>Phone:</h5>
15
+ <h3><%= @wholesaler.phone %></h3>
16
+
17
+ <h5>Fax:</h5>
18
+ <h3><%= @wholesaler.fax %></h3>
19
+
20
+ <h5>Resale_number:</h5>
21
+ <h3><%= @wholesaler.resale_number %></h3>
22
+
23
+ <h5>Taxid:</h5>
24
+ <h3><%= @wholesaler.taxid %></h3>
25
+
26
+ <h5>Web_address:</h5>
27
+ <h3><%= @wholesaler.web_address %></h3>
28
+
29
+ <h5>Terms:</h5>
30
+ <h3><%= @wholesaler.terms %></h3>
31
+
32
+ <h5>Notes:</h5>
33
+ <h3><%= simple_format @wholesaler.notes %></h3>
34
+
35
+ </div>
36
+
37
+ <div class="rightie">
38
+
39
+ <div class="adr">
40
+ <h4><%= t("bill_address") %></h4>
41
+ <%= render 'admin/shared/address', :address => @wholesaler.bill_address %>
42
+ </div>
43
+ <div class="adr">
44
+ <h4><%= t("ship_address") %></h4>
45
+ <%= render 'admin/shared/address', :address => @wholesaler.ship_address %>
46
+ </div>
47
+
48
+ <div class="adr">
49
+ <h4><%= t("user_details") %></h4>
50
+ <p>
51
+ ID: <%= @wholesaler.user.id %>
52
+ <br/>
53
+ Email: <%= @wholesaler.user.email %>
54
+ <br/>
55
+ <%= link_to "view user", admin_user_path(@wholesaler.user) %> /
56
+ <%= link_to "edit user", edit_admin_user_path(@wholesaler.user) %> /
57
+ <%= render "user_options", :user => @wholesaler.user %>
58
+ </p>
59
+ </div>
60
+
61
+ </div>
62
+
63
+ <hr/>
64
+
65
+ <p>
66
+ <%= link_to_edit @wholesaler %> <%= t('or') %>
67
+ <%= link_to t('back'), collection_url %>
68
+ </p>
@@ -0,0 +1,3 @@
1
+ <h1><%= t('wholesalers') %></h1>
2
+
3
+ <p>Aenean facilisis nulla vitae urna tincidunt congue sed ut dui. Morbi malesuada nulla nec purus convallis consequat. Vivamus id mollis quam. Morbi ac commodo nulla. In condimentum orci id nisl volutpat bibendum. Quisque commodo hendrerit lorem quis egestas. Maecenas quis tortor arcu. Vivamus rutrum nunc non neque consectetur quis placerat neque lobortis. Nam vestibulum, arcu sodales feugiat consectetur, nisl orci bibendum elit, eu euismod magna sapien ut nibh. Donec semper quam scelerisque tortor dictum gravida. In hac habitasse platea dictumst. Nam pulvinar, odio sed rhoncus suscipit, sem diam ultrices mauris, eu consequat purus metus eu velit. Proin metus odio, aliquam eget molestie nec, gravida ut sapien. Phasellus quis est sed turpis sollicitudin venenatis sed eu odio. Praesent eget neque eu eros interdum malesuada non vel leo. Sed fringilla porta ligula egestas tincidunt. Nullam risus magna, ornare vitae varius eget, scelerisque a libero. Morbi eu porttitor ipsum. Nullam lorem nisi, posuere quis volutpat eget, luctus nec massa. Pellentesque aliquam lacinia tellus sit amet bibendum. Ut posuere justo in enim pretium scelerisque. Etiam ornare vehicula euismod. Vestibulum at risus augue. Sed non semper dolor. Sed fringilla consequat.</p>
@@ -0,0 +1,77 @@
1
+ <% address ||= @address %>
2
+ <% billing ||= false %>
3
+
4
+ <p>
5
+ <%= form.label :firstname, t(billing ? 'billing_firstname' : 'shipping_firstname') %><br/>
6
+ <%= form.text_field :firstname, :class => 'required' %><span class="req">*</span>
7
+ </p>
8
+ <p>
9
+ <%= form.label :lastname, t(billing ? 'billing_lastname' : 'shipping_lastname') %><br/>
10
+ <%= form.text_field :lastname %>
11
+ </p>
12
+ <p>
13
+ <%= form.label :address1, t(:street_address) %><br/>
14
+ <%= form.text_field :address1, :class => 'required' %><span class="req">*</span>
15
+ </p>
16
+ <p>
17
+ <%= form.label :address2, t(:street_address_2) %><br/>
18
+ <%= form.text_field :address2 %>
19
+ </p>
20
+ <p>
21
+ <%= form.label :city, t(:city) %><br/>
22
+ <%= form.text_field :city, :class => 'required' %><span class="req">*</span>
23
+ </p>
24
+ <% if Spree::Config[:address_requires_state] %>
25
+ <p>
26
+ <span id="bstate">
27
+ <% have_states = !address.country.states.empty? %>
28
+ <%= form.label :state, t(:state) %><br/>
29
+ <noscript>
30
+ <%= form.text_field :state_name, :class => 'required' %>
31
+ </noscript>
32
+ <% state_elements = [
33
+ form.collection_select(:state_id, address.country.states,
34
+ :id, :name,
35
+ {:include_blank => true},
36
+ {:class => have_states ? "required" : "hidden",
37
+ :disabled => !have_states}) +
38
+ form.text_field(:state_name,
39
+ :class => !have_states ? "required" : "hidden",
40
+ :disabled => have_states)
41
+ ].join.gsub('"', "'").gsub("\n", "")
42
+ %>
43
+ <script type="text/javascript" language="javascript" charset="utf-8">
44
+ // <![CDATA[
45
+ document.write("<%= raw state_elements %>");
46
+ // ]]>
47
+ </script>
48
+ </span>
49
+ <span class="req">*</span>
50
+ </p>
51
+ <% end %>
52
+ <p>
53
+ <%= form.label :zipcode, t(:zip) %><br/>
54
+ <%= form.text_field :zipcode, :class => 'required' %><span class="req">*</span>
55
+ </p>
56
+ <p>
57
+ <%= form.label :country_id, t(:country) %><br/>
58
+ <span id="bcountry"><%= form.collection_select :country_id, Country.all, :id, :name, {}, {:class => 'required'} %></span>
59
+ <span class="req">*</span>
60
+ </p>
61
+ <p>
62
+ <%= form.label :phone, t(:phone) %><br/>
63
+ <%= form.text_field :phone, :class => 'required' %><span class="req">*</span>
64
+ </p>
65
+ <% if Spree::Config[:alternative_billing_phone] %>
66
+ <p>
67
+ <%= form.label :alternative_phone, t(:alternative_phone) %><br/>
68
+ <%= form.text_field :alternative_phone %>
69
+ </p>
70
+ <% end %>
71
+ <% if billing %>
72
+ <p class="field checkbox">
73
+ <label for="wholesaler_use_billing">
74
+ <%= check_box_tag 'wholesaler[use_billing]', '1', (!(@wholesaler.bill_address.nil? && @wholesaler.ship_address.nil?) && @wholesaler.bill_address.eql?(@wholesaler.ship_address)) %> <%= t(".use_for_shipping") %>
75
+ </label>
76
+ </p>
77
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <li><%= link_to t("home") , root_path %></li>
2
+ <li><%= link_to t("wholesalers") , wholesalers_path %></li>
3
+ <li class="cart-indicator"><%= link_to_cart %></li>
4
+
@@ -0,0 +1,91 @@
1
+ <fieldset class="leftie">
2
+
3
+ <fieldset>
4
+ <legend>User</legend>
5
+ <%= fields_for :user, @user do |uf| %>
6
+ <%= render "shared/error_messages", :target => @user %>
7
+ <%= render 'shared/user_form', :f => uf %>
8
+ <% end %>
9
+ </fieldset>
10
+
11
+ <fieldset>
12
+ <legend>Company Information</legend>
13
+ <%= render "shared/error_messages", :target => @wholesaler %>
14
+ <p>
15
+ <%= form.label :company %><br/>
16
+ <%= form.text_field :company, :class => 'required' %><span class="req">*</span>
17
+ </p>
18
+ <p>
19
+ <%= form.label :buyer_contact %><br/>
20
+ <%= form.text_field :buyer_contact, :class => 'required' %><span class="req">*</span>
21
+ </p>
22
+ <p>
23
+ <%= form.label :manager_contact %><br/>
24
+ <%= form.text_field :manager_contact, :class => 'required' %><span class="req">*</span>
25
+ </p>
26
+ <p>
27
+ <%= form.label :phone %><br/>
28
+ <%= form.text_field :phone, :class => 'required' %><span class="req">*</span>
29
+ </p>
30
+ <p>
31
+ <%= form.label :fax %><br/>
32
+ <%= form.text_field :fax, :class => 'required' %><span class="req">*</span>
33
+ </p>
34
+ <p>
35
+ <%= form.label :resale_number %><br/>
36
+ <%= form.text_field :resale_number, :class => 'required' %><span class="req">*</span>
37
+ </p>
38
+ <p>
39
+ <%= form.label :taxid %><br/>
40
+ <%= form.text_field :taxid, :class => 'required' %><span class="req">*</span>
41
+ </p>
42
+ <p>
43
+ <%= form.label :web_address %><br/>
44
+ <%= form.text_field :web_address, :class => 'required' %><span class="req">*</span>
45
+ </p>
46
+ <p>
47
+ <%= form.label :terms %><br/>
48
+ <%= form.select :terms, Wholesaler.term_options, :class => 'required' %><span class="req">*</span>
49
+ </p>
50
+ </fieldset>
51
+ </fieldset>
52
+
53
+ <fieldset class="rightie">
54
+
55
+
56
+
57
+ <br/>
58
+
59
+ <fieldset>
60
+ <legend>Billing Address</legend>
61
+ <%= fields_for :bill_address, @bill_address do |af| %>
62
+ <%= render "shared/error_messages", :target => @bill_address %>
63
+ <%= render 'shared/address_form', :form => af, :address => @bill_address, :billing => true %>
64
+ <% end %>
65
+ </fieldset>
66
+
67
+ <fieldset id="fields_ship_address">
68
+ <legend>Shipping Address</legend>
69
+ <%= fields_for :ship_address, @ship_address do |af| %>
70
+ <%= render "shared/error_messages", :target => @ship_address %>
71
+ <%= render 'shared/address_form', :form => af, :address => @ship_address %>
72
+ <% end %>
73
+ </fieldset>
74
+
75
+ <p class="action">
76
+ <%= form.submit t("wholesale_apply"), :class => 'button' %>
77
+ </p>
78
+
79
+ </fieldset>
80
+
81
+ <br class="clear"/>
82
+
83
+ <script type="text/javascript">
84
+ //<![CDATA[
85
+
86
+ $('#wholesaler_use_billing').change(function(evt) {
87
+ $('#fields_ship_address').css('display', $(this).is(':checked') ? 'none' : 'block');
88
+ }).attr('checked', true).change();
89
+
90
+ //]]>
91
+ </script>
@@ -0,0 +1,21 @@
1
+ <div class="left">
2
+ <%= hook :wholesale_index_content do %>
3
+ <%= render 'hooks/wholesale_static_content' %>
4
+ <% end %>
5
+ </div>
6
+ <div class="right">
7
+ <div class="left">
8
+ <%= hook :wholesale_index_signup do %>
9
+ <h3><%= t('wholesale_apply') %></h3>
10
+ <p>Maecenas quis tortor arcu. Vivamus rutrum nunc non neque consectetur quis placerat neque lobortis. Nam vestibulum, arcu sodales feugiat consectetur, nisl orci bibendum elit, eu euismod magna sapien ut nibh.</p>
11
+ <%= link_to 'Apply Now!', new_wholesaler_path, :class => 'button' %>
12
+ <% end %>
13
+ </div>
14
+ <div class="right">
15
+ <%= hook :wholesale_index_login do %>
16
+ <h3><%= t('wholesale_login') %></h3>
17
+ <%= render 'shared/login' %>
18
+ <% end %>
19
+ </div>
20
+ </div>
21
+
@@ -0,0 +1,8 @@
1
+ <h1>Wholesale Signup</h1>
2
+
3
+ <%= form_for @wholesaler do |form| %>
4
+
5
+ <%= render 'fields', :form => form %>
6
+
7
+
8
+ <% end %>
@@ -1,8 +1,34 @@
1
1
  en:
2
+
3
+ billing_firstname: "Billing First Name"
4
+ billing_lastname: "Billing Last Name"
5
+ shipping_firstname: "Shipping First Name"
6
+ shipping_lastname: "Shipping Last Name"
7
+
8
+ buyer_contact: "Buyer Contact"
9
+
2
10
  wholesale: "Wholesale"
11
+ wholesaler: "Wholesaler"
12
+ wholesalers: "Wholesalers"
13
+ new_wholesaler: "New Wholesaler"
14
+ editing_wholesaler: "Edit Wholesaler"
15
+ wholesaler_account: "Wholesaler Account"
16
+ listing_wholesalers: "Listing Wholesaler"
17
+ wholesale_login: "Wholesale Login"
18
+ wholesale_apply: "Apply for a wholesale account"
19
+
20
+
21
+
22
+
23
+ shared:
24
+ address_form:
25
+ use_for_shipping: "Use billing address for shipping"
26
+
3
27
  wholesale_customer: "Wholesale Customer ID: #%{id}"
28
+
4
29
 
5
30
  admin:
31
+
6
32
  hooks:
7
33
  product_form_right:
8
34
  master_wholesale_price: "Master Wholesale Price"
@@ -12,4 +38,22 @@ en:
12
38
  variants:
13
39
  form:
14
40
  wholesale_price: "Wholesale Price"
15
-
41
+
42
+
43
+ wholesalers:
44
+ index:
45
+ company: "Company"
46
+ buyer_contact: "Buyer contact"
47
+ manager_contact: "Manager contact"
48
+ notes: "Notes"
49
+ form:
50
+ company: "Company"
51
+ buyer_contact: "Buyer contact"
52
+ manager_contact: "Manager contact"
53
+ phone: "Phone"
54
+ fax: "Fax"
55
+ resale_number: "Resale number"
56
+ taxid: "Taxid"
57
+ web_address: "Web address"
58
+ terms: "Terms"
59
+ notes: "Notes"