refinerycms-stores 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +26 -0
- data/Gemfile.lock +306 -0
- data/Guardfile +27 -0
- data/LICENSE.txt +20 -0
- data/Rakefile +65 -0
- data/VERSION +1 -0
- data/app/assets/stylesheets/refinery/refinerycms-stores.sass +76 -0
- data/app/controllers/refinery/addresses/admin/addresses_controller.rb +12 -0
- data/app/controllers/refinery/orders/admin/orders_controller.rb +12 -0
- data/app/controllers/refinery/orders/orders_controller.rb +96 -0
- data/app/controllers/refinery/products/admin/products_controller.rb +12 -0
- data/app/controllers/refinery/products/products_controller.rb +17 -0
- data/app/controllers/refinery/stores/admin/stores_controller.rb +12 -0
- data/app/controllers/refinery/stores/stores_controller.rb +80 -0
- data/app/helpers/refinery/orders/orders_helper.rb +11 -0
- data/app/models/refinery/addresses/address.rb +12 -0
- data/app/models/refinery/orders/line_item.rb +24 -0
- data/app/models/refinery/orders/order.rb +364 -0
- data/app/models/refinery/products/product.rb +17 -0
- data/app/models/refinery/stores/store.rb +33 -0
- data/app/views/refinery/addresses/admin/addresses/_actions.html.erb +25 -0
- data/app/views/refinery/addresses/admin/addresses/_address.html.erb +16 -0
- data/app/views/refinery/addresses/admin/addresses/_addresses.html.erb +2 -0
- data/app/views/refinery/addresses/admin/addresses/_form.html.erb +89 -0
- data/app/views/refinery/addresses/admin/addresses/_records.html.erb +18 -0
- data/app/views/refinery/addresses/admin/addresses/_sortable_list.html.erb +5 -0
- data/app/views/refinery/addresses/admin/addresses/edit.html.erb +1 -0
- data/app/views/refinery/addresses/admin/addresses/index.html.erb +7 -0
- data/app/views/refinery/addresses/admin/addresses/new.html.erb +1 -0
- data/app/views/refinery/orders/admin/orders/_actions.html.erb +25 -0
- data/app/views/refinery/orders/admin/orders/_form.html.erb +122 -0
- data/app/views/refinery/orders/admin/orders/_order.html.erb +20 -0
- data/app/views/refinery/orders/admin/orders/_orders.html.erb +2 -0
- data/app/views/refinery/orders/admin/orders/_records.html.erb +18 -0
- data/app/views/refinery/orders/admin/orders/_sortable_list.html.erb +5 -0
- data/app/views/refinery/orders/admin/orders/edit.html.erb +1 -0
- data/app/views/refinery/orders/admin/orders/index.html.erb +7 -0
- data/app/views/refinery/orders/admin/orders/new.html.erb +1 -0
- data/app/views/refinery/orders/orders/_address_form.html.haml +35 -0
- data/app/views/refinery/orders/orders/_card_form.html.haml +63 -0
- data/app/views/refinery/orders/orders/_order_snapshot.html.haml +44 -0
- data/app/views/refinery/orders/orders/confirmation.html.haml +26 -0
- data/app/views/refinery/orders/orders/edit.html.haml +36 -0
- data/app/views/refinery/orders/orders/index.html.haml +6 -0
- data/app/views/refinery/orders/orders/purchase.html.haml +25 -0
- data/app/views/refinery/orders/orders/show.html.haml +36 -0
- data/app/views/refinery/products/admin/products/_actions.html.erb +25 -0
- data/app/views/refinery/products/admin/products/_form.html.erb +127 -0
- data/app/views/refinery/products/admin/products/_product.html.erb +20 -0
- data/app/views/refinery/products/admin/products/_products.html.erb +2 -0
- data/app/views/refinery/products/admin/products/_records.html.erb +18 -0
- data/app/views/refinery/products/admin/products/_sortable_list.html.erb +5 -0
- data/app/views/refinery/products/admin/products/edit.html.erb +4 -0
- data/app/views/refinery/products/admin/products/index.html.erb +10 -0
- data/app/views/refinery/products/admin/products/new.html.erb +4 -0
- data/app/views/refinery/products/products/show.html.erb +105 -0
- data/app/views/refinery/stores/admin/stores/_actions.html.erb +57 -0
- data/app/views/refinery/stores/admin/stores/_form.html.erb +56 -0
- data/app/views/refinery/stores/admin/stores/_records.html.erb +18 -0
- data/app/views/refinery/stores/admin/stores/_sortable_list.html.erb +5 -0
- data/app/views/refinery/stores/admin/stores/_store.html.erb +20 -0
- data/app/views/refinery/stores/admin/stores/_stores.html.erb +2 -0
- data/app/views/refinery/stores/admin/stores/edit.html.erb +4 -0
- data/app/views/refinery/stores/admin/stores/index.html.erb +13 -0
- data/app/views/refinery/stores/admin/stores/new.html.erb +4 -0
- data/app/views/refinery/stores/stores/_cart.html.erb +22 -0
- data/app/views/refinery/stores/stores/_cart_item.html.erb +9 -0
- data/app/views/refinery/stores/stores/_list_product.html.erb +16 -0
- data/app/views/refinery/stores/stores/index.html.erb +11 -0
- data/app/views/refinery/stores/stores/show.html.erb +28 -0
- data/config/locales/en.yml +143 -0
- data/config/locales/es.yml +143 -0
- data/config/locales/fr.yml +139 -0
- data/config/locales/nb.yml +143 -0
- data/config/locales/nl.yml +143 -0
- data/config/routes.rb +81 -0
- data/db/migrate/1_create_stores_stores.rb +29 -0
- data/db/migrate/2_create_products_products.rb +44 -0
- data/db/migrate/3_create_orders_orders.rb +44 -0
- data/db/migrate/4_create_orders_line_items.rb +20 -0
- data/db/migrate/5_create_addresses_addresses.rb +39 -0
- data/db/seeds.rb +23 -0
- data/lib/generators/refinery/stores_generator.rb +17 -0
- data/lib/refinery/addresses/engine.rb +31 -0
- data/lib/refinery/addresses.rb +21 -0
- data/lib/refinery/cart.rb +36 -0
- data/lib/refinery/cart_item.rb +28 -0
- data/lib/refinery/orders/engine.rb +31 -0
- data/lib/refinery/orders.rb +21 -0
- data/lib/refinery/products/engine.rb +31 -0
- data/lib/refinery/products.rb +21 -0
- data/lib/refinery/store_gateway.rb +106 -0
- data/lib/refinery/stores/engine.rb +31 -0
- data/lib/refinery/stores.rb +21 -0
- data/lib/refinerycms-stores.rb +7 -0
- data/lib/tasks/refinery/stores.rake +13 -0
- data/readme.md +10 -0
- data/refinerycms-stores.gemspec +261 -0
- data/spec/models/refinery/addresses/address_spec.rb +18 -0
- data/spec/models/refinery/orders/order_spec.rb +18 -0
- data/spec/models/refinery/products/product_spec.rb +18 -0
- data/spec/models/refinery/stores/store_spec.rb +18 -0
- data/spec/requests/refinery/addresses/admin/addresses_spec.rb +101 -0
- data/spec/requests/refinery/orders/admin/orders_spec.rb +101 -0
- data/spec/requests/refinery/products/admin/products_spec.rb +101 -0
- data/spec/requests/refinery/stores/admin/stores_spec.rb +101 -0
- data/spec/spec_helper.rb +53 -0
- data/spec/support/factories/refinery/addresses.rb +7 -0
- data/spec/support/factories/refinery/orders.rb +7 -0
- data/spec/support/factories/refinery/products.rb +7 -0
- data/spec/support/factories/refinery/stores.rb +7 -0
- data/tasks/rspec.rake +6 -0
- data/tasks/testing.rake +8 -0
- data/test/helper.rb +17 -0
- data/test/test_refinerycms-cart.rb +7 -0
- metadata +571 -0
@@ -0,0 +1,143 @@
|
|
1
|
+
nl:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
addresses:
|
5
|
+
title: Addresses
|
6
|
+
orders:
|
7
|
+
title: Orders
|
8
|
+
products:
|
9
|
+
title: Products
|
10
|
+
stores:
|
11
|
+
title: Stores
|
12
|
+
addresses:
|
13
|
+
admin:
|
14
|
+
addresses:
|
15
|
+
actions:
|
16
|
+
create_new: Maak een nieuwe Address
|
17
|
+
reorder: Wijzig de volgorde van de Addresses
|
18
|
+
reorder_done: Klaar met het wijzingen van de volgorde van de Addresses
|
19
|
+
records:
|
20
|
+
title: Addresses
|
21
|
+
sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
|
22
|
+
no_items_yet: Er zijn nog geen Addresses. Druk op 'Maak een nieuwe Address'
|
23
|
+
om de eerste aan te maken.
|
24
|
+
address:
|
25
|
+
view_live_html: Bekijk deze address op de website <br/><em>(opent een
|
26
|
+
nieuw venster)</em>
|
27
|
+
edit: Bewerk deze address
|
28
|
+
delete: Verwijder deze address voor eeuwig
|
29
|
+
addresses:
|
30
|
+
show:
|
31
|
+
other: Andere Addresses
|
32
|
+
orders:
|
33
|
+
admin:
|
34
|
+
orders:
|
35
|
+
actions:
|
36
|
+
create_new: Maak een nieuwe Order
|
37
|
+
reorder: Wijzig de volgorde van de Orders
|
38
|
+
reorder_done: Klaar met het wijzingen van de volgorde van de Orders
|
39
|
+
records:
|
40
|
+
title: Orders
|
41
|
+
sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
|
42
|
+
no_items_yet: Er zijn nog geen Orders. Druk op 'Maak een nieuwe Order'
|
43
|
+
om de eerste aan te maken.
|
44
|
+
order:
|
45
|
+
view_live_html: Bekijk deze order op de website <br/><em>(opent een nieuw
|
46
|
+
venster)</em>
|
47
|
+
edit: Bewerk deze order
|
48
|
+
delete: Verwijder deze order voor eeuwig
|
49
|
+
orders:
|
50
|
+
show:
|
51
|
+
other: Andere Orders
|
52
|
+
products:
|
53
|
+
admin:
|
54
|
+
products:
|
55
|
+
actions:
|
56
|
+
create_new: Maak een nieuwe Product
|
57
|
+
reorder: Wijzig de volgorde van de Products
|
58
|
+
reorder_done: Klaar met het wijzingen van de volgorde van de Products
|
59
|
+
records:
|
60
|
+
title: Products
|
61
|
+
sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
|
62
|
+
no_items_yet: Er zijn nog geen Products. Druk op 'Maak een nieuwe Product'
|
63
|
+
om de eerste aan te maken.
|
64
|
+
product:
|
65
|
+
view_live_html: Bekijk deze product op de website <br/><em>(opent een
|
66
|
+
nieuw venster)</em>
|
67
|
+
edit: Bewerk deze product
|
68
|
+
delete: Verwijder deze product voor eeuwig
|
69
|
+
products:
|
70
|
+
show:
|
71
|
+
other: Andere Products
|
72
|
+
stores:
|
73
|
+
admin:
|
74
|
+
stores:
|
75
|
+
actions:
|
76
|
+
create_new: Maak een nieuwe Store
|
77
|
+
reorder: Wijzig de volgorde van de Stores
|
78
|
+
reorder_done: Klaar met het wijzingen van de volgorde van de Stores
|
79
|
+
records:
|
80
|
+
title: Stores
|
81
|
+
sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
|
82
|
+
no_items_yet: Er zijn nog geen Stores. Druk op 'Maak een nieuwe Store'
|
83
|
+
om de eerste aan te maken.
|
84
|
+
store:
|
85
|
+
view_live_html: Bekijk deze store op de website <br/><em>(opent een nieuw
|
86
|
+
venster)</em>
|
87
|
+
edit: Bewerk deze store
|
88
|
+
delete: Verwijder deze store voor eeuwig
|
89
|
+
stores:
|
90
|
+
show:
|
91
|
+
other: Andere Stores
|
92
|
+
activerecord:
|
93
|
+
attributes:
|
94
|
+
refinery/addresses/address:
|
95
|
+
customer: Customer
|
96
|
+
order: Order
|
97
|
+
is_billing: Is Billing
|
98
|
+
first_name: First Name
|
99
|
+
last_name: Last Name
|
100
|
+
phone: Phone
|
101
|
+
email: Email
|
102
|
+
address1: Address1
|
103
|
+
address2: Address2
|
104
|
+
city: City
|
105
|
+
state: State
|
106
|
+
zip: Zip
|
107
|
+
country: Country
|
108
|
+
refinery/orders/order:
|
109
|
+
order_number: Order Number
|
110
|
+
order_customer: Order Customer
|
111
|
+
order_status: Order Status
|
112
|
+
order_notes: Order Notes
|
113
|
+
shipping_type: Shipping Type
|
114
|
+
shipped_on: Shipped On
|
115
|
+
product_total: Product Total
|
116
|
+
shipping_charges: Shipping Charges
|
117
|
+
tax_charges: Tax Charges
|
118
|
+
cc_last4: Cc Last4
|
119
|
+
cc_card_type: Cc Card Type
|
120
|
+
cc_expiry_month: Cc Expiry Month
|
121
|
+
cc_expiry_year: Cc Expiry Year
|
122
|
+
cc_token: Cc Token
|
123
|
+
cc_purchased_on: Cc Purchased On
|
124
|
+
refinery/products/product:
|
125
|
+
store: Store
|
126
|
+
name: Name
|
127
|
+
code: Code
|
128
|
+
description: Description
|
129
|
+
date_available: Date Available
|
130
|
+
price: Price
|
131
|
+
size_width: Size Width
|
132
|
+
size_height: Size Height
|
133
|
+
size_depth: Size Depth
|
134
|
+
weight: Weight
|
135
|
+
tax_type: Tax Type
|
136
|
+
digital_download: Digital Download
|
137
|
+
main_pic: Main Pic
|
138
|
+
inactive: Inactive
|
139
|
+
refinery/stores/store:
|
140
|
+
name: Name
|
141
|
+
meta_keywords: Meta Keywords
|
142
|
+
description: Description
|
143
|
+
is_active: Is Active
|
data/config/routes.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
Refinery::Core::Engine.routes.draw do
|
2
|
+
|
3
|
+
# Frontend routes
|
4
|
+
namespace :stores do
|
5
|
+
resources :stores, :only => [:index, :show] do
|
6
|
+
collection do
|
7
|
+
post :add_to_cart
|
8
|
+
post :empty_cart
|
9
|
+
post :checkout
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :orders do
|
16
|
+
resources :orders, :only => [:index, :show, :update, :edit] do
|
17
|
+
member do
|
18
|
+
post :purchase
|
19
|
+
get :cancel_order
|
20
|
+
post :re_edit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
namespace :products do
|
27
|
+
resources :products, :only => [:show]
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
# Admin routes
|
32
|
+
namespace :stores, :path => '' do
|
33
|
+
namespace :admin, :path => 'refinery' do
|
34
|
+
resources :stores, :except => :show do
|
35
|
+
collection do
|
36
|
+
post :update_positions
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Admin routes
|
43
|
+
namespace :products, :path => '' do
|
44
|
+
namespace :admin, :path => 'refinery' do
|
45
|
+
resources :products, :except => :show do
|
46
|
+
collection do
|
47
|
+
post :update_positions
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
# Frontend routes
|
55
|
+
namespace :orders do
|
56
|
+
resources :orders, :path => '', :only => [:index, :show]
|
57
|
+
end
|
58
|
+
|
59
|
+
# Admin routes
|
60
|
+
namespace :orders, :path => '' do
|
61
|
+
namespace :admin, :path => 'refinery' do
|
62
|
+
resources :orders, :except => :show do
|
63
|
+
collection do
|
64
|
+
post :update_positions
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Admin routes
|
71
|
+
namespace :addresses, :path => '' do
|
72
|
+
namespace :admin, :path => 'refinery' do
|
73
|
+
resources :addresses, :except => :show do
|
74
|
+
collection do
|
75
|
+
post :update_positions
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class CreateStoresStores < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
create_table :refinery_stores do |t|
|
5
|
+
t.string :name
|
6
|
+
t.string :meta_keywords
|
7
|
+
t.text :description
|
8
|
+
t.boolean :is_active
|
9
|
+
t.integer :position
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
def down
|
17
|
+
if defined?(::Refinery::UserPlugin)
|
18
|
+
::Refinery::UserPlugin.destroy_all({:name => "refinerycms-stores"})
|
19
|
+
end
|
20
|
+
|
21
|
+
if defined?(::Refinery::Page)
|
22
|
+
::Refinery::Page.delete_all({:link_url => "/stores/stores"})
|
23
|
+
end
|
24
|
+
|
25
|
+
drop_table :refinery_stores
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class CreateProductsProducts < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
create_table :refinery_products do |t|
|
5
|
+
t.references :store, :null => false
|
6
|
+
t.string :name
|
7
|
+
t.string :code, :unique => true, :null => false
|
8
|
+
t.text :description
|
9
|
+
t.datetime :date_available
|
10
|
+
t.integer :quantity
|
11
|
+
t.float :price
|
12
|
+
t.float :size_width
|
13
|
+
t.float :size_height
|
14
|
+
t.float :size_depth
|
15
|
+
t.float :weight
|
16
|
+
t.references :tax_type
|
17
|
+
t.references :digital_download
|
18
|
+
t.references :main_pic
|
19
|
+
t.boolean :inactive, :default => false
|
20
|
+
t.integer :position
|
21
|
+
|
22
|
+
t.timestamps
|
23
|
+
end
|
24
|
+
|
25
|
+
add_index :refinery_products, :store_id
|
26
|
+
add_index :refinery_products, :code
|
27
|
+
add_index :refinery_products, :tax_type_id
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def down
|
32
|
+
if defined?(::Refinery::UserPlugin)
|
33
|
+
::Refinery::UserPlugin.destroy_all({:name => "refinerycms-products"})
|
34
|
+
end
|
35
|
+
|
36
|
+
if defined?(::Refinery::Page)
|
37
|
+
::Refinery::Page.delete_all({:link_url => "/products/products"})
|
38
|
+
end
|
39
|
+
|
40
|
+
drop_table :refinery_products
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class CreateOrdersOrders < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
create_table :refinery_orders do |t|
|
5
|
+
t.integer :order_number, :null => false, :unique => true
|
6
|
+
t.references :order_customer
|
7
|
+
t.string :order_status, :default => '', :null => false
|
8
|
+
t.text :order_notes
|
9
|
+
t.references :shipping_type
|
10
|
+
t.datetime :shipped_on
|
11
|
+
t.float :product_total, :default => 0.0, :limit => 10
|
12
|
+
t.float :shipping_charges, :default => 0.0, :limit => 10
|
13
|
+
t.float :tax_charges, :default => 0.0, :limit => 5
|
14
|
+
t.string :cc_token
|
15
|
+
t.string :cc_last4, :limit => 8
|
16
|
+
t.string :cc_card_type, :limit => 32
|
17
|
+
t.integer :cc_expiry_month
|
18
|
+
t.integer :cc_expiry_year
|
19
|
+
t.datetime :cc_purchased_on
|
20
|
+
t.string :cc_confirmation_id
|
21
|
+
t.integer :position
|
22
|
+
|
23
|
+
t.timestamps
|
24
|
+
end
|
25
|
+
add_index :refinery_orders, :order_customer_id
|
26
|
+
add_index :refinery_orders, :shipping_type_id
|
27
|
+
add_index :refinery_orders, :order_number
|
28
|
+
add_index :refinery_orders, :order_status
|
29
|
+
end
|
30
|
+
|
31
|
+
def down
|
32
|
+
if defined?(::Refinery::UserPlugin)
|
33
|
+
::Refinery::UserPlugin.destroy_all({:name => "refinerycms-orders"})
|
34
|
+
end
|
35
|
+
|
36
|
+
if defined?(::Refinery::Page)
|
37
|
+
::Refinery::Page.delete_all({:link_url => "/orders/orders"})
|
38
|
+
end
|
39
|
+
|
40
|
+
drop_table :refinery_orders
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class CreateOrdersLineItems < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
create_table :refinery_line_items do |t|
|
5
|
+
t.references :order
|
6
|
+
t.references :product
|
7
|
+
t.integer :quantity
|
8
|
+
t.float :unit_price, :default => 0.0, :limit => 10, :null => false
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
add_index :refinery_line_items, :order_id
|
13
|
+
add_index :refinery_line_items, :product_id
|
14
|
+
end
|
15
|
+
|
16
|
+
def down
|
17
|
+
drop_table :refinery_line_items
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class CreateAddressesAddresses < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
create_table :refinery_addresses do |t|
|
5
|
+
t.references :customer
|
6
|
+
t.references :order
|
7
|
+
t.boolean :is_billing, :default => false
|
8
|
+
t.string :first_name, :default => '', :null => false
|
9
|
+
t.string :last_name, :default => '', :null => false
|
10
|
+
t.string :phone
|
11
|
+
t.string :email
|
12
|
+
t.string :address1, :default => '', :null => false
|
13
|
+
t.string :address2
|
14
|
+
t.string :city
|
15
|
+
t.string :state, :default => '', :limit => 32
|
16
|
+
t.string :zip, :default => '', :limit => 32
|
17
|
+
t.string :country, :default => '', :limit => 16, :null => false
|
18
|
+
t.integer :position
|
19
|
+
|
20
|
+
t.timestamps
|
21
|
+
end
|
22
|
+
add_index :refinery_addresses, :customer_id
|
23
|
+
add_index :refinery_addresses, :order_id
|
24
|
+
add_index :refinery_addresses, [:last_name, :first_name]
|
25
|
+
add_index :refinery_addresses, :phone
|
26
|
+
add_index :refinery_addresses, :email
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def down
|
31
|
+
if defined?(::Refinery::UserPlugin)
|
32
|
+
::Refinery::UserPlugin.destroy_all({:name => "refinerycms-addresses"})
|
33
|
+
end
|
34
|
+
|
35
|
+
drop_table :refinery_addresses
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
if defined?(::Refinery::User)
|
2
|
+
::Refinery::User.all.each do |user|
|
3
|
+
if user.plugins.where(:name => 'refinerycms-stores').blank?
|
4
|
+
user.plugins.create(:name => 'refinerycms-stores',
|
5
|
+
:position => (user.plugins.maximum(:position) || -1) +1)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
url = "/stores/stores"
|
12
|
+
if defined?(::Refinery::Page) && ::Refinery::Page.where(:link_url => url).empty?
|
13
|
+
page = ::Refinery::Page.create(
|
14
|
+
:title => 'Stores',
|
15
|
+
:link_url => url,
|
16
|
+
:deletable => false,
|
17
|
+
:menu_match => "^#{url}(\/|\/.+?|)$"
|
18
|
+
)
|
19
|
+
Refinery::Pages.default_parts.each do |default_page_part|
|
20
|
+
page.parts.create(:title => default_page_part, :body => nil)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Refinery
|
2
|
+
class StoresGenerator < Rails::Generators::Base
|
3
|
+
|
4
|
+
def rake_db
|
5
|
+
rake("refinery_stores:install:migrations")
|
6
|
+
end
|
7
|
+
|
8
|
+
def append_load_seed_data
|
9
|
+
create_file 'db/seeds.rb' unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
|
10
|
+
append_file 'db/seeds.rb', :verbose => true do
|
11
|
+
<<-EOH
|
12
|
+
Refinery::Stores::Engine.load_seed
|
13
|
+
EOH
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Refinery
|
2
|
+
module Addresses
|
3
|
+
class Engine < Rails::Engine
|
4
|
+
include Refinery::Engine
|
5
|
+
isolate_namespace Refinery::Addresses
|
6
|
+
|
7
|
+
engine_name :refinery_stores
|
8
|
+
|
9
|
+
initializer "register refinerycms_addresses plugin" do |app|
|
10
|
+
# Refinery::Plugin.register do |plugin|
|
11
|
+
# plugin.name = "addresses"
|
12
|
+
# plugin.url = {
|
13
|
+
# :controller => 'refinery/addresses/admin/addresses',
|
14
|
+
# :action => 'index'
|
15
|
+
# }
|
16
|
+
# plugin.pathname = root
|
17
|
+
|
18
|
+
# plugin.activity = {
|
19
|
+
# :class_name => :'refinery/addresses/address',
|
20
|
+
# :title => 'first_name'
|
21
|
+
# }
|
22
|
+
#
|
23
|
+
# end
|
24
|
+
end
|
25
|
+
|
26
|
+
config.after_initialize do
|
27
|
+
Refinery.register_engine(Refinery::Addresses)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'refinerycms-core'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
autoload :StoresGenerator, 'generators/refinery/stores_generator'
|
5
|
+
|
6
|
+
module Addresses
|
7
|
+
require 'refinery/addresses/engine'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_writer :root
|
11
|
+
|
12
|
+
def root
|
13
|
+
@root ||= Pathname.new(File.expand_path('../../../', __FILE__))
|
14
|
+
end
|
15
|
+
|
16
|
+
def factory_paths
|
17
|
+
@factory_paths ||= [ root.join('spec', 'factories').to_s ]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'refinerycms-core'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
|
5
|
+
class Cart
|
6
|
+
|
7
|
+
attr_reader :items
|
8
|
+
|
9
|
+
def initialize()
|
10
|
+
@items = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_product(product)
|
14
|
+
current_item = @items.find {|item| item.product == product}
|
15
|
+
if current_item
|
16
|
+
current_item.increment_quantity
|
17
|
+
else
|
18
|
+
current_item = ::Refinery::CartItem.new(product)
|
19
|
+
@items << current_item
|
20
|
+
end
|
21
|
+
current_item
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def total_items
|
26
|
+
@items.sum { |item| item.quantity }
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def total_price
|
31
|
+
@items.sum { |item| item.price }
|
32
|
+
end
|
33
|
+
|
34
|
+
end # class Cart
|
35
|
+
|
36
|
+
end # module Refinery
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'refinerycms-core'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
|
5
|
+
class CartItem
|
6
|
+
|
7
|
+
attr_reader :product, :quantity
|
8
|
+
|
9
|
+
def initialize(product)
|
10
|
+
@product = product
|
11
|
+
@quantity = 1
|
12
|
+
end
|
13
|
+
|
14
|
+
def increment_quantity
|
15
|
+
@quantity += 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def name
|
19
|
+
@product.name
|
20
|
+
end
|
21
|
+
|
22
|
+
def price
|
23
|
+
@product.price * @quantity
|
24
|
+
end
|
25
|
+
|
26
|
+
end # class CartItem
|
27
|
+
|
28
|
+
end # module Refinery
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Refinery
|
2
|
+
module Orders
|
3
|
+
class Engine < Rails::Engine
|
4
|
+
include Refinery::Engine
|
5
|
+
isolate_namespace Refinery::Orders
|
6
|
+
|
7
|
+
engine_name :refinery_stores
|
8
|
+
|
9
|
+
initializer "register refinerycms_orders plugin" do |app|
|
10
|
+
# Refinery::Plugin.register do |plugin|
|
11
|
+
# plugin.name = "orders"
|
12
|
+
# plugin.url = {
|
13
|
+
# :controller => 'refinery/orders/admin/orders',
|
14
|
+
# :action => 'index'
|
15
|
+
# }
|
16
|
+
# plugin.pathname = root
|
17
|
+
|
18
|
+
# plugin.activity = {
|
19
|
+
# :class_name => :'refinery/orders/order',
|
20
|
+
# :title => 'order_status'
|
21
|
+
# }
|
22
|
+
#
|
23
|
+
# end
|
24
|
+
end
|
25
|
+
|
26
|
+
config.after_initialize do
|
27
|
+
Refinery.register_engine(Refinery::Orders)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'refinerycms-core'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
autoload :StoresGenerator, 'generators/refinery/stores_generator'
|
5
|
+
|
6
|
+
module Orders
|
7
|
+
require 'refinery/orders/engine'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_writer :root
|
11
|
+
|
12
|
+
def root
|
13
|
+
@root ||= Pathname.new(File.expand_path('../../../', __FILE__))
|
14
|
+
end
|
15
|
+
|
16
|
+
def factory_paths
|
17
|
+
@factory_paths ||= [ root.join('spec', 'factories').to_s ]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Refinery
|
2
|
+
module Products
|
3
|
+
class Engine < Rails::Engine
|
4
|
+
include Refinery::Engine
|
5
|
+
isolate_namespace Refinery::Products
|
6
|
+
|
7
|
+
engine_name :refinery_stores
|
8
|
+
|
9
|
+
initializer "register refinerycms_products plugin" do |app|
|
10
|
+
# Refinery::Plugin.register do |plugin|
|
11
|
+
# plugin.name = "products"
|
12
|
+
# plugin.url = {
|
13
|
+
# :controller => 'refinery/products/admin/products',
|
14
|
+
# :action => 'index'
|
15
|
+
# }
|
16
|
+
# plugin.pathname = root
|
17
|
+
|
18
|
+
# plugin.activity = {
|
19
|
+
# :class_name => :'refinery/products/product',
|
20
|
+
# :title => 'name'
|
21
|
+
# }
|
22
|
+
#
|
23
|
+
# end
|
24
|
+
end
|
25
|
+
|
26
|
+
config.after_initialize do
|
27
|
+
Refinery.register_engine(Refinery::Products)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'refinerycms-core'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
autoload :StoresGenerator, 'generators/refinery/stores_generator'
|
5
|
+
|
6
|
+
module Products
|
7
|
+
require 'refinery/products/engine'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_writer :root
|
11
|
+
|
12
|
+
def root
|
13
|
+
@root ||= Pathname.new(File.expand_path('../../../', __FILE__))
|
14
|
+
end
|
15
|
+
|
16
|
+
def factory_paths
|
17
|
+
@factory_paths ||= [ root.join('spec', 'factories').to_s ]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|