kylekthompson-shoppe 1.0.7
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/shoppe/chosen-sprite.png +0 -0
- data/app/assets/images/shoppe/chosen-sprite@2x.png +0 -0
- data/app/assets/images/shoppe/document.svg +1 -0
- data/app/assets/images/shoppe/icons/bag.svg +1 -0
- data/app/assets/images/shoppe/icons/balance.svg +1 -0
- data/app/assets/images/shoppe/icons/box.svg +1 -0
- data/app/assets/images/shoppe/icons/building.svg +1 -0
- data/app/assets/images/shoppe/icons/chart.svg +1 -0
- data/app/assets/images/shoppe/icons/chat.svg +1 -0
- data/app/assets/images/shoppe/icons/checkbox.svg +1 -0
- data/app/assets/images/shoppe/icons/checkbox2.svg +1 -0
- data/app/assets/images/shoppe/icons/cloud.svg +1 -0
- data/app/assets/images/shoppe/icons/cone.svg +1 -0
- data/app/assets/images/shoppe/icons/credit_card.svg +1 -0
- data/app/assets/images/shoppe/icons/currency.svg +1 -0
- data/app/assets/images/shoppe/icons/edit.svg +14 -0
- data/app/assets/images/shoppe/icons/flowchart.svg +1 -0
- data/app/assets/images/shoppe/icons/gift.svg +1 -0
- data/app/assets/images/shoppe/icons/globe.svg +1 -0
- data/app/assets/images/shoppe/icons/id.svg +1 -0
- data/app/assets/images/shoppe/icons/id2.svg +1 -0
- data/app/assets/images/shoppe/icons/locked.svg +1 -0
- data/app/assets/images/shoppe/icons/report.svg +1 -0
- data/app/assets/images/shoppe/icons/search.svg +1 -0
- data/app/assets/images/shoppe/icons/support.svg +1 -0
- data/app/assets/images/shoppe/icons/tags.svg +1 -0
- data/app/assets/images/shoppe/icons/toolbox.svg +1 -0
- data/app/assets/images/shoppe/icons/unlocked.svg +1 -0
- data/app/assets/images/shoppe/icons/wallet.svg +1 -0
- data/app/assets/images/shoppe/logo.svg +47 -0
- data/app/assets/images/shoppe/move.svg +1 -0
- data/app/assets/images/shoppe/shoppe.svg +25 -0
- data/app/assets/images/shoppe/square.svg +9 -0
- data/app/assets/images/shoppe/statuses/accepted.svg +14 -0
- data/app/assets/images/shoppe/statuses/paid.svg +16 -0
- data/app/assets/images/shoppe/statuses/received.svg +15 -0
- data/app/assets/images/shoppe/statuses/rejected.svg +14 -0
- data/app/assets/images/shoppe/statuses/shipped.svg +14 -0
- data/app/assets/images/shoppe/table-tear-off.png +0 -0
- data/app/assets/javascripts/shoppe/application.coffee +123 -0
- data/app/assets/javascripts/shoppe/chosen.jquery.js +1166 -0
- data/app/assets/javascripts/shoppe/jquery_ui.js +6 -0
- data/app/assets/javascripts/shoppe/mousetrap.js +9 -0
- data/app/assets/javascripts/shoppe/order_form.coffee +47 -0
- data/app/assets/stylesheets/shoppe/application.scss +601 -0
- data/app/assets/stylesheets/shoppe/chosen.scss +424 -0
- data/app/assets/stylesheets/shoppe/dialog.scss +25 -0
- data/app/assets/stylesheets/shoppe/elements.scss +79 -0
- data/app/assets/stylesheets/shoppe/printable.scss +67 -0
- data/app/assets/stylesheets/shoppe/reset.scss +93 -0
- data/app/assets/stylesheets/shoppe/sub.scss +106 -0
- data/app/assets/stylesheets/shoppe/variables.scss +1 -0
- data/app/controllers/shoppe/addresses_controller.rb +47 -0
- data/app/controllers/shoppe/application_controller.rb +46 -0
- data/app/controllers/shoppe/attachments_controller.rb +14 -0
- data/app/controllers/shoppe/countries_controller.rb +47 -0
- data/app/controllers/shoppe/customers_controller.rb +55 -0
- data/app/controllers/shoppe/dashboard_controller.rb +9 -0
- data/app/controllers/shoppe/delivery_service_prices_controller.rb +45 -0
- data/app/controllers/shoppe/delivery_services_controller.rb +47 -0
- data/app/controllers/shoppe/orders_controller.rb +119 -0
- data/app/controllers/shoppe/payments_controller.rb +33 -0
- data/app/controllers/shoppe/product_categories_controller.rb +47 -0
- data/app/controllers/shoppe/product_category_localisations_controller.rb +58 -0
- data/app/controllers/shoppe/product_localisations_controller.rb +58 -0
- data/app/controllers/shoppe/products_controller.rb +58 -0
- data/app/controllers/shoppe/sessions_controller.rb +34 -0
- data/app/controllers/shoppe/settings_controller.rb +16 -0
- data/app/controllers/shoppe/stock_level_adjustments_controller.rb +40 -0
- data/app/controllers/shoppe/tax_rates_controller.rb +49 -0
- data/app/controllers/shoppe/users_controller.rb +53 -0
- data/app/controllers/shoppe/variants_controller.rb +50 -0
- data/app/helpers/shoppe/application_helper.rb +60 -0
- data/app/helpers/shoppe/product_category_helper.rb +36 -0
- data/app/mailers/shoppe/order_mailer.rb +25 -0
- data/app/mailers/shoppe/user_mailer.rb +10 -0
- data/app/models/shoppe/address.rb +44 -0
- data/app/models/shoppe/country.rb +27 -0
- data/app/models/shoppe/customer.rb +41 -0
- data/app/models/shoppe/delivery_service.rb +33 -0
- data/app/models/shoppe/delivery_service_price.rb +31 -0
- data/app/models/shoppe/order.rb +100 -0
- data/app/models/shoppe/order/actions.rb +94 -0
- data/app/models/shoppe/order/billing.rb +105 -0
- data/app/models/shoppe/order/delivery.rb +229 -0
- data/app/models/shoppe/order/states.rb +69 -0
- data/app/models/shoppe/order_item.rb +239 -0
- data/app/models/shoppe/payment.rb +86 -0
- data/app/models/shoppe/product.rb +189 -0
- data/app/models/shoppe/product/product_attributes.rb +20 -0
- data/app/models/shoppe/product/variants.rb +51 -0
- data/app/models/shoppe/product_attribute.rb +66 -0
- data/app/models/shoppe/product_categorization.rb +14 -0
- data/app/models/shoppe/product_category.rb +75 -0
- data/app/models/shoppe/setting.rb +68 -0
- data/app/models/shoppe/stock_level_adjustment.rb +19 -0
- data/app/models/shoppe/tax_rate.rb +46 -0
- data/app/models/shoppe/user.rb +49 -0
- data/app/validators/permalink_validator.rb +7 -0
- data/app/views/layouts/shoppe/application.html.haml +34 -0
- data/app/views/layouts/shoppe/printable.html.haml +11 -0
- data/app/views/layouts/shoppe/sub.html.haml +10 -0
- data/app/views/shoppe/addresses/_form.html.haml +33 -0
- data/app/views/shoppe/addresses/edit.html.haml +5 -0
- data/app/views/shoppe/addresses/new.html.haml +5 -0
- data/app/views/shoppe/countries/_form.html.haml +35 -0
- data/app/views/shoppe/countries/edit.html.haml +6 -0
- data/app/views/shoppe/countries/index.html.haml +25 -0
- data/app/views/shoppe/countries/new.html.haml +7 -0
- data/app/views/shoppe/customers/_addresses.html.haml +20 -0
- data/app/views/shoppe/customers/_form.html.haml +30 -0
- data/app/views/shoppe/customers/_search_form.html.haml +13 -0
- data/app/views/shoppe/customers/edit.html.haml +5 -0
- data/app/views/shoppe/customers/index.html.haml +32 -0
- data/app/views/shoppe/customers/new.html.haml +5 -0
- data/app/views/shoppe/customers/show.html.haml +53 -0
- data/app/views/shoppe/delivery_service_prices/_form.html.haml +44 -0
- data/app/views/shoppe/delivery_service_prices/edit.html.haml +6 -0
- data/app/views/shoppe/delivery_service_prices/index.html.haml +23 -0
- data/app/views/shoppe/delivery_service_prices/new.html.haml +6 -0
- data/app/views/shoppe/delivery_services/_form.html.haml +38 -0
- data/app/views/shoppe/delivery_services/edit.html.haml +9 -0
- data/app/views/shoppe/delivery_services/index.html.haml +27 -0
- data/app/views/shoppe/delivery_services/new.html.haml +6 -0
- data/app/views/shoppe/order_mailer/accepted.text.erb +12 -0
- data/app/views/shoppe/order_mailer/received.text.erb +9 -0
- data/app/views/shoppe/order_mailer/rejected.text.erb +10 -0
- data/app/views/shoppe/order_mailer/shipped.text.erb +16 -0
- data/app/views/shoppe/orders/_form.html.haml +58 -0
- data/app/views/shoppe/orders/_order_details.html.haml +57 -0
- data/app/views/shoppe/orders/_order_items.html.haml +38 -0
- data/app/views/shoppe/orders/_order_items_form.html.haml +61 -0
- data/app/views/shoppe/orders/_payments_form.html.haml +15 -0
- data/app/views/shoppe/orders/_payments_table.html.haml +37 -0
- data/app/views/shoppe/orders/_search_form.html.haml +24 -0
- data/app/views/shoppe/orders/_status_bar.html.haml +35 -0
- data/app/views/shoppe/orders/despatch_note.html.haml +45 -0
- data/app/views/shoppe/orders/edit.html.haml +21 -0
- data/app/views/shoppe/orders/index.html.haml +39 -0
- data/app/views/shoppe/orders/new.html.haml +14 -0
- data/app/views/shoppe/orders/show.html.haml +25 -0
- data/app/views/shoppe/payments/refund.html.haml +13 -0
- data/app/views/shoppe/product_categories/_form.html.haml +50 -0
- data/app/views/shoppe/product_categories/edit.html.haml +8 -0
- data/app/views/shoppe/product_categories/index.html.haml +27 -0
- data/app/views/shoppe/product_categories/new.html.haml +6 -0
- data/app/views/shoppe/product_category_localisations/form.html.haml +29 -0
- data/app/views/shoppe/product_category_localisations/index.html.haml +26 -0
- data/app/views/shoppe/product_localisations/form.html.haml +32 -0
- data/app/views/shoppe/product_localisations/index.html.haml +26 -0
- data/app/views/shoppe/products/_form.html.haml +118 -0
- data/app/views/shoppe/products/_table.html.haml +42 -0
- data/app/views/shoppe/products/edit.html.haml +9 -0
- data/app/views/shoppe/products/import.html.haml +67 -0
- data/app/views/shoppe/products/index.html.haml +9 -0
- data/app/views/shoppe/products/new.html.haml +7 -0
- data/app/views/shoppe/sessions/new.html.haml +12 -0
- data/app/views/shoppe/sessions/reset.html.haml +12 -0
- data/app/views/shoppe/settings/edit.html.haml +19 -0
- data/app/views/shoppe/shared/error.html.haml +6 -0
- data/app/views/shoppe/stock_level_adjustments/index.html.haml +40 -0
- data/app/views/shoppe/tax_rates/form.html.haml +28 -0
- data/app/views/shoppe/tax_rates/index.html.haml +17 -0
- data/app/views/shoppe/user_mailer/new_password.text.erb +9 -0
- data/app/views/shoppe/users/_form.html.haml +27 -0
- data/app/views/shoppe/users/edit.html.haml +5 -0
- data/app/views/shoppe/users/index.html.haml +17 -0
- data/app/views/shoppe/users/new.html.haml +7 -0
- data/app/views/shoppe/variants/form.html.haml +68 -0
- data/app/views/shoppe/variants/index.html.haml +33 -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_shoppe_initial_schema.rb +175 -0
- data/db/migrate/20131024201501_add_address_type_to_shoppe_tax_rates.rb +5 -0
- data/db/migrate/20131024204815_create_shoppe_payments.rb +32 -0
- data/db/migrate/20131102143930_remove_default_on_order_item_weight.rb +9 -0
- data/db/migrate/20141013192427_create_shoppe_customers.rb +14 -0
- data/db/migrate/20141026175622_add_indexes_to_shoppe_order_items.rb +6 -0
- data/db/migrate/20141026175943_add_indexes_to_shoppe_orders.rb +7 -0
- data/db/migrate/20141026180333_add_indexes_to_shoppe_payments.rb +6 -0
- data/db/migrate/20141026180835_add_indexes_to_shoppe_product_attributes.rb +7 -0
- data/db/migrate/20141026180952_add_indexes_to_shoppe_product_categories.rb +5 -0
- data/db/migrate/20141026181040_add_indexes_to_shoppe_products.rb +8 -0
- data/db/migrate/20141026181312_add_indexes_to_shoppe_settings.rb +5 -0
- data/db/migrate/20141026181354_add_indexes_to_shoppe_stock_level_adjustments.rb +6 -0
- data/db/migrate/20141026181559_add_indexes_to_shoppe_users.rb +5 -0
- data/db/migrate/20141026181716_add_indexes_to_shoppe_delivery_services.rb +9 -0
- data/db/migrate/20141026181717_allow_multiple_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_shoppe_addresses.rb +17 -0
- data/db/migrate/20150315215633_add_customer_to_shoppe_orders.rb +5 -0
- data/db/migrate/20150513171350_create_shoppe_product_category_translation_table.rb +17 -0
- data/db/migrate/20150519173350_create_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/shoppe.rb +60 -0
- data/lib/shoppe/associated_countries.rb +20 -0
- data/lib/shoppe/country_importer.rb +15 -0
- data/lib/shoppe/default_navigation.rb +21 -0
- data/lib/shoppe/engine.rb +55 -0
- data/lib/shoppe/error.rb +21 -0
- data/lib/shoppe/errors/inappropriate_delivery_service.rb +6 -0
- data/lib/shoppe/errors/insufficient_stock_to_fulfil.rb +15 -0
- data/lib/shoppe/errors/invalid_configuration.rb +6 -0
- data/lib/shoppe/errors/not_enough_stock.rb +15 -0
- data/lib/shoppe/errors/payment_declined.rb +6 -0
- data/lib/shoppe/errors/refund_failed.rb +6 -0
- data/lib/shoppe/errors/unorderable_item.rb +6 -0
- data/lib/shoppe/navigation_manager.rb +81 -0
- data/lib/shoppe/orderable_item.rb +39 -0
- data/lib/shoppe/settings.rb +26 -0
- data/lib/shoppe/settings_loader.rb +16 -0
- data/lib/shoppe/setup_generator.rb +10 -0
- data/lib/shoppe/version.rb +3 -0
- data/lib/shoppe/view_helpers.rb +16 -0
- data/lib/tasks/shoppe.rake +29 -0
- metadata +662 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
module Shoppe
|
2
|
+
class DeliveryServicePricesController < Shoppe::ApplicationController
|
3
|
+
|
4
|
+
before_filter { @active_nav = :delivery_services }
|
5
|
+
before_filter { @delivery_service = Shoppe::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('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('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('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 Shoppe
|
2
|
+
class DeliveryServicesController < Shoppe::ApplicationController
|
3
|
+
|
4
|
+
before_filter { @active_nav = :delivery_services }
|
5
|
+
before_filter { params[:id] && @delivery_service = Shoppe::DeliveryService.find(params[:id]) }
|
6
|
+
|
7
|
+
def index
|
8
|
+
@delivery_services = Shoppe::DeliveryService.all
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@delivery_service = Shoppe::DeliveryService.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@delivery_service = Shoppe::DeliveryService.new(safe_params)
|
17
|
+
if @delivery_service.save
|
18
|
+
redirect_to :delivery_services, :flash => {:notice => t('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('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('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 Shoppe
|
2
|
+
class OrdersController < Shoppe::ApplicationController
|
3
|
+
|
4
|
+
before_filter { @active_nav = :orders }
|
5
|
+
before_filter { params[:id] && @order = Shoppe::Order.find(params[:id])}
|
6
|
+
|
7
|
+
def index
|
8
|
+
@query = Shoppe::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 = Shoppe::Order.new
|
14
|
+
@order.order_items.build(:ordered_item_type => 'Shoppe::Product')
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
Shoppe::Order.transaction do
|
19
|
+
@order = Shoppe::Order.new(safe_params)
|
20
|
+
@order.status = 'confirming'
|
21
|
+
|
22
|
+
if safe_params[:customer_id]
|
23
|
+
@customer = Shoppe::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('shoppe.orders.create_notice')
|
52
|
+
else
|
53
|
+
@order.order_items.build(:ordered_item_type => 'Shoppe::Product')
|
54
|
+
render :action => "new"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
rescue Shoppe::Errors::InsufficientStockToFulfil => e
|
58
|
+
flash.now[:alert] = t('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('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('shoppe.orders.accept_notice')
|
83
|
+
rescue Shoppe::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('shoppe.orders.reject_notice')
|
90
|
+
rescue Shoppe::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('shoppe.orders.ship_notice')
|
97
|
+
end
|
98
|
+
|
99
|
+
def despatch_note
|
100
|
+
render :layout => '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 Shoppe
|
2
|
+
class PaymentsController < ApplicationController
|
3
|
+
|
4
|
+
before_filter { @order = Shoppe::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('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('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('shoppe.payments.refund_notice')
|
25
|
+
else
|
26
|
+
render :layout => false
|
27
|
+
end
|
28
|
+
rescue Shoppe::Errors::RefundFailed => e
|
29
|
+
redirect_to @order, :alert => e.message
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Shoppe
|
2
|
+
class ProductCategoriesController < Shoppe::ApplicationController
|
3
|
+
|
4
|
+
before_filter { @active_nav = :product_categories }
|
5
|
+
before_filter { params[:id] && @product_category = Shoppe::ProductCategory.find(params[:id]) }
|
6
|
+
|
7
|
+
def index
|
8
|
+
@product_categories_without_parent = Shoppe::ProductCategory.without_parent.ordered
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@product_category = Shoppe::ProductCategory.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@product_category = Shoppe::ProductCategory.new(safe_params)
|
17
|
+
if @product_category.save
|
18
|
+
redirect_to :product_categories, :flash => { :notice => t('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('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('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 Shoppe
|
4
|
+
class ProductCategoryLocalisationsController < ApplicationController
|
5
|
+
|
6
|
+
before_filter { @active_nav = :product_categories }
|
7
|
+
before_filter { @product_category = Shoppe::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("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('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('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
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "globalize"
|
2
|
+
|
3
|
+
module Shoppe
|
4
|
+
class ProductLocalisationsController < ApplicationController
|
5
|
+
|
6
|
+
before_filter { @active_nav = :products }
|
7
|
+
before_filter { @product = Shoppe::Product.find(params[:product_id]) }
|
8
|
+
before_filter { params[:id] && @localisation = @product.translations.find(params[:id]) }
|
9
|
+
|
10
|
+
def index
|
11
|
+
@localisations = @product.translations
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@localisation = @product.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.update(safe_params)
|
24
|
+
I18n.locale = I18n.default_locale
|
25
|
+
redirect_to [@product, :localisations], :flash => { :notice => t("shoppe.localisations.localisation_created") }
|
26
|
+
else
|
27
|
+
render :action => "form"
|
28
|
+
end
|
29
|
+
else
|
30
|
+
redirect_to [@product, :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, :localisations], :notice => t('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, :localisations], :notice => t('shoppe.localisations.localisation_destroyed')
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def safe_params
|
54
|
+
params[:product_translation].permit(:name, :locale, :permalink, :description, :short_description)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Shoppe
|
2
|
+
class ProductsController < Shoppe::ApplicationController
|
3
|
+
|
4
|
+
before_filter { @active_nav = :products }
|
5
|
+
before_filter { params[:id] && @product = Shoppe::Product.root.find(params[:id]) }
|
6
|
+
|
7
|
+
def index
|
8
|
+
@products = Shoppe::Product.root.includes(:translations, :stock_level_adjustments, :default_image, :product_categories, :variants).order(:name).group_by(&:product_category).sort_by { |cat,pro| cat.name }
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@product = Shoppe::Product.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@product = Shoppe::Product.new(safe_params)
|
17
|
+
if @product.save
|
18
|
+
redirect_to :products, :flash => {:notice => t('shoppe.products.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.update(safe_params)
|
29
|
+
redirect_to [:edit, @product], :flash => {:notice => t('shoppe.products.update_notice') }
|
30
|
+
else
|
31
|
+
render :action => "edit"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def destroy
|
36
|
+
@product.destroy
|
37
|
+
redirect_to :products, :flash => {:notice => t('shoppe.products.destroy_notice')}
|
38
|
+
end
|
39
|
+
|
40
|
+
def import
|
41
|
+
if request.post?
|
42
|
+
if params[:import].nil?
|
43
|
+
redirect_to import_products_path, :flash => {:alert => I18n.t('shoppe.imports.errors.no_file')}
|
44
|
+
else
|
45
|
+
Shoppe::Product.import(params[:import][:import_file])
|
46
|
+
redirect_to products_path, :flash => {:notice => I18n.t("shoppe.products.imports.success")}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def safe_params
|
54
|
+
params[:product].permit(:name, :sku, :permalink, :description, :short_description, :weight, :price, :cost_price, :tax_rate_id, :stock_control, :default_image_file, :data_sheet_file, :active, :featured, :in_the_box, :product_attributes_array => [:key, :value, :searchable, :public], :product_category_ids => [])
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|