radiant-shop-extension 0.11.6 → 0.90.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +21 -3
- data/LICENSE +42 -0
- data/README.md +62 -25
- data/Rakefile +4 -5
- data/VERSION +1 -1
- data/app/controllers/admin/shop/categories_controller.rb +1 -0
- data/app/controllers/admin/shop/orders_controller.rb +1 -1
- data/app/controllers/admin/shop/products_controller.rb +18 -7
- data/app/helpers/shop_helper.rb +8 -0
- data/app/models/form_address.rb +5 -5
- data/app/models/form_checkout.rb +25 -17
- data/app/models/form_line_item.rb +1 -1
- data/app/models/shop_category.rb +22 -7
- data/app/models/shop_customer.rb +1 -1
- data/app/models/shop_line_item.rb +26 -26
- data/app/models/shop_order.rb +0 -2
- data/app/models/shop_product.rb +15 -18
- data/app/views/.DS_Store +0 -0
- data/app/views/admin/shop/categories/edit/meta/_status.html.haml +3 -0
- data/app/views/admin/shop/products/edit/_foot.html.haml +1 -8
- data/app/views/admin/shop/products/edit/meta/_layout.html.haml +6 -0
- data/app/views/admin/shop/products/edit/meta/_status.html.haml +3 -0
- data/app/views/admin/shop/products/index/_product.html.haml +1 -1
- data/config/locales/en.yml +8 -7
- data/config/routes.rb +4 -16
- data/db/migrate/20101011063133_setup_shop.rb +94 -0
- data/db/seeds/forms.rb +113 -154
- data/db/seeds/layouts.rb +67 -103
- data/db/seeds/pages.rb +101 -0
- data/db/seeds/products.rb +29 -0
- data/db/seeds/snippets.rb +36 -21
- data/lib/shop/controllers/application_controller.rb +5 -3
- data/lib/shop/models/form_extension.rb +1 -2
- data/lib/shop/models/page.rb +0 -1
- data/lib/shop/models/user.rb +0 -1
- data/lib/shop/tags/card.rb +8 -2
- data/lib/shop/tags/cart.rb +5 -1
- data/lib/shop/tags/helpers.rb +35 -60
- data/lib/shop/tags/item.rb +2 -16
- data/lib/shop/tags/product.rb +7 -0
- data/lib/tasks/shop_extension_tasks.rake +9 -4
- data/public/javascripts/admin/extensions/shop/products/edit.js +0 -25
- data/radiant-shop-extension.gemspec +25 -201
- data/shop_extension.rb +18 -19
- data/spec/datasets/forms.rb +25 -28
- data/spec/datasets/shop_categories.rb +2 -2
- data/spec/datasets/shop_config.rb +24 -0
- data/spec/datasets/shop_customers.rb +1 -0
- data/spec/datasets/shop_line_items.rb +21 -3
- data/spec/datasets/shop_products.rb +4 -1
- data/spec/datasets/tags.rb +19 -0
- data/spec/lib/shop/models/page_spec.rb +1 -1
- data/spec/lib/shop/tags/card_spec.rb +30 -4
- data/spec/lib/shop/tags/cart_spec.rb +29 -12
- data/spec/lib/shop/tags/helpers_spec.rb +45 -66
- data/spec/lib/shop/tags/item_spec.rb +6 -10
- data/spec/lib/shop/tags/product_spec.rb +27 -2
- data/spec/models/form_address_spec.rb +9 -8
- data/spec/models/form_checkout_spec.rb +28 -22
- data/spec/models/shop_category_spec.rb +2 -10
- data/spec/models/shop_line_item_spec.rb +71 -34
- data/spec/models/shop_order_spec.rb +5 -5
- data/spec/models/shop_product_attachment_spec.rb +1 -0
- data/spec/models/shop_product_spec.rb +4 -47
- data/spec/spec.opts +3 -5
- metadata +60 -248
- data/Gemfile +0 -26
- data/Gemfile.lock +0 -75
- data/MIT-LICENSE +0 -20
- data/app/controllers/admin/shop/discounts/discountables_controller.rb +0 -44
- data/app/controllers/admin/shop/discounts_controller.rb +0 -64
- data/app/controllers/admin/shop/packages/packings_controller.rb +0 -90
- data/app/controllers/admin/shop/packages_controller.rb +0 -63
- data/app/controllers/admin/shop/products/variant_templates_controller.rb +0 -27
- data/app/controllers/admin/shop/products/variants_controller.rb +0 -60
- data/app/controllers/admin/shop/variants_controller.rb +0 -48
- data/app/models/form_discount.rb +0 -39
- data/app/models/shop_discount.rb +0 -37
- data/app/models/shop_discountable.rb +0 -64
- data/app/models/shop_group.rb +0 -15
- data/app/models/shop_grouping.rb +0 -6
- data/app/models/shop_package.rb +0 -74
- data/app/models/shop_packing.rb +0 -22
- data/app/models/shop_product_variant.rb +0 -34
- data/app/models/shop_variant.rb +0 -23
- data/app/views/admin/pages/_shop_category.html.haml +0 -4
- data/app/views/admin/pages/_shop_product.html.haml +0 -4
- data/app/views/admin/shop/discounts/edit/_foot.html.haml +0 -16
- data/app/views/admin/shop/discounts/edit/_form.html.haml +0 -15
- data/app/views/admin/shop/discounts/edit/_head.html.haml +0 -4
- data/app/views/admin/shop/discounts/edit/_inputs.html.haml +0 -2
- data/app/views/admin/shop/discounts/edit/_meta.html.haml +0 -8
- data/app/views/admin/shop/discounts/edit/_parts.html.haml +0 -9
- data/app/views/admin/shop/discounts/edit/_popups.html.haml +0 -4
- data/app/views/admin/shop/discounts/edit/buttons/_browse_categories.html.haml +0 -1
- data/app/views/admin/shop/discounts/edit/buttons/_browse_products.html.haml +0 -1
- data/app/views/admin/shop/discounts/edit/inputs/_amount.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/inputs/_code.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/inputs/_name.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/meta/_finish.html.haml +0 -5
- data/app/views/admin/shop/discounts/edit/meta/_start.html.haml +0 -5
- data/app/views/admin/shop/discounts/edit/parts/_categories.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/parts/_products.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/popups/_browse_categories.html.haml +0 -6
- data/app/views/admin/shop/discounts/edit/popups/_browse_products.html.haml +0 -6
- data/app/views/admin/shop/discounts/edit/shared/_category.html.haml +0 -11
- data/app/views/admin/shop/discounts/edit/shared/_product.html.haml +0 -12
- data/app/views/admin/shop/discounts/edit.html.haml +0 -11
- data/app/views/admin/shop/discounts/index/_discount.html.haml +0 -13
- data/app/views/admin/shop/discounts/index/_foot.html.haml +0 -5
- data/app/views/admin/shop/discounts/index/_head.html.haml +0 -2
- data/app/views/admin/shop/discounts/index/buttons/_new_discount.html.haml +0 -1
- data/app/views/admin/shop/discounts/index.html.haml +0 -13
- data/app/views/admin/shop/discounts/new.html.haml +0 -11
- data/app/views/admin/shop/discounts/remove.html.haml +0 -12
- data/app/views/admin/shop/packages/edit/_foot.html.haml +0 -17
- data/app/views/admin/shop/packages/edit/_form.html.haml +0 -15
- data/app/views/admin/shop/packages/edit/_head.html.haml +0 -4
- data/app/views/admin/shop/packages/edit/_inputs.html.haml +0 -2
- data/app/views/admin/shop/packages/edit/_meta.html.haml +0 -8
- data/app/views/admin/shop/packages/edit/_parts.html.haml +0 -9
- data/app/views/admin/shop/packages/edit/_popups.html.haml +0 -4
- data/app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml +0 -1
- data/app/views/admin/shop/packages/edit/inputs/_name.html.haml +0 -3
- data/app/views/admin/shop/packages/edit/inputs/_price.html.haml +0 -3
- data/app/views/admin/shop/packages/edit/meta/_sku.html.haml +0 -5
- data/app/views/admin/shop/packages/edit/parts/_description.html.haml +0 -1
- data/app/views/admin/shop/packages/edit/parts/_products.html.haml +0 -3
- data/app/views/admin/shop/packages/edit/popups/_browse_products.html.haml +0 -7
- data/app/views/admin/shop/packages/edit/shared/_product.html.haml +0 -8
- data/app/views/admin/shop/packages/edit.html.haml +0 -11
- data/app/views/admin/shop/packages/index/_foot.html.haml +0 -8
- data/app/views/admin/shop/packages/index/_head.html.haml +0 -2
- data/app/views/admin/shop/packages/index/_package.html.haml +0 -9
- data/app/views/admin/shop/packages/index/buttons/_new_package.html.haml +0 -1
- data/app/views/admin/shop/packages/index.html.haml +0 -13
- data/app/views/admin/shop/packages/new.html.haml +0 -11
- data/app/views/admin/shop/packages/remove.html.haml +0 -12
- data/app/views/admin/shop/products/edit/buttons/_browse_templates.html.haml +0 -1
- data/app/views/admin/shop/products/edit/buttons/_new_variant.html.haml +0 -1
- data/app/views/admin/shop/products/edit/parts/_variants.html.haml +0 -3
- data/app/views/admin/shop/products/edit/popups/_browse_templates.html.haml +0 -6
- data/app/views/admin/shop/products/edit/popups/_new_variant.html.haml +0 -16
- data/app/views/admin/shop/products/edit/shared/_template.html.haml +0 -6
- data/app/views/admin/shop/products/edit/shared/_variant.html.haml +0 -10
- data/app/views/admin/shop/products/index/buttons/_variants.html.haml +0 -1
- data/app/views/admin/shop/variants/edit/_foot.html.haml +0 -9
- data/app/views/admin/shop/variants/edit/_form.html.haml +0 -13
- data/app/views/admin/shop/variants/edit/_head.html.haml +0 -4
- data/app/views/admin/shop/variants/edit/_inputs.html.haml +0 -2
- data/app/views/admin/shop/variants/edit/_meta.html.haml +0 -8
- data/app/views/admin/shop/variants/edit/_parts.html.haml +0 -9
- data/app/views/admin/shop/variants/edit/_popups.html.haml +0 -4
- data/app/views/admin/shop/variants/edit/inputs/_name.html.haml +0 -3
- data/app/views/admin/shop/variants/edit/inputs/_options.html.haml +0 -3
- data/app/views/admin/shop/variants/edit.html.haml +0 -11
- data/app/views/admin/shop/variants/index/_foot.html.haml +0 -5
- data/app/views/admin/shop/variants/index/_head.html.haml +0 -2
- data/app/views/admin/shop/variants/index/_variant.html.haml +0 -9
- data/app/views/admin/shop/variants/index/buttons/_add_variant.html.haml +0 -1
- data/app/views/admin/shop/variants/index/buttons/_categories.html.haml +0 -1
- data/app/views/admin/shop/variants/index.html.haml +0 -13
- data/app/views/admin/shop/variants/new.html.haml +0 -11
- data/app/views/admin/shop/variants/remove.html.haml +0 -12
- data/app/views/shop/categories/show.html.haml +0 -1
- data/app/views/shop/orders/show.html.haml +0 -1
- data/app/views/shop/products/index.html.haml +0 -1
- data/app/views/shop/products/show.html.haml +0 -1
- data/cucumber.yml +0 -1
- data/db/migrate/20100311053701_initial.rb +0 -153
- data/db/migrate/20100927041219_remove_payment_methods.rb +0 -16
- data/db/migrate/20100927041624_change_payments_add_gateway.rb +0 -11
- data/db/migrate/20100927140446_change_payment_add_card_type_card_number.rb +0 -11
- data/db/migrate/20100929011106_fix_relationship_foreign_keys.rb +0 -101
- data/db/migrate/20100929011607_drop_shop_addressables.rb +0 -25
- data/db/migrate/20100929030510_create_shop_groups.rb +0 -19
- data/db/migrate/20100929080301_shop_groups_change_add_description.rb +0 -11
- data/db/migrate/20100929081200_create_variants.rb +0 -20
- data/db/migrate/20100929143531_change_variants_add_updated_by.rb +0 -25
- data/db/migrate/20100929145641_change_created_by_to_id.rb +0 -75
- data/db/migrate/20100929235221_change_category_add_variant_id.rb +0 -9
- data/db/migrate/20100930235221_create_packages.rb +0 -31
- data/db/migrate/20101005231713_create_page_ids.rb +0 -11
- data/db/migrate/20101006051214_create_pages_for_products_and_categories.rb +0 -73
- data/db/migrate/20101007111845_add_default_position_to_attachment.rb +0 -9
- data/db/migrate/20101010071143_create_discounts.rb +0 -29
- data/db/migrate/20101010072225_modify_categories_remove_variant.rb +0 -9
- data/db/migrate/20101010130034_change_discountables_add_observer.rb +0 -15
- data/db/migrate/20101011063133_change_orders_set_limits_to_null.rb +0 -11
- data/features/support/env.rb +0 -16
- data/features/support/paths.rb +0 -14
- data/lib/shop/interface/packages.rb +0 -34
- data/lib/shop/interface/variants.rb +0 -34
- data/lib/shop/tags/package.rb +0 -95
- data/lib/shop/tags/product_variant.rb +0 -52
- data/lib/shop/tags/responses.rb +0 -34
- data/mockups/balsamiq/products-retro_fun_tshirt-more.bmml +0 -0
- data/mockups/balsamiq/products-retro_fun_tshirt.bmml +0 -0
- data/mockups/discounts/new-edit.bmml +0 -492
- data/public/javascripts/admin/extensions/shop/discounts/edit.js +0 -76
- data/public/javascripts/admin/extensions/shop/packages/edit.js +0 -109
- data/public/stylesheets/sass/admin/extensions/shop/discounts/edit.sass +0 -125
- data/public/stylesheets/sass/admin/extensions/shop/packages/edit.sass +0 -162
- data/spec/controllers/admin/shop/discounts/discountables_controller_spec.rb +0 -73
- data/spec/controllers/admin/shop/discounts_controller_spec.rb +0 -81
- data/spec/controllers/admin/shop/packages/packings_controller_spec.rb +0 -188
- data/spec/controllers/admin/shop/packages_controller_spec.rb +0 -32
- data/spec/controllers/admin/shop/products/variant_templates_controller_spec.rb +0 -53
- data/spec/controllers/admin/shop/products/variants_controller_spec.rb +0 -116
- data/spec/controllers/admin/shop/variants_controller_spec.rb +0 -67
- data/spec/datasets/shop_discountables.rb +0 -22
- data/spec/datasets/shop_discounts.rb +0 -29
- data/spec/datasets/shop_groups.rb +0 -15
- data/spec/datasets/shop_packages.rb +0 -25
- data/spec/datasets/shop_product_variants.rb +0 -22
- data/spec/datasets/shop_variants.rb +0 -17
- data/spec/lib/shop/tags/package_spec.rb +0 -342
- data/spec/lib/shop/tags/product_variant_spec.rb +0 -175
- data/spec/lib/shop/tags/responses_spec.rb +0 -129
- data/spec/models/form_discount_spec.rb +0 -63
- data/spec/models/shop_discount_spec.rb +0 -130
- data/spec/models/shop_discountable_spec.rb +0 -114
- data/spec/models/shop_group_spec.rb +0 -38
- data/spec/models/shop_package_spec.rb +0 -117
- data/spec/models/shop_packing_spec.rb +0 -67
- data/spec/models/shop_product_variant_spec.rb +0 -92
- data/spec/models/shop_variant_spec.rb +0 -32
data/HISTORY.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
## History
|
2
2
|
|
3
|
+
### 0.11+ (October 2010) @dirkkelly | sponsored by @frontiergroup
|
4
|
+
|
5
|
+
* Products and Categories are now pages
|
6
|
+
* Orders are shown in the admin system
|
7
|
+
* Seed data allows you to easily bootstrap
|
8
|
+
* All actions now utilize the form extension
|
9
|
+
* Core has remained minimal and been built to be extended, look out for
|
10
|
+
** radiant-shop_discounts-extension
|
11
|
+
** radiant-shop_variants-extension
|
12
|
+
** radiant-shop_packages-extension
|
13
|
+
* Wiki work is under way, we're ready for the world to start playing
|
14
|
+
|
15
|
+
### 0.10+ (September 2010) @dirkkelly | sponsored by @frontiergroup
|
16
|
+
|
17
|
+
* Started releasing as a Gem
|
18
|
+
* Customers are a model that extend users, they have no admin access
|
19
|
+
|
3
20
|
### 0.9+ (September 2010) @dirkkelly | sponsored by @frontiergroup
|
4
21
|
|
5
22
|
* SPECS! Yes, lots of them.
|
@@ -16,10 +33,11 @@
|
|
16
33
|
|
17
34
|
* Started pulling apart the database, removing overkill columns and tidying up codebase
|
18
35
|
* Making it easier to understand, and less feature bloated
|
36
|
+
* @sbmsuite no longer involved in the project
|
19
37
|
|
20
38
|
### 0.7 (11 Mar 2010)
|
21
39
|
|
22
|
-
* @dirkkelly and
|
40
|
+
* @dirkkelly and @sbmsuite decide to make this the core for an entire shop extension
|
23
41
|
|
24
42
|
### 0.6 (26 Sep 2009)
|
25
43
|
|
@@ -72,6 +90,6 @@ Thanks to John Reilly, Justin Grammens who did most of the work to get the origi
|
|
72
90
|
|
73
91
|
Huge thanks to Ingvi Gudmundsson (http://www.ingvithor.net/) for sponsoring and helping test v0.4 to v0.6.
|
74
92
|
|
75
|
-
|
93
|
+
----
|
76
94
|
|
77
|
-
|
95
|
+
Thanks to Jason Stirk for the original code base, it was a great starting point for seeing how an extension like this could be built.
|
data/LICENSE
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Copyright (c) 2010 Dirk Kelly (dk@dirkkelly.com) (SquareTalent)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
20
|
+
|
21
|
+
---------------------------------------------------------------------------
|
22
|
+
|
23
|
+
Copyright (c) 2008-2009 Aurora Software (http://www.aurorasoft.com.au)
|
24
|
+
|
25
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
26
|
+
a copy of this software and associated documentation files (the
|
27
|
+
"Software"), to deal in the Software without restriction, including
|
28
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
29
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
30
|
+
permit persons to whom the Software is furnished to do so, subject to
|
31
|
+
the following conditions:
|
32
|
+
|
33
|
+
The above copyright notice and this permission notice shall be
|
34
|
+
included in all copies or substantial portions of the Software.
|
35
|
+
|
36
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
37
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
38
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
39
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
40
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
41
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
42
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,36 +1,73 @@
|
|
1
1
|
# Radiant Shop
|
2
2
|
|
3
|
-
|
3
|
+
There isn't any store software out there which allows you to manage both the content
|
4
|
+
and the design of products in a similar way that you would a page or blog post.
|
4
5
|
|
5
|
-
|
6
|
+
I believe this is a problem, most simple online Stores should try to be a website
|
7
|
+
before they try to be an advanced application.
|
6
8
|
|
7
|
-
|
9
|
+
Radiant Shop doesn't require you to write server side code to build a store.
|
8
10
|
|
9
|
-
|
11
|
+
Instead you will use Radius tags, html, and css to build a custom store experience.
|
10
12
|
|
11
|
-
|
13
|
+
You're not limited to one design per category, or even per product. Nor are you forced
|
14
|
+
into following a specific checkout process, or to use a certain Gateway.
|
12
15
|
|
13
|
-
|
16
|
+
_**An online store is just a website**_
|
14
17
|
|
15
|
-
|
16
|
-
gateway:
|
17
|
-
name: Eway
|
18
|
-
username: 123456
|
19
|
-
password: abcdef
|
20
|
-
|
21
|
-
# Development
|
18
|
+
## Need Help?
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
20
|
+
The [Wiki](http://wiki.github.com/dirkkelly/radiant-shop-extension "Github Wiki Page") is the best source of information
|
21
|
+
about the entire project.
|
22
|
+
|
23
|
+
It's in its infancy, and your help is greatly appreciated. You can reach me via
|
24
|
+
|
25
|
+
* [Github Issues](http://github.com/dirkkelly/radiant-shop-extension/issues)
|
26
|
+
* [Twitter](http://twitter.com/dirkkelly)
|
27
|
+
|
28
|
+
I don't use email to manage my extension development work.
|
29
|
+
|
30
|
+
## Quickstart
|
31
|
+
|
32
|
+
Install RadiantShop Gem
|
33
|
+
|
34
|
+
gem install radiant-shop-extension
|
35
|
+
# This will install Radiant and the Gems RadiantShop requires
|
36
|
+
|
37
|
+
Create a Radiant project
|
38
|
+
|
39
|
+
radiant myshop --database sqlite3
|
40
|
+
cd myshop
|
41
|
+
|
42
|
+
Edit your Gemfile
|
43
|
+
|
44
|
+
source :gemcutter
|
45
|
+
gem 'radiant', '0.9.1'
|
46
|
+
gem 'radiant-shop-extension', :require => false
|
33
47
|
|
34
|
-
|
48
|
+
Add to your config/environment.rb
|
49
|
+
|
50
|
+
config.gem 'radiant-scoped-extension', :lib => false
|
51
|
+
config.gem 'radiant-images-extension', :lib => false
|
52
|
+
config.gem 'radiant-forms-extension', :lib => false
|
53
|
+
config.gem 'radiant-drag-extension', :lib => false
|
54
|
+
config.gem 'radiant-shop-extension', :lib => false
|
55
|
+
|
56
|
+
Bootstrap Radiant (answer questions, I suggest an empty template)
|
57
|
+
|
58
|
+
rake db:bootstrap
|
59
|
+
|
60
|
+
Migrate shop
|
61
|
+
|
62
|
+
rake radiant:extensions:update_all
|
63
|
+
rake radiant:extensions:shop:migrate
|
64
|
+
|
65
|
+
Seed shop (optional, will help you get on your way)
|
66
|
+
|
67
|
+
rake radiant:extensions:shop:seed
|
68
|
+
|
69
|
+
## Licence
|
70
|
+
|
71
|
+
Copyright 2010 Dirk Kelly [dk@dirkkelly.com](dk@dirkkelly.com) [@dirkkelly](http://twitter.com/dirkkelly) and licenced under MIT.
|
35
72
|
|
36
|
-
|
73
|
+
See LICENCE for further information.
|
data/Rakefile
CHANGED
@@ -6,15 +6,14 @@ begin
|
|
6
6
|
gem.description = %Q{Radiant Shop is an attempt at a simple but complete store. It includes Products, Categories, Orders and Credit Card Payments}
|
7
7
|
gem.email = "dk@dirkkelly.com"
|
8
8
|
gem.homepage = "http://github.com/squaretalent/radiant-shop-extension"
|
9
|
-
gem.authors = ["Dirk Kelly", "John Barker"]
|
9
|
+
gem.authors = ["Dirk Kelly", "John Barker", "Darcy Laycock"]
|
10
10
|
gem.add_dependency 'radiant', '>= 0.9.1'
|
11
11
|
gem.add_dependency 'activemerchant', '>= 1.8.0'
|
12
12
|
gem.add_dependency 'fastercsv', '>= 1.5.3'
|
13
|
-
gem.add_dependency 'radiant-layouts-extension', '>= 0.9.1'
|
14
13
|
gem.add_dependency 'radiant-settings-extension', '>= 1.1.1'
|
15
|
-
gem.add_dependency 'radiant-images-extension', '>= 0.
|
16
|
-
gem.add_dependency 'radiant-forms-extension', '>= 3.
|
17
|
-
gem.add_dependency 'radiant-
|
14
|
+
gem.add_dependency 'radiant-images-extension', '>= 0.4.0'
|
15
|
+
gem.add_dependency 'radiant-forms-extension', '>= 3.2.1'
|
16
|
+
gem.add_dependency 'radiant-users-extension', '>= 0.0.1'
|
18
17
|
gem.add_dependency 'radiant-drag-extension', '>= 0.1.0'
|
19
18
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
20
19
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.90.0
|
@@ -157,14 +157,14 @@ private
|
|
157
157
|
@meta << 'sku'
|
158
158
|
@meta << 'page'
|
159
159
|
@meta << 'category'
|
160
|
+
@meta << 'layout'
|
161
|
+
@meta << 'status'
|
160
162
|
|
161
163
|
@parts << 'description'
|
162
|
-
@parts << 'variants'
|
163
164
|
end
|
164
165
|
|
165
166
|
def config_index
|
166
167
|
@buttons << 'add_category'
|
167
|
-
@buttons << 'variants'
|
168
168
|
end
|
169
169
|
|
170
170
|
def config_new
|
@@ -176,13 +176,9 @@ private
|
|
176
176
|
|
177
177
|
@buttons << 'browse_images'
|
178
178
|
@buttons << 'new_image'
|
179
|
-
@buttons << 'browse_templates'
|
180
|
-
@buttons << 'new_variant'
|
181
179
|
|
182
180
|
@popups << 'browse_images'
|
183
181
|
@popups << 'new_image'
|
184
|
-
@popups << 'browse_templates'
|
185
|
-
@popups << 'new_variant'
|
186
182
|
end
|
187
183
|
|
188
184
|
def assets_global
|
@@ -204,6 +200,22 @@ private
|
|
204
200
|
include_javascript 'admin/dragdrop'
|
205
201
|
include_javascript 'admin/extensions/shop/edit'
|
206
202
|
include_javascript 'admin/extensions/shop/products/edit'
|
203
|
+
|
204
|
+
|
205
|
+
@routes = [
|
206
|
+
{
|
207
|
+
:name => 'admin_shop_product_images_path',
|
208
|
+
:path => admin_shop_product_images_path(@shop_product)
|
209
|
+
},
|
210
|
+
{
|
211
|
+
:name => 'sort_admin_shop_product_images_path',
|
212
|
+
:path => sort_admin_shop_product_images_path(@shop_product)
|
213
|
+
},
|
214
|
+
{
|
215
|
+
:name => 'admin_shop_product_image_path',
|
216
|
+
:path => admin_shop_product_image_path(@shop_product, ':id')
|
217
|
+
}
|
218
|
+
]
|
207
219
|
end
|
208
220
|
|
209
221
|
def set_layout_and_page
|
@@ -215,5 +227,4 @@ private
|
|
215
227
|
)
|
216
228
|
end
|
217
229
|
|
218
|
-
|
219
230
|
end
|
data/app/helpers/shop_helper.rb
CHANGED
@@ -2,4 +2,12 @@ module ShopHelper
|
|
2
2
|
def input_currency(amount)
|
3
3
|
number_to_currency(amount, :unit => '', :delimiter => '')
|
4
4
|
end
|
5
|
+
|
6
|
+
def routes_to_js(routes)
|
7
|
+
js = "ROUTES = new Array;\n"
|
8
|
+
@routes.each do |route|
|
9
|
+
js << "ROUTES[#{route[:name].to_json}] = #{route[:path].to_json}\n"
|
10
|
+
end
|
11
|
+
javascript_tag js
|
12
|
+
end
|
5
13
|
end
|
data/app/models/form_address.rb
CHANGED
@@ -41,12 +41,12 @@ class FormAddress
|
|
41
41
|
create_order_shipping_address
|
42
42
|
end
|
43
43
|
|
44
|
-
|
44
|
+
unless (@billing.present? and @billing.valid?) and (@shipping.present? and @shipping.valid?)
|
45
45
|
@form.redirect_to = :back
|
46
46
|
end
|
47
47
|
|
48
|
-
@result[:billing] = @billing.
|
49
|
-
@result[:shipping] = @shipping.
|
48
|
+
@result[:billing] = (@billing.valid? ? @billing.id : false) rescue false
|
49
|
+
@result[:shipping] = (@shipping.valid? ? @shipping.id : false) rescue false
|
50
50
|
end
|
51
51
|
|
52
52
|
# Attaches a billing address to the order (and current customer)
|
@@ -99,7 +99,7 @@ class FormAddress
|
|
99
99
|
elsif @shipping == @billing and shipping != billing
|
100
100
|
# We have conflicting data so create a new address
|
101
101
|
# the id is rejected so we'll get a new address
|
102
|
-
@order.update_attributes
|
102
|
+
@order.update_attributes({ :shipping_attributes => shipping })
|
103
103
|
@shipping = @order.shipping
|
104
104
|
end
|
105
105
|
rescue
|
@@ -118,7 +118,7 @@ class FormAddress
|
|
118
118
|
|
119
119
|
else
|
120
120
|
# Create a new address with these attributes
|
121
|
-
@order.update_attributes
|
121
|
+
@order.update_attributes({ :shipping_attributes => shipping })
|
122
122
|
@shipping = @order.shipping
|
123
123
|
end
|
124
124
|
end
|
data/app/models/form_checkout.rb
CHANGED
@@ -5,29 +5,33 @@ class FormCheckout
|
|
5
5
|
attr_accessor :config, :data, :result, :gateway, :card
|
6
6
|
|
7
7
|
def create
|
8
|
+
redirect = @form.redirect_to
|
9
|
+
|
10
|
+
@form.redirect_to = :back
|
8
11
|
find_current_order # locate the @order object
|
9
12
|
|
10
13
|
create_result_object # A default response object
|
11
|
-
|
14
|
+
|
12
15
|
# If the form was configured for gateway and we have a billing address
|
13
16
|
if @order.billing.present?
|
14
17
|
if gateway.present?
|
15
18
|
prepare_gateway # Create the @gateway object
|
16
19
|
prepare_credit_card if card.present?# Create the @card object
|
17
|
-
|
20
|
+
|
18
21
|
if @result[:gateway] and @result[:card]
|
19
22
|
purchase! # Use @card to pay through @gateway
|
20
23
|
|
21
24
|
# We have a paid for order with a billing address
|
22
25
|
if success?
|
23
|
-
finalize_cart
|
24
26
|
# The form was configured to send a payment email
|
25
|
-
if
|
26
|
-
|
27
|
+
if extensions.present?
|
28
|
+
configure_success_extensions # Create some configuration variables for mailing
|
27
29
|
end
|
30
|
+
|
31
|
+
finalize_cart
|
32
|
+
@form.redirect_to = redirect
|
28
33
|
else
|
29
34
|
@result[:payment] = false
|
30
|
-
@form.redirect_to = :back
|
31
35
|
end
|
32
36
|
end
|
33
37
|
else
|
@@ -94,13 +98,18 @@ class FormCheckout
|
|
94
98
|
end
|
95
99
|
|
96
100
|
# Sets up mail to send an invoice to the billing email address
|
97
|
-
def
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
def configure_success_extensions
|
102
|
+
extensions.each do |name, config|
|
103
|
+
if config[:extension].include?('mail')
|
104
|
+
config[:to] = @order.billing.email unless config[:to].present?
|
105
|
+
end
|
106
|
+
|
107
|
+
# it's very likely the extension will need to know the order id
|
108
|
+
config[:shop_order] = @order.id
|
109
|
+
|
110
|
+
result = @form.call_extension(name,config)
|
111
|
+
@result.merge!({ name.to_sym => result })
|
112
|
+
end
|
104
113
|
end
|
105
114
|
|
106
115
|
# Uses the gateway and card objects to carry out an ActiveMerchant purchase
|
@@ -115,7 +124,6 @@ class FormCheckout
|
|
115
124
|
end
|
116
125
|
|
117
126
|
def finalize_cart
|
118
|
-
@result[:session] = { :shop_order => nil } # We no longer need to store the current shop_roder
|
119
127
|
@order.update_attribute(:status, 'paid') # The order is now considered paid
|
120
128
|
end
|
121
129
|
|
@@ -126,7 +134,7 @@ class FormCheckout
|
|
126
134
|
|
127
135
|
# Returns the name of the gateway (Eway)
|
128
136
|
def gateway_name
|
129
|
-
gateway[:name]
|
137
|
+
gateway[:name].capitalize
|
130
138
|
end
|
131
139
|
|
132
140
|
# Returns Gateway username and password etc
|
@@ -191,8 +199,8 @@ class FormCheckout
|
|
191
199
|
end
|
192
200
|
|
193
201
|
# Returns configured mail attributes
|
194
|
-
def
|
195
|
-
@config[:
|
202
|
+
def extensions
|
203
|
+
@config[:extensions]
|
196
204
|
end
|
197
205
|
|
198
206
|
# Returns the amount to be charged, which is $10 on testing gateways
|
@@ -15,7 +15,7 @@ class FormLineItem
|
|
15
15
|
when 'modify'
|
16
16
|
@result[:modify] = @order.modify(line_item_id,line_item_quantity)
|
17
17
|
when 'remove'
|
18
|
-
@result[:remove] = @order.remove(line_item_id
|
18
|
+
@result[:remove] = @order.remove(line_item_id)
|
19
19
|
end
|
20
20
|
|
21
21
|
@result
|
data/app/models/shop_category.rb
CHANGED
@@ -8,10 +8,7 @@ class ShopCategory < ActiveRecord::Base
|
|
8
8
|
belongs_to :updated_by, :class_name => 'User'
|
9
9
|
belongs_to :product_layout, :class_name => 'Layout'
|
10
10
|
|
11
|
-
|
12
|
-
has_many :discounts, :class_name => 'ShopDiscount', :through => :discountables
|
13
|
-
|
14
|
-
before_validation :assign_slug, :assign_breadcrumb
|
11
|
+
before_validation :assign_slug, :assign_breadcrumb, :assign_page_class_name
|
15
12
|
|
16
13
|
accepts_nested_attributes_for :page
|
17
14
|
|
@@ -24,10 +21,21 @@ class ShopCategory < ActiveRecord::Base
|
|
24
21
|
def handle; ShopProduct.to_sku(page.url); end
|
25
22
|
|
26
23
|
# Returns the content of the product's page's description part
|
27
|
-
def description
|
24
|
+
def description
|
25
|
+
begin
|
26
|
+
page.parts.find_by_name('description').content
|
27
|
+
rescue
|
28
|
+
''
|
29
|
+
end
|
30
|
+
end
|
28
31
|
|
29
32
|
# Returns products through the pages children
|
30
|
-
def products
|
33
|
+
def products
|
34
|
+
pages = page.children.all(
|
35
|
+
:conditions => { :class_name => 'ShopProductPage' },
|
36
|
+
:order => 'pages.position ASC'
|
37
|
+
).map(&:shop_product)
|
38
|
+
end
|
31
39
|
|
32
40
|
# Returns the url of the page
|
33
41
|
def url; page.url; end
|
@@ -78,7 +86,14 @@ class ShopCategory < ActiveRecord::Base
|
|
78
86
|
# Assigns a breadcrumb to the page if its not set
|
79
87
|
def assign_breadcrumb
|
80
88
|
if page.present?
|
81
|
-
self.page.breadcrumb
|
89
|
+
self.page.breadcrumb ||= page.title
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Assigns a page class if its nil
|
94
|
+
def assign_page_class_name
|
95
|
+
if page.present?
|
96
|
+
self.page.class_name = page.class_name || 'ShopCategoryPage'
|
82
97
|
end
|
83
98
|
end
|
84
99
|
|
data/app/models/shop_customer.rb
CHANGED
@@ -4,53 +4,53 @@ class ShopLineItem < ActiveRecord::Base
|
|
4
4
|
has_one :customer, :class_name => 'ShopCustomer', :through => :order, :source => :customer
|
5
5
|
belongs_to :item, :polymorphic => true
|
6
6
|
|
7
|
-
|
8
|
-
has_many :discounts, :class_name => 'ShopDiscount', :through => :discountables
|
7
|
+
before_validation :adjust_quantity, :copy_price
|
9
8
|
|
10
|
-
|
11
|
-
validates_uniqueness_of :item_id, :scope => [ :order_id, :item_type ]
|
12
|
-
validates_presence_of :item
|
9
|
+
validates_presence_of :item, :item_price
|
13
10
|
|
14
|
-
|
15
|
-
price = value
|
16
|
-
price -= discounted
|
17
|
-
|
18
|
-
# We never want to return a negative cost
|
19
|
-
[0.00,price.to_f].max
|
20
|
-
end
|
11
|
+
validates_uniqueness_of :item_id, :scope => [ :order_id, :item_type ]
|
21
12
|
|
22
|
-
|
23
|
-
price = (item.price * self.quantity)
|
24
|
-
end
|
13
|
+
validates_numericality_of :item_price, :greater_than => 0.00, :allow_nil => true, :precisions => 2
|
25
14
|
|
26
|
-
def
|
27
|
-
(
|
15
|
+
def price
|
16
|
+
(item_price.to_f * self.quantity).to_f
|
28
17
|
end
|
29
18
|
|
30
19
|
def weight
|
20
|
+
warn 'Not yet fully implemented'
|
31
21
|
(item.weight.to_f * self.quantity.to_f).to_f
|
32
22
|
end
|
33
23
|
|
34
|
-
|
35
|
-
|
36
|
-
self.discounts.map { |d| discount += d.amount }
|
37
|
-
|
38
|
-
# Convert to a percentage
|
39
|
-
discount * 0.01
|
40
|
-
end
|
24
|
+
# Overloads the base to_json to return what we want
|
25
|
+
def to_json(*attrs); super self.class.params; end
|
41
26
|
|
42
27
|
class << self
|
43
28
|
|
44
|
-
|
29
|
+
# Returns attributes attached to the product
|
30
|
+
def attrs
|
45
31
|
[ :id, :quantity ]
|
46
32
|
end
|
47
33
|
|
34
|
+
# Returns methods with usefuly information
|
35
|
+
def methds
|
36
|
+
[ :price, :weight ]
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns a custom hash of attributes on the product
|
40
|
+
def params
|
41
|
+
{ :only => attrs, :methods => methds }
|
42
|
+
end
|
43
|
+
|
48
44
|
end
|
49
45
|
|
50
|
-
|
46
|
+
protected
|
51
47
|
|
52
48
|
def adjust_quantity
|
53
49
|
self.quantity = [1,self.quantity].max
|
54
50
|
end
|
55
51
|
|
52
|
+
def copy_price
|
53
|
+
self.item_price = item.price unless item_price.present?
|
54
|
+
end
|
55
|
+
|
56
56
|
end
|
data/app/models/shop_order.rb
CHANGED
@@ -4,8 +4,6 @@ class ShopOrder < ActiveRecord::Base
|
|
4
4
|
|
5
5
|
has_one :payment, :class_name => 'ShopPayment', :foreign_key => :order_id, :dependent => :destroy
|
6
6
|
has_many :line_items, :class_name => 'ShopLineItem', :foreign_key => :order_id, :dependent => :destroy
|
7
|
-
has_many :discountables, :class_name => 'ShopDiscountable', :foreign_key => :discounted_id
|
8
|
-
has_many :discounts, :class_name => 'ShopDiscount', :through => :discountables
|
9
7
|
|
10
8
|
belongs_to :billing, :class_name => 'ShopAddress'
|
11
9
|
belongs_to :shipping, :class_name => 'ShopAddress'
|
data/app/models/shop_product.rb
CHANGED
@@ -10,22 +10,13 @@ class ShopProduct < ActiveRecord::Base
|
|
10
10
|
has_many :orders, :class_name => 'ShopOrder', :through => :line_items, :uniq => true
|
11
11
|
has_many :attachments, :class_name => 'ShopProductAttachment', :foreign_key => :product_id
|
12
12
|
has_many :images, :class_name => 'Image', :through => :attachments, :uniq => true
|
13
|
-
|
14
|
-
|
15
|
-
has_many :related, :class_name => 'ShopProduct', :through => :packings, :source => :product, :uniq => true
|
16
|
-
has_many :variants, :class_name => 'ShopProductVariant', :foreign_key => :product_id, :dependent => :destroy
|
17
|
-
has_many :discountables, :class_name => 'ShopDiscountable', :foreign_key => :discounted_id
|
18
|
-
has_many :discounts, :class_name => 'ShopDiscount', :through => :discountables
|
19
|
-
|
20
|
-
before_validation :assign_slug, :assign_breadcrumb
|
13
|
+
|
14
|
+
before_validation :assign_slug, :assign_breadcrumb, :assign_page_class_name
|
21
15
|
validates_presence_of :page
|
22
16
|
|
23
17
|
validates_numericality_of :price, :greater_than => 0.00, :allow_nil => true, :precisions => 2
|
24
18
|
|
25
19
|
accepts_nested_attributes_for :page
|
26
|
-
accepts_nested_attributes_for :variants
|
27
|
-
|
28
|
-
after_create :assign_discounts
|
29
20
|
|
30
21
|
# Returns the title of the product's page
|
31
22
|
def name; page.title; end
|
@@ -40,7 +31,13 @@ class ShopProduct < ActiveRecord::Base
|
|
40
31
|
def category_id; category.id; end
|
41
32
|
|
42
33
|
# Returns the content of the product's page's description part
|
43
|
-
def description
|
34
|
+
def description
|
35
|
+
begin
|
36
|
+
page.parts.find_by_name('description').content
|
37
|
+
rescue
|
38
|
+
''
|
39
|
+
end
|
40
|
+
end
|
44
41
|
|
45
42
|
# Returns the url of the page
|
46
43
|
def url; page.url; end
|
@@ -104,7 +101,7 @@ class ShopProduct < ActiveRecord::Base
|
|
104
101
|
# Converts a url to a pretty sku and removes the shop prefix /shop/page/category/product page-category-product
|
105
102
|
def to_sku(url)
|
106
103
|
if url.present?
|
107
|
-
url.downcase.strip.gsub(
|
104
|
+
url.downcase.strip.gsub(/^(\/*)(.*)(\/)$/,'\2').gsub(/[\s\.:;=+~]+/,'_').gsub(/\//,'-')
|
108
105
|
end
|
109
106
|
end
|
110
107
|
|
@@ -122,14 +119,14 @@ class ShopProduct < ActiveRecord::Base
|
|
122
119
|
# Assigns a breadcrumb to the page if its not set
|
123
120
|
def assign_breadcrumb
|
124
121
|
if page.present?
|
125
|
-
self.page.breadcrumb
|
122
|
+
self.page.breadcrumb ||= page.title
|
126
123
|
end
|
127
124
|
end
|
128
125
|
|
129
|
-
# Assigns
|
130
|
-
def
|
131
|
-
|
132
|
-
|
126
|
+
# Assigns a page class if its nil
|
127
|
+
def assign_page_class_name
|
128
|
+
if page.present?
|
129
|
+
self.page.class_name = page.class_name || 'ShopProductPage'
|
133
130
|
end
|
134
131
|
end
|
135
132
|
|
data/app/views/.DS_Store
CHANGED
Binary file
|