refinerycms-stores 0.0.14 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/Gemfile +12 -12
  2. data/Rakefile +3 -3
  3. data/VERSION +1 -1
  4. data/app/assets/stylesheets/refinery/refinerycms-stores.sass +10 -0
  5. data/app/controllers/refinery/customers/customers_controller.rb +76 -0
  6. data/app/controllers/refinery/orders/orders_controller.rb +1 -0
  7. data/app/controllers/refinery/stores/stores_controller.rb +1 -0
  8. data/app/helpers/refinery/stores/stores_helper.rb +27 -0
  9. data/app/models/refinery/addresses/address.rb +3 -0
  10. data/app/models/refinery/customers/customer.rb +17 -0
  11. data/app/models/refinery/orders/order.rb +2 -1
  12. data/app/views/refinery/customers/edit.html.haml +17 -0
  13. data/app/views/refinery/customers/new.html.haml +17 -0
  14. data/app/views/refinery/products/products/show.html.haml +38 -0
  15. data/app/views/refinery/stores/stores/_cart.html.haml +20 -0
  16. data/app/views/refinery/stores/stores/_cart_item.html.haml +9 -0
  17. data/app/views/refinery/stores/stores/_customer_head.html.haml +12 -0
  18. data/app/views/refinery/stores/stores/_list_product.html.haml +11 -0
  19. data/app/views/refinery/stores/stores/index.html.haml +6 -0
  20. data/app/views/refinery/stores/stores/show.html.haml +14 -0
  21. data/config/locales/en.yml +23 -0
  22. data/config/locales/es.yml +24 -0
  23. data/config/locales/fr.yml +23 -0
  24. data/config/locales/nb.yml +24 -0
  25. data/config/locales/nl.yml +24 -0
  26. data/config/routes.rb +17 -11
  27. data/db/migrate/6_create_customers_customers.rb +22 -0
  28. data/lib/refinery/customers.rb +21 -0
  29. data/lib/refinery/customers/engine.rb +31 -0
  30. data/lib/refinerycms-stores.rb +1 -0
  31. data/refinerycms-stores.gemspec +21 -445
  32. metadata +37 -1612
  33. data/Gemfile.lock +0 -338
  34. data/app/views/refinery/products/products/show.html.erb +0 -76
  35. data/app/views/refinery/stores/stores/_cart.html.erb +0 -22
  36. data/app/views/refinery/stores/stores/_cart_item.html.erb +0 -9
  37. data/app/views/refinery/stores/stores/_list_product.html.erb +0 -16
  38. data/app/views/refinery/stores/stores/index.html.erb +0 -11
  39. data/app/views/refinery/stores/stores/show.html.erb +0 -29
data/Gemfile CHANGED
@@ -1,24 +1,24 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gemspec
3
+ # gemspec
4
4
 
5
- gem 'refinerycms', '~> 2.0.0'
6
-
7
- gem 'jquery-rails'
5
+ gem 'refinerycms', '>= 2.0.0'
8
6
 
9
7
  group :development, :test do
10
- gem 'refinerycms-testing', '~> 2.0.0'
11
- gem 'factory_girl_rails'
12
- gem 'generator_spec'
13
- gem 'jeweler'
14
- gem 'simplecov'
8
+ # gem 'refinerycms-testing', '~> 2.0.0'
9
+ # gem 'factory_girl_rails'
10
+ # gem 'generator_spec'
11
+ # gem 'simplecov'
15
12
 
16
- gem 'rb-inotify', '>= 0.5.1'
17
- gem 'libnotify', '~> 0.1.3'
18
- gem 'therubyracer'
13
+ # gem 'rb-inotify', '>= 0.5.1'
14
+ # gem 'libnotify', '~> 0.1.3'
15
+ # gem 'therubyracer'
16
+
17
+ gem 'jeweler'
19
18
 
20
19
  end # group do
21
20
 
21
+ gem 'jquery-rails'
22
22
  gem 'aasm', '>3.0'
23
23
  gem 'hpricot'
24
24
  gem 'ruby_parser'
data/Rakefile CHANGED
@@ -34,7 +34,7 @@ Jeweler::Tasks.new do |gem|
34
34
  gem.homepage = "http://github.com/dsaronin@gmail.com/refinerycms-stores"
35
35
  gem.license = "MIT"
36
36
  gem.summary = %Q{refinerycms shopping cart engine}
37
- gem.description = %Q{Complete engine for shopping cart to be used with a RefineryCMS project}
37
+ gem.description = %Q{Complete engine for Stripe gateway-based shopping cart to be used with a RefineryCMS project}
38
38
  gem.email = "dsaronin@gmail.com"
39
39
  gem.authors = ["Daudi Amani"]
40
40
  # dependencies defined in Gemfile
@@ -48,8 +48,8 @@ Rake::TestTask.new(:test) do |test|
48
48
  test.verbose = true
49
49
  end
50
50
 
51
- require 'simplecov'
52
- SimpleCov.start 'rails'
51
+ # require 'simplecov'
52
+ # SimpleCov.start 'rails'
53
53
 
54
54
  task :default => :test
55
55
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.14
1
+ 0.0.16
@@ -77,4 +77,14 @@ table.product-header
77
77
  align: right
78
78
  border: outset 2px lightgray
79
79
 
80
+ #customer-profile
81
+ font-size: small
82
+
83
+ .customer-actions
84
+ a
85
+ font-color: blue
86
+
87
+ a:hover
88
+ background: #c3c3c3
89
+ text-decoration: underline
80
90
 
@@ -0,0 +1,76 @@
1
+ module Refinery
2
+ module Customers
3
+ class CustomersController < ApplicationController
4
+
5
+ crudify :customer
6
+
7
+ before_filter :authenticate_refinery_user!, :get_customer, :except => [:new, :create]
8
+
9
+ def new
10
+ @customer = Customer.new
11
+ end
12
+
13
+ # GET /customers/:id/edit
14
+ def edit
15
+ end
16
+
17
+ # PUT /customers/:id
18
+ def update
19
+
20
+ if params[:customer][:password].blank? and params[:customer][:password_confirmation].blank?
21
+ params[:customer].delete(:password)
22
+ params[:customer].delete(:password_confirmation)
23
+ end
24
+
25
+ # keep these the same
26
+ params[:customer][:username] = params[:customer][:email]
27
+
28
+ if @customer.update_attributes(params[:customer])
29
+ flash[:notice] = t('successful', :scope => 'customers.update', :email => @customer.email)
30
+ redirect_to root_path
31
+
32
+ else
33
+ render :action => 'edit'
34
+ end
35
+
36
+ end
37
+
38
+ def create
39
+ @customer = Customer.new(params[:customer])
40
+ @customer.username = @customer.email
41
+
42
+ if @customer.save
43
+ @customer.roles << ::Refinery::Role[:customer] # remember as a customer role
44
+
45
+ redirect_to root_path
46
+
47
+ else
48
+ @customer.errors.delete(:username) # this is set to email
49
+ render :action => :new
50
+
51
+ end
52
+
53
+ end
54
+
55
+ protected
56
+
57
+ def redirect?
58
+ if refinery_current_user.nil?
59
+ redirect_to new_refinery_user_session_path
60
+ end
61
+ end
62
+
63
+ # ----------------------------------------------------------------------
64
+ # get_customer -- returns @customer else error if cur_user mismatch
65
+ # ----------------------------------------------------------------------
66
+ def get_customer()
67
+ if params[:id] != refinery_current_user.id
68
+ error_404
69
+ else
70
+ @customer = Customer.find(params[:id])
71
+ end
72
+ end
73
+
74
+ end # class
75
+ end # module Customers
76
+ end # module Refinery
@@ -6,6 +6,7 @@ module Refinery
6
6
  # ensure user registration unless anon orders okay
7
7
  # ensure state machine transitions
8
8
 
9
+ before_filter :authenticate_refinery_user!
9
10
  before_filter :find_all_orders, :only => :index
10
11
  before_filter :find_order, :except => :index
11
12
  before_filter :setup_payment_gateway, :only => [:edit, :update, :purchase, :re_edit]
@@ -2,6 +2,7 @@ module Refinery
2
2
  module Stores
3
3
  class StoresController < ::Refinery::StoresApplicationController
4
4
 
5
+ before_filter :authenticate_refinery_user!, :only => :checkout
5
6
  before_filter :find_first_store, :only => :index
6
7
  before_filter :find_store, :only => :show
7
8
  before_filter :find_page, :except => [:index, :add_to_cart, :empty_cart, :checkout]
@@ -0,0 +1,27 @@
1
+ module Refinery
2
+ module Stores
3
+ module StoresHelper
4
+
5
+ def pretty_customer_name( )
6
+ user = refinery_current_user # might raise exception
7
+
8
+ name = ( user.billing_address.nil? ?
9
+ user.username :
10
+ user.billing_address.first_name )
11
+ return "Hi #{name}!"
12
+
13
+ rescue NameError
14
+ return "please signin"
15
+ end
16
+
17
+ def is_user_signed_in?()
18
+
19
+ return refinery_current_user
20
+
21
+ rescue NameError
22
+ return nil
23
+ end
24
+
25
+ end # module StoresHelper
26
+ end # module Stores
27
+ end # module Refinery
@@ -6,6 +6,9 @@ module Refinery
6
6
 
7
7
  validates :first_name, :presence => true
8
8
  validates :last_name, :presence => true
9
+
10
+ belongs_to :order, :class_name => ::Refinery::Orders::Order
11
+ belongs_to :customer, :class_name => ::Refinery::Customers::Customer
9
12
 
10
13
  end
11
14
  end
@@ -0,0 +1,17 @@
1
+ module Refinery
2
+ module Customers
3
+ class Customer < ::Refinery::User
4
+
5
+ has_many :addresses, :class_name => ::Refinery::Addresses::Address
6
+ has_many :orders, :class_name => ::Refinery::Orders::Order, :foreign_key => :order_customer_id
7
+
8
+ has_one :billing_address, :class_name => ::Refinery::Addresses::Address,
9
+ :conditions => { :is_billing => true, :order_id => nil }
10
+
11
+ has_one :shipping_address, :class_name => ::Refinery::Addresses::Address,
12
+ :conditions => { :is_billing => false, :order_id => nil }
13
+
14
+
15
+ end
16
+ end
17
+ end
@@ -14,7 +14,8 @@ module Refinery
14
14
  has_many :addresses, :class_name => ::Refinery::Addresses::Address
15
15
  has_many :line_items
16
16
 
17
- # belongs_to :customer
17
+ belongs_to :customer, :class_name => ::Refinery::Customers::Customer, :foreign_key => :order_customer_id
18
+
18
19
  # belongs_to :shipping_type
19
20
  # belongs_to :discount
20
21
  # belongs_to :shipping_vendor
@@ -0,0 +1,17 @@
1
+ - content_for :header, t('pick_new_password_for', :scope => 'refinery.users.reset', :email => @refinery_user.email)
2
+ = form_for resource, :as => resource_name, |
3
+ :url => refinery.refinery_customers_customer_path, |
4
+ :html => { :method => :put } do |f| |
5
+ = render '/refinery/admin/error_messages', :object => @refinery_user, :include_object_name => true
6
+ .field
7
+ = f.label :password
8
+ = f.password_field :password, :class => 'larger widest'
9
+ .field
10
+ = f.label :password_confirmation
11
+ = f.password_field :password_confirmation, :class => 'larger widest'
12
+ = render '/refinery/admin/form_actions', :f => f, |
13
+ :continue_editing => false, |
14
+ :submit_button_text => t('reset_password', :scope => 'refinery.users.reset'), |
15
+ :cancel_url => refinery.new_refinery_user_session_path, |
16
+ :cancel_title => nil, |
17
+ :hide_delete => true |
@@ -0,0 +1,17 @@
1
+ - content_for :header, t('there_are_no_users', :scope => 'refinery.welcome')
2
+ = form_for :user, :url => refinery.refinery_customers_customer_path do |f|
3
+ = render '/refinery/admin/error_messages', :object => @user, :include_object_name => true
4
+ .field
5
+ = f.label :email
6
+ = f.text_field :email, :class => 'larger widest'
7
+ .field
8
+ = f.label :password
9
+ = f.password_field :password, :class => 'larger widest'
10
+ .field
11
+ = f.label :password_confirmation
12
+ = f.password_field :password_confirmation, :class => 'larger widest'
13
+ = render '/refinery/admin/form_actions', :f => f, |
14
+ :submit_continue => false, |
15
+ :submit_button_text => t('sign_up', :scope => 'refinery.users.new'), |
16
+ :hide_delete => true, |
17
+ :hide_cancel => true |
@@ -0,0 +1,38 @@
1
+ - content_for :body_content_title do
2
+ = @product.name
3
+ - content_for :body_content_left do
4
+ %section#product
5
+ .product_show
6
+ .product_photo
7
+ - if @product.main_pic_id
8
+ = image_fu @product.main_pic, Refinery::Images.user_image_sizes[:large], :class => "product-pic", :alt => @product.name
9
+ - else
10
+ \&nbsp;
11
+ .product_text
12
+ %h1
13
+ = @product.name
14
+ %p
15
+ = raw @product.description
16
+ .product_spec
17
+ .product_code
18
+ %p
19
+ code: #{@product.code}
20
+ %br/
21
+ size:
22
+ \#{number_with_precision(@product.size_width, :precision => 1)} x
23
+ \#{number_with_precision(@product.size_height, :precision => 1)} x
24
+ \#{number_with_precision(@product.size_depth, :precision => 1)}
25
+ %br/
26
+ weight:
27
+ \#{number_with_precision(@product.weight, :precision => 1)} lbs
28
+ - unless @product.digital_download_id.blank?
29
+ %i digital download
30
+ .product_pricebuy
31
+ %h2
32
+ = number_to_currency(@product.price)
33
+ .product-action
34
+ = button_to( "add to cart", refinery.add_to_cart_stores_stores_path(:id => @product), :class => "add-to-cart" )
35
+ - content_for :body_content_right do
36
+ %aside
37
+ = render( :partial => "refinery/stores/stores/cart", :object => @cart )
38
+ = render '/refinery/content_page'
@@ -0,0 +1,20 @@
1
+ = render "refinery/stores/stores/customer_head"
2
+
3
+ #cart
4
+ .cart-title
5
+ %h3
6
+ = cart.store_name
7
+ Cart
8
+ - if cart.items.empty?
9
+ %p
10
+ %i Your cart is empty; click add-to-cart to add products.
11
+ %table
12
+ = render(:partial => "refinery/stores/stores/cart_item", :collection => cart.items)
13
+ %tr.total-line
14
+ %td{:colspan => "2"} Total
15
+ %td.total-cell= number_to_currency(cart.total_price)
16
+ %tr
17
+ %td
18
+ = button_to( "checkout", refinery.checkout_stores_stores_path(), :class => "checkout-cart" )
19
+ %td
20
+ = button_to( "empty cart", refinery.empty_cart_stores_stores_path(), :class => "empty-cart" )
@@ -0,0 +1,9 @@
1
+ - if cart_item == @current_item
2
+ %tr#current_item
3
+ - else
4
+ %tr
5
+ %td
6
+ = cart_item.quantity
7
+ \&times;
8
+ %td= h(cart_item.name)
9
+ %td.item-price= number_to_currency(cart_item.price)
@@ -0,0 +1,12 @@
1
+ #customer-profile
2
+ .customer-actions
3
+ = pretty_customer_name( )
4
+ &ensp;
5
+ - if is_user_signed_in?
6
+ = link_to( "profile", "#", :title => "update your profile information" )
7
+ &nbsp;
8
+ = link_to( "sign out", "#", :title => "switch customer profile" )
9
+ -else
10
+ = link_to( "sign up", refinery.new_customers_customer_path, :title => "create a new customer profile" )
11
+ &nbsp;
12
+ = link_to( "sign in", refinery.new_refinery_user_session_path, :title => "sign into your customer profile" )
@@ -0,0 +1,11 @@
1
+ %dl
2
+ %dt
3
+ - if list_product.main_pic_id
4
+ = image_fu list_product.main_pic, Refinery::Images.user_image_sizes[:small], :class => "catalog-pic", :alt => list_product.name
5
+ - else
6
+ \&nbsp;
7
+ %dd
8
+ = link_to( ( truncate( list_product.name, :length => 60 ) + " &raquo;" ).html_safe, refinery.products_product_path( list_product ) )
9
+ %br/
10
+ = number_to_currency(list_product.price)
11
+ - # = button_to( "add to cart", refinery.add_to_cart_stores_stores_path(:id => list_product), :class => "add-to-cart" )
@@ -0,0 +1,6 @@
1
+ - content_for :body_content_left do
2
+ %ul#stores
3
+ - @stores.each do |store|
4
+ %li
5
+ = link_to store.name, refinery.stores_store_path(store)
6
+ = render '/refinery/content_page'
@@ -0,0 +1,14 @@
1
+ - content_for :stylesheets, stylesheet_link_tag('refinery/refinerycms-stores')
2
+ - content_for :body_content_title do
3
+ = @store.name
4
+ - content_for :body_content_left do
5
+ %section
6
+ %h1
7
+ = @store.name
8
+ = raw @store.description
9
+ %section.catalog-brief-list
10
+ = render :partial => "list_product", :collection => @store.active_products
11
+ - content_for :body_content_right do
12
+ %aside
13
+ = render( :partial => "cart", :object => @cart )
14
+ = render "/refinery/content_page"
@@ -1,6 +1,8 @@
1
1
  en:
2
2
  refinery:
3
3
  plugins:
4
+ customers:
5
+ title: Customers
4
6
  addresses:
5
7
  title: Addresses
6
8
  orders:
@@ -9,6 +11,25 @@ en:
9
11
  title: Products
10
12
  stores:
11
13
  title: Stores
14
+ customers:
15
+ admin:
16
+ customers:
17
+ actions:
18
+ create_new: Add New Customer
19
+ reorder: Reorder Customers
20
+ reorder_done: Done Reordering Customers
21
+ records:
22
+ title: Customers
23
+ sorry_no_results: Sorry! There are no results found.
24
+ no_items_yet: There are no Customers yet. Click "Add New Customer" to
25
+ add your first customer.
26
+ customer:
27
+ view_live_html: View this customer live <br/><em>(opens in a new window)</em>
28
+ edit: Edit this customer
29
+ delete: Remove this customer forever
30
+ customers:
31
+ show:
32
+ other: Other Customers
12
33
  addresses:
13
34
  admin:
14
35
  addresses:
@@ -91,6 +112,8 @@ en:
91
112
  other: Other Stores
92
113
  activerecord:
93
114
  attributes:
115
+ refinery/customers/customer:
116
+ name: Name
94
117
  refinery/addresses/address:
95
118
  customer: Customer
96
119
  order: Order