kkt_shoppe 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +55 -0
- data/Rakefile +36 -0
- data/app/assets/images/kkt_shoppe/chosen-sprite.png +0 -0
- data/app/assets/images/kkt_shoppe/chosen-sprite@2x.png +0 -0
- data/app/assets/images/kkt_shoppe/document.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/bag.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/balance.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/box.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/building.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/chart.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/chat.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/checkbox.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/checkbox2.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/cloud.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/cone.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/credit_card.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/currency.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/edit.svg +14 -0
- data/app/assets/images/kkt_shoppe/icons/flowchart.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/gift.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/globe.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/id.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/id2.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/locked.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/report.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/search.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/support.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/tags.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/toolbox.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/unlocked.svg +1 -0
- data/app/assets/images/kkt_shoppe/icons/wallet.svg +1 -0
- data/app/assets/images/kkt_shoppe/kkt_shoppe.svg +25 -0
- data/app/assets/images/kkt_shoppe/logo.svg +47 -0
- data/app/assets/images/kkt_shoppe/move.svg +1 -0
- data/app/assets/images/kkt_shoppe/square.svg +9 -0
- data/app/assets/images/kkt_shoppe/statuses/accepted.svg +14 -0
- data/app/assets/images/kkt_shoppe/statuses/paid.svg +16 -0
- data/app/assets/images/kkt_shoppe/statuses/received.svg +15 -0
- data/app/assets/images/kkt_shoppe/statuses/rejected.svg +14 -0
- data/app/assets/images/kkt_shoppe/statuses/shipped.svg +14 -0
- data/app/assets/images/kkt_shoppe/table-tear-off.png +0 -0
- data/app/assets/javascripts/kkt_shoppe/application.coffee +123 -0
- data/app/assets/javascripts/kkt_shoppe/chosen.jquery.js +1166 -0
- data/app/assets/javascripts/kkt_shoppe/jquery_ui.js +6 -0
- data/app/assets/javascripts/kkt_shoppe/mousetrap.js +9 -0
- data/app/assets/javascripts/kkt_shoppe/order_form.coffee +47 -0
- data/app/assets/stylesheets/kkt_shoppe/application.scss +601 -0
- data/app/assets/stylesheets/kkt_shoppe/chosen.scss +424 -0
- data/app/assets/stylesheets/kkt_shoppe/dialog.scss +25 -0
- data/app/assets/stylesheets/kkt_shoppe/elements.scss +79 -0
- data/app/assets/stylesheets/kkt_shoppe/printable.scss +67 -0
- data/app/assets/stylesheets/kkt_shoppe/reset.scss +93 -0
- data/app/assets/stylesheets/kkt_shoppe/sub.scss +106 -0
- data/app/assets/stylesheets/kkt_shoppe/variables.scss +1 -0
- data/app/controllers/kkt_shoppe/addresses_controller.rb +47 -0
- data/app/controllers/kkt_shoppe/application_controller.rb +46 -0
- data/app/controllers/kkt_shoppe/attachments_controller.rb +14 -0
- data/app/controllers/kkt_shoppe/countries_controller.rb +47 -0
- data/app/controllers/kkt_shoppe/customers_controller.rb +55 -0
- data/app/controllers/kkt_shoppe/dashboard_controller.rb +9 -0
- data/app/controllers/kkt_shoppe/delivery_service_prices_controller.rb +45 -0
- data/app/controllers/kkt_shoppe/delivery_services_controller.rb +47 -0
- data/app/controllers/kkt_shoppe/orders_controller.rb +119 -0
- data/app/controllers/kkt_shoppe/payments_controller.rb +33 -0
- data/app/controllers/kkt_shoppe/product_categories_controller.rb +47 -0
- data/app/controllers/kkt_shoppe/product_category_localisations_controller.rb +58 -0
- data/app/controllers/kkt_shoppe/product_localisations_controller.rb +58 -0
- data/app/controllers/kkt_shoppe/products_controller.rb +58 -0
- data/app/controllers/kkt_shoppe/sessions_controller.rb +34 -0
- data/app/controllers/kkt_shoppe/settings_controller.rb +16 -0
- data/app/controllers/kkt_shoppe/stock_level_adjustments_controller.rb +40 -0
- data/app/controllers/kkt_shoppe/tax_rates_controller.rb +49 -0
- data/app/controllers/kkt_shoppe/users_controller.rb +53 -0
- data/app/controllers/kkt_shoppe/variants_controller.rb +50 -0
- data/app/helpers/kkt_shoppe/application_helper.rb +60 -0
- data/app/helpers/kkt_shoppe/product_category_helper.rb +36 -0
- data/app/mailers/kkt_shoppe/order_mailer.rb +25 -0
- data/app/mailers/kkt_shoppe/user_mailer.rb +10 -0
- data/app/models/kkt_shoppe/address.rb +44 -0
- data/app/models/kkt_shoppe/country.rb +27 -0
- data/app/models/kkt_shoppe/customer.rb +41 -0
- data/app/models/kkt_shoppe/delivery_service.rb +33 -0
- data/app/models/kkt_shoppe/delivery_service_price.rb +31 -0
- data/app/models/kkt_shoppe/order/actions.rb +94 -0
- data/app/models/kkt_shoppe/order/billing.rb +105 -0
- data/app/models/kkt_shoppe/order/delivery.rb +229 -0
- data/app/models/kkt_shoppe/order/states.rb +69 -0
- data/app/models/kkt_shoppe/order.rb +100 -0
- data/app/models/kkt_shoppe/order_item.rb +239 -0
- data/app/models/kkt_shoppe/payment.rb +86 -0
- data/app/models/kkt_shoppe/product/product_attributes.rb +20 -0
- data/app/models/kkt_shoppe/product/variants.rb +51 -0
- data/app/models/kkt_shoppe/product.rb +189 -0
- data/app/models/kkt_shoppe/product_attribute.rb +66 -0
- data/app/models/kkt_shoppe/product_categorization.rb +14 -0
- data/app/models/kkt_shoppe/product_category.rb +75 -0
- data/app/models/kkt_shoppe/setting.rb +68 -0
- data/app/models/kkt_shoppe/stock_level_adjustment.rb +19 -0
- data/app/models/kkt_shoppe/tax_rate.rb +46 -0
- data/app/models/kkt_shoppe/user.rb +49 -0
- data/app/validators/permalink_validator.rb +7 -0
- data/app/views/kkt_shoppe/addresses/_form.html.haml +33 -0
- data/app/views/kkt_shoppe/addresses/edit.html.haml +5 -0
- data/app/views/kkt_shoppe/addresses/new.html.haml +5 -0
- data/app/views/kkt_shoppe/countries/_form.html.haml +35 -0
- data/app/views/kkt_shoppe/countries/edit.html.haml +6 -0
- data/app/views/kkt_shoppe/countries/index.html.haml +25 -0
- data/app/views/kkt_shoppe/countries/new.html.haml +7 -0
- data/app/views/kkt_shoppe/customers/_addresses.html.haml +20 -0
- data/app/views/kkt_shoppe/customers/_form.html.haml +30 -0
- data/app/views/kkt_shoppe/customers/_search_form.html.haml +13 -0
- data/app/views/kkt_shoppe/customers/edit.html.haml +5 -0
- data/app/views/kkt_shoppe/customers/index.html.haml +32 -0
- data/app/views/kkt_shoppe/customers/new.html.haml +5 -0
- data/app/views/kkt_shoppe/customers/show.html.haml +53 -0
- data/app/views/kkt_shoppe/delivery_service_prices/_form.html.haml +44 -0
- data/app/views/kkt_shoppe/delivery_service_prices/edit.html.haml +6 -0
- data/app/views/kkt_shoppe/delivery_service_prices/index.html.haml +23 -0
- data/app/views/kkt_shoppe/delivery_service_prices/new.html.haml +6 -0
- data/app/views/kkt_shoppe/delivery_services/_form.html.haml +38 -0
- data/app/views/kkt_shoppe/delivery_services/edit.html.haml +9 -0
- data/app/views/kkt_shoppe/delivery_services/index.html.haml +27 -0
- data/app/views/kkt_shoppe/delivery_services/new.html.haml +6 -0
- data/app/views/kkt_shoppe/order_mailer/accepted.text.erb +12 -0
- data/app/views/kkt_shoppe/order_mailer/received.text.erb +9 -0
- data/app/views/kkt_shoppe/order_mailer/rejected.text.erb +10 -0
- data/app/views/kkt_shoppe/order_mailer/shipped.text.erb +16 -0
- data/app/views/kkt_shoppe/orders/_form.html.haml +58 -0
- data/app/views/kkt_shoppe/orders/_order_details.html.haml +57 -0
- data/app/views/kkt_shoppe/orders/_order_items.html.haml +38 -0
- data/app/views/kkt_shoppe/orders/_order_items_form.html.haml +61 -0
- data/app/views/kkt_shoppe/orders/_payments_form.html.haml +15 -0
- data/app/views/kkt_shoppe/orders/_payments_table.html.haml +37 -0
- data/app/views/kkt_shoppe/orders/_search_form.html.haml +24 -0
- data/app/views/kkt_shoppe/orders/_status_bar.html.haml +35 -0
- data/app/views/kkt_shoppe/orders/despatch_note.html.haml +45 -0
- data/app/views/kkt_shoppe/orders/edit.html.haml +21 -0
- data/app/views/kkt_shoppe/orders/index.html.haml +39 -0
- data/app/views/kkt_shoppe/orders/new.html.haml +14 -0
- data/app/views/kkt_shoppe/orders/show.html.haml +25 -0
- data/app/views/kkt_shoppe/payments/refund.html.haml +13 -0
- data/app/views/kkt_shoppe/product_categories/_form.html.haml +50 -0
- data/app/views/kkt_shoppe/product_categories/edit.html.haml +8 -0
- data/app/views/kkt_shoppe/product_categories/index.html.haml +27 -0
- data/app/views/kkt_shoppe/product_categories/new.html.haml +6 -0
- data/app/views/kkt_shoppe/product_category_localisations/form.html.haml +29 -0
- data/app/views/kkt_shoppe/product_category_localisations/index.html.haml +26 -0
- data/app/views/kkt_shoppe/product_localisations/form.html.haml +32 -0
- data/app/views/kkt_shoppe/product_localisations/index.html.haml +26 -0
- data/app/views/kkt_shoppe/products/_form.html.haml +118 -0
- data/app/views/kkt_shoppe/products/_table.html.haml +42 -0
- data/app/views/kkt_shoppe/products/edit.html.haml +9 -0
- data/app/views/kkt_shoppe/products/import.html.haml +67 -0
- data/app/views/kkt_shoppe/products/index.html.haml +9 -0
- data/app/views/kkt_shoppe/products/new.html.haml +7 -0
- data/app/views/kkt_shoppe/sessions/new.html.haml +12 -0
- data/app/views/kkt_shoppe/sessions/reset.html.haml +12 -0
- data/app/views/kkt_shoppe/settings/edit.html.haml +19 -0
- data/app/views/kkt_shoppe/shared/error.html.haml +6 -0
- data/app/views/kkt_shoppe/stock_level_adjustments/index.html.haml +40 -0
- data/app/views/kkt_shoppe/tax_rates/form.html.haml +28 -0
- data/app/views/kkt_shoppe/tax_rates/index.html.haml +17 -0
- data/app/views/kkt_shoppe/user_mailer/new_password.text.erb +9 -0
- data/app/views/kkt_shoppe/users/_form.html.haml +27 -0
- data/app/views/kkt_shoppe/users/edit.html.haml +5 -0
- data/app/views/kkt_shoppe/users/index.html.haml +17 -0
- data/app/views/kkt_shoppe/users/new.html.haml +7 -0
- data/app/views/kkt_shoppe/variants/form.html.haml +68 -0
- data/app/views/kkt_shoppe/variants/index.html.haml +33 -0
- data/app/views/layouts/kkt_shoppe/application.html.haml +34 -0
- data/app/views/layouts/kkt_shoppe/printable.html.haml +11 -0
- data/app/views/layouts/kkt_shoppe/sub.html.haml +10 -0
- data/config/locales/de.yml +653 -0
- data/config/locales/en.yml +744 -0
- data/config/locales/es.yml +653 -0
- data/config/locales/pl.yml +662 -0
- data/config/locales/pt-BR.yml +655 -0
- data/config/routes.rb +53 -0
- data/db/countries.txt +252 -0
- data/db/migrate/20130926094549_create_kkt_shoppe_initial_schema.rb +175 -0
- data/db/migrate/20131024201501_add_address_type_to_kkt_shoppe_tax_rates.rb +5 -0
- data/db/migrate/20131024204815_create_kkt_shoppe_payments.rb +32 -0
- data/db/migrate/20131102143930_remove_default_on_order_item_weight.rb +9 -0
- data/db/migrate/20141013192427_create_kkt_shoppe_customers.rb +14 -0
- data/db/migrate/20141026175622_add_indexes_to_kkt_shoppe_order_items.rb +6 -0
- data/db/migrate/20141026175943_add_indexes_to_kkt_shoppe_orders.rb +7 -0
- data/db/migrate/20141026180333_add_indexes_to_kkt_shoppe_payments.rb +6 -0
- data/db/migrate/20141026180835_add_indexes_to_kkt_shoppe_product_attributes.rb +7 -0
- data/db/migrate/20141026180952_add_indexes_to_kkt_shoppe_product_categories.rb +5 -0
- data/db/migrate/20141026181040_add_indexes_to_kkt_shoppe_products.rb +8 -0
- data/db/migrate/20141026181312_add_indexes_to_kkt_shoppe_settings.rb +5 -0
- data/db/migrate/20141026181354_add_indexes_to_kkt_shoppe_stock_level_adjustments.rb +6 -0
- data/db/migrate/20141026181559_add_indexes_to_kkt_shoppe_users.rb +5 -0
- data/db/migrate/20141026181716_add_indexes_to_kkt_shoppe_delivery_services.rb +9 -0
- data/db/migrate/20141026181717_allow_multiple_kkt_shoppe_products_per_shoppe_product_category.rb +46 -0
- data/db/migrate/20141026181718_add_nested_to_product_categories.rb +30 -0
- data/db/migrate/20141027215005_create_kkt_shoppe_addresses.rb +17 -0
- data/db/migrate/20150315215633_add_customer_to_kkt_shoppe_orders.rb +5 -0
- data/db/migrate/20150513171350_create_kkt_shoppe_product_category_translation_table.rb +17 -0
- data/db/migrate/20150519173350_create_kkt_shoppe_product_translation_table.rb +18 -0
- data/db/schema.rb +308 -0
- data/db/seeds.rb +137 -0
- data/db/seeds_data/poe400.jpg +0 -0
- data/db/seeds_data/snom-870-blk.jpg +0 -0
- data/db/seeds_data/snom-870-grey.jpg +0 -0
- data/db/seeds_data/snom-mm2.jpg +0 -0
- data/db/seeds_data/spa303.jpg +0 -0
- data/db/seeds_data/t18p.jpg +0 -0
- data/db/seeds_data/t20p.jpg +0 -0
- data/db/seeds_data/t22p.jpg +0 -0
- data/db/seeds_data/t26p.jpg +0 -0
- data/db/seeds_data/t41pn.jpg +0 -0
- data/db/seeds_data/t46gn.jpg +0 -0
- data/db/seeds_data/w52p.jpg +0 -0
- data/db/seeds_data/yhs32.jpg +0 -0
- data/lib/kkt_shoppe/associated_countries.rb +20 -0
- data/lib/kkt_shoppe/country_importer.rb +15 -0
- data/lib/kkt_shoppe/default_navigation.rb +21 -0
- data/lib/kkt_shoppe/engine.rb +55 -0
- data/lib/kkt_shoppe/error.rb +21 -0
- data/lib/kkt_shoppe/errors/inappropriate_delivery_service.rb +6 -0
- data/lib/kkt_shoppe/errors/insufficient_stock_to_fulfil.rb +15 -0
- data/lib/kkt_shoppe/errors/invalid_configuration.rb +6 -0
- data/lib/kkt_shoppe/errors/not_enough_stock.rb +15 -0
- data/lib/kkt_shoppe/errors/payment_declined.rb +6 -0
- data/lib/kkt_shoppe/errors/refund_failed.rb +6 -0
- data/lib/kkt_shoppe/errors/unorderable_item.rb +6 -0
- data/lib/kkt_shoppe/navigation_manager.rb +81 -0
- data/lib/kkt_shoppe/orderable_item.rb +39 -0
- data/lib/kkt_shoppe/settings.rb +26 -0
- data/lib/kkt_shoppe/settings_loader.rb +16 -0
- data/lib/kkt_shoppe/setup_generator.rb +10 -0
- data/lib/kkt_shoppe/version.rb +3 -0
- data/lib/kkt_shoppe/view_helpers.rb +16 -0
- data/lib/kkt_shoppe.rb +60 -0
- data/lib/tasks/kylekthompson_shoppe.rake +29 -0
- metadata +662 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
/*
|
2
|
+
*= require kkt_shoppe/reset
|
3
|
+
*= require kkt_shoppe/elements
|
4
|
+
*= require_self
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
@import 'variables';
|
9
|
+
|
10
|
+
html { overflow-y: scroll; height:100%; background:#fff;}
|
11
|
+
body { font-family:$font; font-weight: normal; font-size: 100%; min-width:900px; height:100%; }
|
12
|
+
@import 'variables';
|
13
|
+
|
14
|
+
html.login {
|
15
|
+
background:image-url('kkt_shoppe/logo.svg') #40454D no-repeat center 100px;
|
16
|
+
background-size:70px;
|
17
|
+
|
18
|
+
#flash-alert {
|
19
|
+
background:#C17391;
|
20
|
+
position:absolute;
|
21
|
+
top:0;
|
22
|
+
width:100%;
|
23
|
+
text-align:center;
|
24
|
+
color:#fff;
|
25
|
+
padding:15px 0;
|
26
|
+
}
|
27
|
+
|
28
|
+
#flash-notice {
|
29
|
+
background:#94C164;
|
30
|
+
position:absolute;
|
31
|
+
top:0;
|
32
|
+
width:100%;
|
33
|
+
text-align:center;
|
34
|
+
color:#fff;
|
35
|
+
padding:15px 0;
|
36
|
+
}
|
37
|
+
|
38
|
+
//
|
39
|
+
// Error
|
40
|
+
//
|
41
|
+
div.error {
|
42
|
+
background:#fff;
|
43
|
+
width:400px;
|
44
|
+
margin:auto;
|
45
|
+
margin-top:200px;
|
46
|
+
padding:25px;
|
47
|
+
line-height:1.5;
|
48
|
+
font-size:0.9em;
|
49
|
+
text-align:center;
|
50
|
+
h2 { color:#C17391; text-transform:uppercase; font-size:0.8em; margin-bottom:15px;}
|
51
|
+
p.back { margin-top:25px;}
|
52
|
+
p.message { font-size:1.1em;}
|
53
|
+
}
|
54
|
+
|
55
|
+
//
|
56
|
+
// Primary login area
|
57
|
+
//
|
58
|
+
div.loginArea {
|
59
|
+
background:#fff;
|
60
|
+
width:400px;
|
61
|
+
margin:auto;
|
62
|
+
margin-top:200px;
|
63
|
+
padding-top:50px;
|
64
|
+
|
65
|
+
h2 {
|
66
|
+
text-align:center;
|
67
|
+
font-weight:300;
|
68
|
+
font-size:1.4em;
|
69
|
+
color:#40454D;
|
70
|
+
margin-bottom:30px;
|
71
|
+
}
|
72
|
+
p.field {
|
73
|
+
text-align:center;
|
74
|
+
margin-bottom:15px;
|
75
|
+
input {
|
76
|
+
padding:7px;
|
77
|
+
border:0;
|
78
|
+
border-radius:4px;
|
79
|
+
border:1px solid #c0c6ce;
|
80
|
+
width:275px;
|
81
|
+
font-family:$font;
|
82
|
+
font-weight:600;
|
83
|
+
background:#eef0f4;
|
84
|
+
box-shadow:inset 1px 1px 1px rgba(42,51,61,0.1);
|
85
|
+
text-align:center;
|
86
|
+
&::-webkit-input-placeholder { color:#b7bfcb; font-weight:normal;}
|
87
|
+
&:-moz-placeholder { color:#b7bfcb; font-weight:normal;}
|
88
|
+
&::-moz-placeholder { color:#b7bfcb; font-weight:normal;}
|
89
|
+
&:-ms-input-placeholder { color:#b7bfcb; font-weight:normal;}
|
90
|
+
}
|
91
|
+
&:last-child { margin-bottom:0;}
|
92
|
+
}
|
93
|
+
p.submit {
|
94
|
+
padding:15px 0 25px 0;
|
95
|
+
text-align:center;
|
96
|
+
}
|
97
|
+
p.reset {
|
98
|
+
background:#353A41;
|
99
|
+
font-size:0.9em;
|
100
|
+
padding:15px 0;
|
101
|
+
text-align:center;
|
102
|
+
a { color:rgba(255,255,255,0.5);}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
$font: 'Helvetica Neue', Arial, sans-serif;
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module KktShoppe
|
2
|
+
class AddressesController < KktShoppe::ApplicationController
|
3
|
+
|
4
|
+
before_filter { @active_nav = :customers }
|
5
|
+
before_filter { params[:customer_id] && @customer = KktShoppe::Customer.find(params[:customer_id])}
|
6
|
+
before_filter { params[:id] && @address = @customer.addresses.find(params[:id])}
|
7
|
+
|
8
|
+
def new
|
9
|
+
@address = KktShoppe::Address.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def edit
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@address = @customer.addresses.build(safe_params)
|
17
|
+
if @customer.addresses.count == 0
|
18
|
+
@address.default = true
|
19
|
+
end
|
20
|
+
if @customer.save
|
21
|
+
redirect_to @customer, :flash => {:notice => "Address has been created successfully"}
|
22
|
+
else
|
23
|
+
render action: "new"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def update
|
28
|
+
if @address.update(safe_params)
|
29
|
+
redirect_to @customer, :flash => {:notice => "Address has been updated successfully"}
|
30
|
+
else
|
31
|
+
render action: "edit"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def destroy
|
36
|
+
@address.destroy
|
37
|
+
redirect_to @customer, :flash => {:notice => "Address has been deleted successfully"}
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def safe_params
|
43
|
+
params[:address].permit(:address_type, :address1, :address2, :address3, :address4, :postcode, :country_id)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module KktShoppe
|
2
|
+
class ApplicationController < ActionController::Base
|
3
|
+
|
4
|
+
before_filter :login_required
|
5
|
+
|
6
|
+
rescue_from ActiveRecord::DeleteRestrictionError do |e|
|
7
|
+
redirect_to request.referer || root_path, :alert => e.message
|
8
|
+
end
|
9
|
+
|
10
|
+
rescue_from KktShoppe::Error do |e|
|
11
|
+
@exception = e
|
12
|
+
render :layout => 'kkt_shoppe/sub', :template => 'kkt_shoppe/shared/error'
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def login_required
|
18
|
+
unless logged_in?
|
19
|
+
redirect_to login_path
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def logged_in?
|
24
|
+
current_user.is_a?(User)
|
25
|
+
end
|
26
|
+
|
27
|
+
def current_user
|
28
|
+
@current_user ||= login_from_session || login_with_demo_mdoe || :false
|
29
|
+
end
|
30
|
+
|
31
|
+
def login_from_session
|
32
|
+
if session[:kkt_shoppe_user_id]
|
33
|
+
@user = User.find_by_id(session[:kkt_shoppe_user_id])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def login_with_demo_mdoe
|
38
|
+
if KktShoppe.settings.demo_mode?
|
39
|
+
@user = User.first
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
helper_method :current_user, :logged_in?
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module KktShoppe
|
2
|
+
class AttachmentsController < KktShoppe::ApplicationController
|
3
|
+
|
4
|
+
def destroy
|
5
|
+
@attachment = Nifty::Attachments::Attachment.find(params[:id])
|
6
|
+
@attachment.destroy
|
7
|
+
respond_to do |wants|
|
8
|
+
wants.html { redirect_to request.referer, :notice => t('kkt_shoppe.attachments.remove_notice')}
|
9
|
+
wants.json { render :status => 'complete' }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module KktShoppe
|
2
|
+
class CountriesController < KktShoppe::ApplicationController
|
3
|
+
|
4
|
+
before_filter { @active_nav = :countries }
|
5
|
+
before_filter { params[:id] && @country = KktShoppe::Country.find(params[:id]) }
|
6
|
+
|
7
|
+
def index
|
8
|
+
@countries = KktShoppe::Country.ordered
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@country = KktShoppe::Country.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@country = KktShoppe::Country.new(safe_params)
|
17
|
+
if @country.save
|
18
|
+
redirect_to :countries, :flash => {:notice => t('kkt_shoppe.countries.create_notice')}
|
19
|
+
else
|
20
|
+
render :action => "new"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def edit
|
25
|
+
end
|
26
|
+
|
27
|
+
def update
|
28
|
+
if @country.update(safe_params)
|
29
|
+
redirect_to [:edit, @country], :flash => {:notice => t('kkt_shoppe.countries.update_notice') }
|
30
|
+
else
|
31
|
+
render :action => "edit"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def destroy
|
36
|
+
@country.destroy
|
37
|
+
redirect_to :countries, :flash => {:notice => t('kkt_shoppe.countries.destroy_notice')}
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def safe_params
|
43
|
+
params[:country].permit(:name, :code2, :code3, :continent, :tld, :currency, :eu_member)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module KktShoppe
|
2
|
+
class CustomersController < KktShoppe::ApplicationController
|
3
|
+
|
4
|
+
before_filter { @active_nav = :customers }
|
5
|
+
before_filter { params[:id] && @customer = KktShoppe::Customer.find(params[:id])}
|
6
|
+
|
7
|
+
def index
|
8
|
+
@query = KktShoppe::Customer.ordered.page(params[:page]).search(params[:q])
|
9
|
+
@customers = @query.result
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@customer = KktShoppe::Customer.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def show
|
17
|
+
@addresses = @customer.addresses.ordered.load
|
18
|
+
@orders = @customer.orders.ordered.load
|
19
|
+
end
|
20
|
+
|
21
|
+
def create
|
22
|
+
@customer = KktShoppe::Customer.new(safe_params)
|
23
|
+
if @customer.save
|
24
|
+
redirect_to @customer, :flash => {:notice => "Customer has been created successfully"}
|
25
|
+
else
|
26
|
+
render :action => "new"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def update
|
31
|
+
if @customer.update(safe_params)
|
32
|
+
redirect_to @customer, :flash => {:notice => "Customer has been updated successfully"}
|
33
|
+
else
|
34
|
+
render :action => "edit"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def destroy
|
39
|
+
@customer.destroy
|
40
|
+
redirect_to customers_path, :flash => {:notice => "Customer has been deleted successfully"}
|
41
|
+
end
|
42
|
+
|
43
|
+
def search
|
44
|
+
index
|
45
|
+
render :action => "index"
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def safe_params
|
51
|
+
params[:customer].permit(:first_name, :last_name, :company, :email, :phone, :mobile)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module KktShoppe
|
2
|
+
class DeliveryServicePricesController < KktShoppe::ApplicationController
|
3
|
+
|
4
|
+
before_filter { @active_nav = :delivery_services }
|
5
|
+
before_filter { @delivery_service = KktShoppe::DeliveryService.find(params[:delivery_service_id])}
|
6
|
+
before_filter { params[:id] && @delivery_service_price = @delivery_service.delivery_service_prices.find(params[:id])}
|
7
|
+
|
8
|
+
def index
|
9
|
+
@delivery_service_prices = @delivery_service.delivery_service_prices.ordered
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@delivery_service_price = @delivery_service.delivery_service_prices.build
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
@delivery_service_price = @delivery_service.delivery_service_prices.build(safe_params)
|
18
|
+
if @delivery_service_price.save
|
19
|
+
redirect_to [@delivery_service, :delivery_service_prices], :notice => t('kkt_shoppe.delivery_service_prices.create_notice')
|
20
|
+
else
|
21
|
+
render :action => "new"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def update
|
26
|
+
if @delivery_service_price.update(safe_params)
|
27
|
+
redirect_to [@delivery_service, :delivery_service_prices], :notice => t('kkt_shoppe.delivery_service_prices.update_notice')
|
28
|
+
else
|
29
|
+
render :action => "edit"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def destroy
|
34
|
+
@delivery_service_price.destroy
|
35
|
+
redirect_to [@delivery_service, :delivery_service_prices], :notice => t('kkt_shoppe.delivery_service_prices.destroy_notice')
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def safe_params
|
41
|
+
params[:delivery_service_price].permit(:price, :cost_price, :tax_rate_id, :min_weight, :max_weight, :code, :country_ids => [])
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module KktShoppe
|
2
|
+
class DeliveryServicesController < KktShoppe::ApplicationController
|
3
|
+
|
4
|
+
before_filter { @active_nav = :delivery_services }
|
5
|
+
before_filter { params[:id] && @delivery_service = KktShoppe::DeliveryService.find(params[:id]) }
|
6
|
+
|
7
|
+
def index
|
8
|
+
@delivery_services = KktShoppe::DeliveryService.all
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@delivery_service = KktShoppe::DeliveryService.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@delivery_service = KktShoppe::DeliveryService.new(safe_params)
|
17
|
+
if @delivery_service.save
|
18
|
+
redirect_to :delivery_services, :flash => {:notice => t('kkt_shoppe.delivery_services.create_notice')}
|
19
|
+
else
|
20
|
+
render :action => "new"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def edit
|
25
|
+
end
|
26
|
+
|
27
|
+
def update
|
28
|
+
if @delivery_service.update(safe_params)
|
29
|
+
redirect_to [:edit, @delivery_service], :flash => {:notice => t('kkt_shoppe.delivery_services.update_notice')}
|
30
|
+
else
|
31
|
+
render :action => "edit"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def destroy
|
36
|
+
@delivery_service.destroy
|
37
|
+
redirect_to :delivery_services, :flash => {:notice =>t('kkt_shoppe.delivery_services.destroy_notice')}
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def safe_params
|
43
|
+
params[:delivery_service].permit(:name, :code, :active, :default, :courier, :tracking_url)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
module KktShoppe
|
2
|
+
class OrdersController < KktShoppe::ApplicationController
|
3
|
+
|
4
|
+
before_filter { @active_nav = :orders }
|
5
|
+
before_filter { params[:id] && @order = KktShoppe::Order.find(params[:id])}
|
6
|
+
|
7
|
+
def index
|
8
|
+
@query = KktShoppe::Order.ordered.received.includes(:order_items => :ordered_item).page(params[:page]).search(params[:q])
|
9
|
+
@orders = @query.result
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@order = KktShoppe::Order.new
|
14
|
+
@order.order_items.build(:ordered_item_type => 'KktShoppe::Product')
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
KktShoppe::Order.transaction do
|
19
|
+
@order = KktShoppe::Order.new(safe_params)
|
20
|
+
@order.status = 'confirming'
|
21
|
+
|
22
|
+
if safe_params[:customer_id]
|
23
|
+
@customer = KktShoppe::Customer.find safe_params[:customer_id]
|
24
|
+
@order.first_name = @customer.first_name
|
25
|
+
@order.last_name = @customer.last_name
|
26
|
+
@order.company = @customer.company
|
27
|
+
@order.email_address = @customer.email
|
28
|
+
@order.phone_number = @customer.phone
|
29
|
+
if @customer.addresses.billing.present?
|
30
|
+
billing = @customer.addresses.billing.first
|
31
|
+
@order.billing_address1 = billing.address1
|
32
|
+
@order.billing_address2 = billing.address2
|
33
|
+
@order.billing_address3 = billing.address3
|
34
|
+
@order.billing_address4 = billing.address4
|
35
|
+
@order.billing_postcode = billing.postcode
|
36
|
+
@order.billing_country_id = billing.country_id
|
37
|
+
end
|
38
|
+
if @customer.addresses.delivery.present?
|
39
|
+
delivery = @customer.addresses.delivery.first
|
40
|
+
@order.delivery_address1 = delivery.address1
|
41
|
+
@order.delivery_address2 = delivery.address2
|
42
|
+
@order.delivery_address3 = delivery.address3
|
43
|
+
@order.delivery_address4 = delivery.address4
|
44
|
+
@order.delivery_postcode = delivery.postcode
|
45
|
+
@order.delivery_country_id = delivery.country_id
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
if !request.xhr? && @order.save
|
50
|
+
@order.confirm!
|
51
|
+
redirect_to @order, :notice => t('kkt_shoppe.orders.create_notice')
|
52
|
+
else
|
53
|
+
@order.order_items.build(:ordered_item_type => 'KktShoppe::Product')
|
54
|
+
render :action => "new"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
rescue KktShoppe::Errors::InsufficientStockToFulfil => e
|
58
|
+
flash.now[:alert] = t('kkt_shoppe.orders.insufficient_stock_order', out_of_stock_items: e.out_of_stock_items.map { |t| t.ordered_item.full_name }.to_sentence)
|
59
|
+
render :action => 'new'
|
60
|
+
end
|
61
|
+
|
62
|
+
def show
|
63
|
+
@payments = @order.payments.to_a
|
64
|
+
end
|
65
|
+
|
66
|
+
def update
|
67
|
+
@order.attributes = safe_params
|
68
|
+
if !request.xhr? && @order.update_attributes(safe_params)
|
69
|
+
redirect_to @order, :notice => t('kkt_shoppe.orders.update_notice')
|
70
|
+
else
|
71
|
+
render :action => "edit"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def search
|
76
|
+
index
|
77
|
+
render :action => "index"
|
78
|
+
end
|
79
|
+
|
80
|
+
def accept
|
81
|
+
@order.accept!(current_user)
|
82
|
+
redirect_to @order, :notice => t('kkt_shoppe.orders.accept_notice')
|
83
|
+
rescue KktShoppe::Errors::PaymentDeclined => e
|
84
|
+
redirect_to @order, :alert => e.message
|
85
|
+
end
|
86
|
+
|
87
|
+
def reject
|
88
|
+
@order.reject!(current_user)
|
89
|
+
redirect_to @order, :notice => t('kkt_shoppe.orders.reject_notice')
|
90
|
+
rescue KktShoppe::Errors::PaymentDeclined => e
|
91
|
+
redirect_to @order, :alert => e.message
|
92
|
+
end
|
93
|
+
|
94
|
+
def ship
|
95
|
+
@order.ship!(params[:consignment_number], current_user)
|
96
|
+
redirect_to @order, :notice => t('kkt_shoppe.orders.ship_notice')
|
97
|
+
end
|
98
|
+
|
99
|
+
def despatch_note
|
100
|
+
render :layout => 'kkt_shoppe/printable'
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def safe_params
|
106
|
+
params[:order].permit(
|
107
|
+
:customer_id,
|
108
|
+
:first_name, :last_name, :company,
|
109
|
+
:billing_address1, :billing_address2, :billing_address3, :billing_address4, :billing_postcode, :billing_country_id,
|
110
|
+
:separate_delivery_address,
|
111
|
+
:delivery_name, :delivery_address1, :delivery_address2, :delivery_address3, :delivery_address4, :delivery_postcode, :delivery_country_id,
|
112
|
+
:delivery_price, :delivery_service_id, :delivery_tax_amount,
|
113
|
+
:email_address, :phone_number,
|
114
|
+
:notes,
|
115
|
+
:order_items_attributes => [:ordered_item_id, :ordered_item_type, :quantity, :unit_price, :tax_amount, :id, :weight]
|
116
|
+
)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module KktShoppe
|
2
|
+
class PaymentsController < ApplicationController
|
3
|
+
|
4
|
+
before_filter { @order = KktShoppe::Order.find(params[:order_id]) }
|
5
|
+
before_filter { params[:id] && @payment = @order.payments.find(params[:id]) }
|
6
|
+
|
7
|
+
def create
|
8
|
+
payment = @order.payments.build(params[:payment].permit(:amount, :method, :reference))
|
9
|
+
if payment.save
|
10
|
+
redirect_to @order, :notice => t('kkt_shoppe.payments.create_notice')
|
11
|
+
else
|
12
|
+
redirect_to @order, :alert => payment.errors.full_messages.to_sentence
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def destroy
|
17
|
+
@payment.destroy
|
18
|
+
redirect_to @order, :notice => t('kkt_shoppe.payments.destroy_notice')
|
19
|
+
end
|
20
|
+
|
21
|
+
def refund
|
22
|
+
if request.post?
|
23
|
+
@payment.refund!(params[:amount])
|
24
|
+
redirect_to @order, :notice => t('kkt_shoppe.payments.refund_notice')
|
25
|
+
else
|
26
|
+
render :layout => false
|
27
|
+
end
|
28
|
+
rescue KktShoppe::Errors::RefundFailed => e
|
29
|
+
redirect_to @order, :alert => e.message
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module KktShoppe
|
2
|
+
class ProductCategoriesController < KktShoppe::ApplicationController
|
3
|
+
|
4
|
+
before_filter { @active_nav = :product_categories }
|
5
|
+
before_filter { params[:id] && @product_category = KktShoppe::ProductCategory.find(params[:id]) }
|
6
|
+
|
7
|
+
def index
|
8
|
+
@product_categories_without_parent = KktShoppe::ProductCategory.without_parent.ordered
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@product_category = KktShoppe::ProductCategory.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@product_category = KktShoppe::ProductCategory.new(safe_params)
|
17
|
+
if @product_category.save
|
18
|
+
redirect_to :product_categories, :flash => { :notice => t('kkt_shoppe.product_category.create_notice') }
|
19
|
+
else
|
20
|
+
render :action => "new"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def edit
|
25
|
+
end
|
26
|
+
|
27
|
+
def update
|
28
|
+
if @product_category.update(safe_params)
|
29
|
+
redirect_to [:edit, @product_category], :flash => { :notice => t('kkt_shoppe.product_category.update_notice') }
|
30
|
+
else
|
31
|
+
render :action => "edit"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def destroy
|
36
|
+
@product_category.destroy
|
37
|
+
redirect_to :product_categories, :flash => { :notice => t('kkt_shoppe.product_category.destroy_notice') }
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def safe_params
|
43
|
+
params[:product_category].permit(:name, :permalink, :description, :image_file, :parent_id, :permalink_includes_ancestors)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "globalize"
|
2
|
+
|
3
|
+
module KktShoppe
|
4
|
+
class ProductCategoryLocalisationsController < ApplicationController
|
5
|
+
|
6
|
+
before_filter { @active_nav = :product_categories }
|
7
|
+
before_filter { @product_category = KktShoppe::ProductCategory.find(params[:product_category_id]) }
|
8
|
+
before_filter { params[:id] && @localisation = @product_category.translations.find(params[:id]) }
|
9
|
+
|
10
|
+
def index
|
11
|
+
@localisations = @product_category.translations
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@localisation = @product_category.translations.new
|
16
|
+
render :action => "form"
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
if I18n.available_locales.include? safe_params[:locale].to_sym
|
21
|
+
I18n.locale = safe_params[:locale].to_sym
|
22
|
+
|
23
|
+
if @product_category.update(safe_params)
|
24
|
+
I18n.locale = I18n.default_locale
|
25
|
+
redirect_to [@product_category, :localisations], :flash => { :notice => t("kkt_shoppe.localisations.localisation_created") }
|
26
|
+
else
|
27
|
+
render :action => "edit"
|
28
|
+
end
|
29
|
+
else
|
30
|
+
redirect_to [@product_category, :localisations]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def edit
|
35
|
+
render :action => "form"
|
36
|
+
end
|
37
|
+
|
38
|
+
def update
|
39
|
+
if @localisation.update(safe_params)
|
40
|
+
redirect_to [@product_category, :localisations], :notice => t('kkt_shoppe.localisations.localisation_updated')
|
41
|
+
else
|
42
|
+
render :action => "form"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def destroy
|
47
|
+
@localisation.destroy
|
48
|
+
redirect_to [@product_category, :localisations], :notice => t('kkt_shoppe.localisations.localisation_destroyed')
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def safe_params
|
54
|
+
params[:product_category_translation].permit(:name, :locale, :permalink, :description)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|