shoppe 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/app/assets/javascripts/shoppe/application.coffee +57 -1
  2. data/app/assets/javascripts/shoppe/mousetrap.js +9 -0
  3. data/app/assets/stylesheets/shoppe/application.scss +70 -59
  4. data/app/assets/stylesheets/shoppe/dialog.scss +10 -0
  5. data/app/assets/stylesheets/shoppe/sub.scss +15 -0
  6. data/app/controllers/shoppe/application_controller.rb +13 -1
  7. data/app/controllers/shoppe/attachments_controller.rb +10 -8
  8. data/app/controllers/shoppe/dashboard_controller.rb +6 -4
  9. data/app/controllers/shoppe/delivery_service_prices_controller.rb +33 -31
  10. data/app/controllers/shoppe/delivery_services_controller.rb +34 -32
  11. data/app/controllers/shoppe/orders_controller.rb +40 -38
  12. data/app/controllers/shoppe/product_categories_controller.rb +34 -32
  13. data/app/controllers/shoppe/products_controller.rb +32 -44
  14. data/app/controllers/shoppe/sessions_controller.rb +24 -22
  15. data/app/controllers/shoppe/stock_level_adjustments_controller.rb +40 -0
  16. data/app/controllers/shoppe/tax_rates_controller.rb +35 -33
  17. data/app/controllers/shoppe/users_controller.rb +40 -33
  18. data/app/controllers/shoppe/variants_controller.rb +50 -0
  19. data/app/helpers/shoppe/shoppe_helper.rb +2 -2
  20. data/app/mailers/shoppe/order_mailer.rb +20 -18
  21. data/app/models/shoppe/country.rb +1 -1
  22. data/app/models/shoppe/delivery_service.rb +17 -15
  23. data/app/models/shoppe/delivery_service_price.rb +18 -16
  24. data/app/models/shoppe/order.rb +293 -290
  25. data/app/models/shoppe/order_item.rb +115 -113
  26. data/app/models/shoppe/product.rb +76 -54
  27. data/app/models/shoppe/product/product_attributes.rb +12 -10
  28. data/app/models/shoppe/product/variants.rb +26 -0
  29. data/app/models/shoppe/product_attribute.rb +40 -38
  30. data/app/models/shoppe/product_category.rb +16 -14
  31. data/app/models/shoppe/stock_level_adjustment.rb +1 -2
  32. data/app/models/shoppe/tax_rate.rb +2 -2
  33. data/app/models/shoppe/user.rb +34 -32
  34. data/app/views/shoppe/orders/index.html.haml +3 -4
  35. data/app/views/shoppe/orders/show.html.haml +5 -5
  36. data/app/views/shoppe/products/_form.html.haml +28 -27
  37. data/app/views/shoppe/products/_table.html.haml +42 -0
  38. data/app/views/shoppe/products/edit.html.haml +2 -1
  39. data/app/views/shoppe/products/index.html.haml +1 -24
  40. data/app/views/shoppe/shared/error.html.haml +4 -0
  41. data/app/views/shoppe/{products/stock_levels.html.haml → stock_level_adjustments/index.html.haml} +12 -6
  42. data/app/views/shoppe/variants/form.html.haml +64 -0
  43. data/app/views/shoppe/variants/index.html.haml +33 -0
  44. data/config/routes.rb +2 -1
  45. data/config/shoppe.example.yml +16 -2
  46. data/db/migrate/20131022090919_refactor_order_items_to_allow_any_product.rb +6 -0
  47. data/db/migrate/20131022092904_rename_product_title_to_name.rb +5 -0
  48. data/db/migrate/20131022093538_stock_level_adjustments_should_be_polymorphic.rb +6 -0
  49. data/db/migrate/20131022135331_add_parent_id_to_products.rb +5 -0
  50. data/db/migrate/20131022145653_cost_price_should_be_default_to_zero.rb +9 -0
  51. data/db/seeds.rb +20 -20
  52. data/lib/shoppe.rb +2 -0
  53. data/lib/shoppe/errors/not_enough_stock.rb +1 -1
  54. data/lib/shoppe/errors/unorderable_item.rb +11 -0
  55. data/lib/shoppe/orderable_item.rb +39 -0
  56. data/lib/shoppe/version.rb +1 -1
  57. data/test/dummy/db/schema.rb +14 -11
  58. data/test/dummy/log/development.log +75 -0
  59. metadata +37 -5
@@ -1,7 +1,9 @@
1
1
  #= require jquery
2
2
  #= require jquery_ujs
3
+ #= require shoppe/mousetrap
3
4
  #= require shoppe/jquery_ui
4
5
  #= require shoppe/chosen.jquery
6
+ #= require nifty/dialog
5
7
  #= require_tree .
6
8
 
7
9
  $ ->
@@ -39,4 +41,58 @@ $ ->
39
41
 
40
42
  # Chosen
41
43
  $('select.chosen').chosen()
42
- $('select.chosen-with-deselect').chosen({allow_single_deselect: true})
44
+ $('select.chosen-with-deselect').chosen({allow_single_deselect: true})
45
+
46
+ # Open AJAX dialogs
47
+ $('a[rel=dialog]').on 'click', ->
48
+ element = $(this)
49
+ options = {}
50
+ options.width = element.data('dialog-width') if element.data('dialog-width')
51
+ options.offset = element.data('dialog-offset') if element.data('dialog-offset')
52
+ options.behavior = element.data('dialog-behavior') if element.data('dialog-behavior')
53
+ options.id = 'ajax'
54
+ options.url = element.attr('href')
55
+ Nifty.Dialog.open(options)
56
+ false
57
+
58
+ #
59
+ # Stock Level Adjustment dialog beavior
60
+ #
61
+ Nifty.Dialog.addBehavior
62
+ name: 'stockLevelAdjustments'
63
+ onLoad: (dialog,options)->
64
+ $('input[type=text]:first', dialog).focus()
65
+ $(dialog).on 'submit', 'form', ->
66
+ form = $(this)
67
+ $.ajax
68
+ url: form.attr('action')
69
+ method: 'POST'
70
+ data: form.serialize()
71
+ dataType: 'text'
72
+ success: (data)->
73
+ $('div.table', dialog).replaceWith(data)
74
+ $('input[type=text]:first', dialog).focus()
75
+ error: (xhr)->
76
+ if xhr.status == 422
77
+ alert xhr.responseText
78
+ else
79
+ alert 'An error occurred while saving the stock level.'
80
+ false
81
+ $(dialog).on 'click', 'nav.pagination a', ->
82
+ $.ajax
83
+ url: $(this).attr('href')
84
+ success: (data)->
85
+ $('div.table', dialog).replaceWith(data)
86
+ false
87
+
88
+ #
89
+ # Always fire keyboard shortcuts when focused on fields
90
+ #
91
+ Mousetrap.stopCallback = -> false
92
+
93
+ #
94
+ # Close dialogs on escape
95
+ #
96
+ Mousetrap.bind 'escape', ->
97
+ Nifty.Dialog.closeTopDialog()
98
+ false
@@ -0,0 +1,9 @@
1
+ /* mousetrap v1.4.5 craig.is/killing/mice */
2
+ (function(J,r,f){function s(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent("on"+b,c)}function A(a){if("keypress"==a.type){var b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return h[a.which]?h[a.which]:B[a.which]?B[a.which]:String.fromCharCode(a.which).toLowerCase()}function t(a){a=a||{};var b=!1,c;for(c in n)a[c]?b=!0:n[c]=0;b||(u=!1)}function C(a,b,c,d,e,v){var g,k,f=[],h=c.type;if(!l[a])return[];"keyup"==h&&w(a)&&(b=[a]);for(g=0;g<l[a].length;++g)if(k=
3
+ l[a][g],!(!d&&k.seq&&n[k.seq]!=k.level||h!=k.action||("keypress"!=h||c.metaKey||c.ctrlKey)&&b.sort().join(",")!==k.modifiers.sort().join(","))){var m=d&&k.seq==d&&k.level==v;(!d&&k.combo==e||m)&&l[a].splice(g,1);f.push(k)}return f}function K(a){var b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");return b}function x(a,b,c){m.stopCallback(b,b.target||b.srcElement,c)||!1!==a(b,c)||(b.preventDefault&&b.preventDefault(),b.stopPropagation&&b.stopPropagation(),
4
+ b.returnValue=!1,b.cancelBubble=!0)}function y(a){"number"!==typeof a.which&&(a.which=a.keyCode);var b=A(a);b&&("keyup"==a.type&&z===b?z=!1:m.handleKey(b,K(a),a))}function w(a){return"shift"==a||"ctrl"==a||"alt"==a||"meta"==a}function L(a,b,c,d){function e(b){return function(){u=b;++n[a];clearTimeout(D);D=setTimeout(t,1E3)}}function v(b){x(c,b,a);"keyup"!==d&&(z=A(b));setTimeout(t,10)}for(var g=n[a]=0;g<b.length;++g){var f=g+1===b.length?v:e(d||E(b[g+1]).action);F(b[g],f,d,a,g)}}function E(a,b){var c,
5
+ d,e,f=[];c="+"===a?["+"]:a.split("+");for(e=0;e<c.length;++e)d=c[e],G[d]&&(d=G[d]),b&&"keypress"!=b&&H[d]&&(d=H[d],f.push("shift")),w(d)&&f.push(d);c=d;e=b;if(!e){if(!p){p={};for(var g in h)95<g&&112>g||h.hasOwnProperty(g)&&(p[h[g]]=g)}e=p[c]?"keydown":"keypress"}"keypress"==e&&f.length&&(e="keydown");return{key:d,modifiers:f,action:e}}function F(a,b,c,d,e){q[a+":"+c]=b;a=a.replace(/\s+/g," ");var f=a.split(" ");1<f.length?L(a,f,b,c):(c=E(a,c),l[c.key]=l[c.key]||[],C(c.key,c.modifiers,{type:c.action},
6
+ d,a,e),l[c.key][d?"unshift":"push"]({callback:b,modifiers:c.modifiers,action:c.action,seq:d,level:e,combo:a}))}var h={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},B={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},H={"~":"`","!":"1",
7
+ "@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},G={option:"alt",command:"meta","return":"enter",escape:"esc",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},p,l={},q={},n={},D,z=!1,I=!1,u=!1;for(f=1;20>f;++f)h[111+f]="f"+f;for(f=0;9>=f;++f)h[f+96]=f;s(r,"keypress",y);s(r,"keydown",y);s(r,"keyup",y);var m={bind:function(a,b,c){a=a instanceof Array?a:[a];for(var d=0;d<a.length;++d)F(a[d],b,c);return this},
8
+ unbind:function(a,b){return m.bind(a,function(){},b)},trigger:function(a,b){if(q[a+":"+b])q[a+":"+b]({},a);return this},reset:function(){l={};q={};return this},stopCallback:function(a,b){return-1<(" "+b.className+" ").indexOf(" mousetrap ")?!1:"INPUT"==b.tagName||"SELECT"==b.tagName||"TEXTAREA"==b.tagName||b.isContentEditable},handleKey:function(a,b,c){var d=C(a,b,c),e;b={};var f=0,g=!1;for(e=0;e<d.length;++e)d[e].seq&&(f=Math.max(f,d[e].level));for(e=0;e<d.length;++e)d[e].seq?d[e].level==f&&(g=!0,
9
+ b[d[e].seq]=1,x(d[e].callback,c,d[e].combo)):g||x(d[e].callback,c,d[e].combo);d="keypress"==c.type&&I;c.type!=u||w(a)||d||t(b);I=g&&"keydown"==c.type}};J.Mousetrap=m;"function"===typeof define&&define.amd&&define(m)})(window,document);
@@ -2,6 +2,8 @@
2
2
  *= require shoppe/reset
3
3
  *= require shoppe/elements
4
4
  *= require shoppe/chosen
5
+ *= require nifty/dialog
6
+ *= require shoppe/dialog
5
7
  *= require_self
6
8
  */
7
9
 
@@ -106,40 +108,7 @@ header.main {
106
108
  padding:15px;
107
109
  h3 { font-size:2.0em; font-weight:500;}
108
110
  }
109
-
110
- //
111
- // data table
112
- //
113
- div.table {
114
- p.info {
115
- overflow:hidden;
116
- margin-bottom:10px;
117
- color:#40454D;
118
- }
119
- table.data {
120
- width:100%;
121
- th, td { padding:10px;}
122
- thead th { border:1px solid #40454D; background:#40454D; text-align:left; font-weight:normal; font-size:0.9em; color:#fff; }
123
- tbody td { border:1px solid #cfd4dd; background:#fff;}
124
- a { color:inherit;}
125
- tbody th { text-align:left; background:#5B6270; border:1px solid #5B6270;font-size:1.2em; color:#fff;}
126
- tbody tr.empty td { padding:50px 0; text-align:center; color:#999; font-style:italic;}
127
- tfoot td.right { text-align:right; }
128
- tfoot td.bold { font-weight:bold;}
129
- tfoot td { border-top:0 solid #ccc; background:#fafafa;}
130
- tfoot tr:first-child td { border-top-width:3px;}
131
- tbody td a.edit { background:image-url('shoppe/icons/edit.svg') no-repeat; margin-top:3px;width:16px; width:16px; background-size:13px; display:inline-block; text-indent:-40000px; opacity:0.3}
132
- tbody td a.edit:hover { opacity:0.5}
133
- tbody tr.form {
134
- td { background:#f2f6fb;}
135
- input[type=text] { border:1px solid #CFD4DD; padding:5px;}
136
- input[type=text]:focus { border-color:#9AC835;}
137
- td.desc input[type=text] { width:95%;}
138
- td.adjustment input[type=text] { width:50px; margin-right:5px;}
139
- }
140
- }
141
- }
142
-
111
+
143
112
 
144
113
  //
145
114
  // Status tags
@@ -295,7 +264,7 @@ header.main {
295
264
 
296
265
  dl.form {
297
266
  margin-top:15px;
298
- input.text { width:70%}
267
+ input.text { width:70%;}
299
268
  a.button { margin-right:5px;}
300
269
  }
301
270
 
@@ -360,30 +329,7 @@ header.main {
360
329
  float:right;
361
330
  }
362
331
  }
363
-
364
- //
365
- // pagination
366
- //
367
- nav.pagination {
368
- display:block;
369
- margin:25px 0;
370
- overflow:hidden;
371
- text-align:center;
372
- span {
373
- display:inline-block;
374
- border:1px solid #ccc;
375
- margin-right:3px;
376
- color:#333;
377
- background:#fff;
378
- &.current { background:#9AC835; border-color:#7B9F26; color:#fff; font-weight:600; padding:5px 10px;}
379
- a {
380
- padding:5px 10px;
381
- display:inline-block;
382
- color:inherit;
383
- text-decoration:none;
384
- }
385
- }
386
- }
332
+
387
333
 
388
334
 
389
335
 
@@ -426,4 +372,69 @@ input.text, textarea.text {
426
372
  font-family:$font;
427
373
  &:focus { border-color:#9AC835; }
428
374
  &.short { width:100px;}
375
+ }
376
+
377
+ //
378
+ // data table
379
+ //
380
+ div.table {
381
+ p.info {
382
+ overflow:hidden;
383
+ margin-bottom:10px;
384
+ color:#40454D;
385
+ }
386
+ table.data {
387
+ width:100%;
388
+ th, td { padding:10px; vertical-align:middle;}
389
+ thead th { border:1px solid #40454D; background:#40454D; text-align:left; font-weight:normal; font-size:0.9em; color:#fff; }
390
+ tbody td { border:1px solid #cfd4dd; background:#fff;}
391
+ a { color:inherit;}
392
+ tbody th { text-align:left; background:#5B6270; border:1px solid #5B6270;font-size:1.2em; color:#fff;}
393
+ tbody tr.empty td { padding:50px 0; text-align:center; color:#999; font-style:italic;}
394
+ tfoot td.right { text-align:right; }
395
+ tfoot td.bold { font-weight:bold;}
396
+ tfoot td { border-top:0 solid #ccc; background:#fafafa;}
397
+ tfoot tr:first-child td { border-top-width:3px;}
398
+ tbody td a.edit { background:image-url('shoppe/icons/edit.svg') no-repeat; margin-top:3px;width:16px; width:16px; background-size:13px; display:inline-block; text-indent:-40000px; opacity:0.3}
399
+ tbody td a.edit:hover { opacity:0.5}
400
+ tbody td.table {
401
+ padding:0;
402
+ table.data {
403
+ td { padding:10px; border-width:0; border-right-width:1px; border-bottom-width:1px;}
404
+ td:last-child { border-right-width:0;}
405
+ tr:last-child td { border-bottom-width:0;}
406
+ }
407
+ }
408
+ tbody tr.form {
409
+ td { background:#f2f6fb;}
410
+ input[type=text] { border:1px solid #CFD4DD; padding:5px;}
411
+ input[type=text]:focus { border-color:#9AC835;}
412
+ td.desc input[type=text] { width:95%;}
413
+ td.adjustment input[type=text] { width:50px; margin-right:5px;}
414
+ }
415
+ }
416
+ }
417
+
418
+ //
419
+ // pagination
420
+ //
421
+ nav.pagination {
422
+ display:block;
423
+ margin:25px 0;
424
+ overflow:hidden;
425
+ text-align:center;
426
+ span {
427
+ display:inline-block;
428
+ border:1px solid #ccc;
429
+ margin-right:3px;
430
+ color:#333;
431
+ background:#fff;
432
+ &.current { background:#9AC835; border-color:#7B9F26; color:#fff; font-weight:600; padding:5px 10px;}
433
+ a {
434
+ padding:5px 10px;
435
+ display:inline-block;
436
+ color:inherit;
437
+ text-decoration:none;
438
+ }
439
+ }
429
440
  }
@@ -0,0 +1,10 @@
1
+ div.niftyDialog {
2
+ h2 {
3
+ background:#fff;
4
+ border-bottom:1px solid #efefef;
5
+ font-size:1.2em;
6
+ color:#111;
7
+ }
8
+ padding:15px;
9
+ nav.pagination { margin:0; margin-top:15px;}
10
+ }
@@ -35,6 +35,21 @@ html.login {
35
35
  padding:15px 0;
36
36
  }
37
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
+ font-weight:500;
50
+ text-align:center;
51
+ p.back { margin-top:25px;}
52
+ }
38
53
 
39
54
  //
40
55
  // Primary login area
@@ -8,6 +8,11 @@ module Shoppe
8
8
  rescue_from ActiveRecord::DeleteRestrictionError do |e|
9
9
  redirect_to request.referer || root_path, :alert => e.message
10
10
  end
11
+
12
+ rescue_from Shoppe::Error do |e|
13
+ @exception = e
14
+ render :layout => 'shoppe/sub', :template => 'shoppe/shared/error'
15
+ end
11
16
 
12
17
  private
13
18
 
@@ -26,7 +31,7 @@ module Shoppe
26
31
 
27
32
  # Returns the currently logged in user
28
33
  def current_user
29
- @current_user ||= login_from_session || :false
34
+ @current_user ||= login_from_session || login_with_demo_mdoe || :false
30
35
  end
31
36
 
32
37
  # Attempt to find a user based on the value stored in the local session
@@ -36,6 +41,13 @@ module Shoppe
36
41
  end
37
42
  end
38
43
 
44
+ # Attempt to login using the demo mode
45
+ def login_with_demo_mdoe
46
+ if Shoppe.config[:demo_mode]
47
+ @user = User.first
48
+ end
49
+ end
50
+
39
51
  # Expose a current_user and logged_in? as helpers to views
40
52
  helper_method :current_user, :logged_in?
41
53
 
@@ -1,12 +1,14 @@
1
- class Shoppe::AttachmentsController < Shoppe::ApplicationController
1
+ module Shoppe
2
+ class AttachmentsController < Shoppe::ApplicationController
2
3
 
3
- def destroy
4
- @attachment = Nifty::Attachments::Attachment.find(params[:id])
5
- @attachment.destroy
6
- respond_to do |wants|
7
- wants.html { redirect_to request.referer, :notice => "Attachment removed successfully" }
8
- wants.json { render :status => 'complete' }
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 => "Attachment removed successfully" }
9
+ wants.json { render :status => 'complete' }
10
+ end
9
11
  end
10
- end
11
12
 
13
+ end
12
14
  end
@@ -1,7 +1,9 @@
1
- class Shoppe::DashboardController < Shoppe::ApplicationController
1
+ module Shoppe
2
+ class DashboardController < Shoppe::ApplicationController
2
3
 
3
- def home
4
- redirect_to :orders
5
- end
4
+ def home
5
+ redirect_to :orders
6
+ end
6
7
 
8
+ end
7
9
  end
@@ -1,43 +1,45 @@
1
- class Shoppe::DeliveryServicePricesController < Shoppe::ApplicationController
1
+ module Shoppe
2
+ class DeliveryServicePricesController < Shoppe::ApplicationController
2
3
 
3
- before_filter { @active_nav = :delivery_services }
4
- before_filter { @delivery_service = Shoppe::DeliveryService.find(params[:delivery_service_id])}
5
- before_filter { params[:id] && @delivery_service_price = @delivery_service.delivery_service_prices.find(params[:id])}
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])}
6
7
 
7
- def index
8
- @delivery_service_prices = @delivery_service.delivery_service_prices.ordered
9
- end
8
+ def index
9
+ @delivery_service_prices = @delivery_service.delivery_service_prices.ordered
10
+ end
10
11
 
11
- def new
12
- @delivery_service_price = @delivery_service.delivery_service_prices.build
13
- end
12
+ def new
13
+ @delivery_service_price = @delivery_service.delivery_service_prices.build
14
+ end
14
15
 
15
- def create
16
- @delivery_service_price = @delivery_service.delivery_service_prices.build(safe_params)
17
- if @delivery_service_price.save
18
- redirect_to [@delivery_service, :delivery_service_prices], :notice => "Price has been created successfully"
19
- else
20
- render :action => "new"
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 => "Price has been created successfully"
20
+ else
21
+ render :action => "new"
22
+ end
21
23
  end
22
- end
23
24
 
24
- def update
25
- if @delivery_service_price.update(safe_params)
26
- redirect_to [@delivery_service, :delivery_service_prices], :notice => "Price has been updated successfully"
27
- else
28
- render :action => "edit"
25
+ def update
26
+ if @delivery_service_price.update(safe_params)
27
+ redirect_to [@delivery_service, :delivery_service_prices], :notice => "Price has been updated successfully"
28
+ else
29
+ render :action => "edit"
30
+ end
29
31
  end
30
- end
31
32
 
32
- def destroy
33
- @delivery_service_price.destroy
34
- redirect_to [@delivery_service, :delivery_service_prices], :notice => "Price has been removed successfully"
35
- end
33
+ def destroy
34
+ @delivery_service_price.destroy
35
+ redirect_to [@delivery_service, :delivery_service_prices], :notice => "Price has been removed successfully"
36
+ end
36
37
 
37
- private
38
+ private
38
39
 
39
- def safe_params
40
- params[:delivery_service_price].permit(:price, :cost_price, :tax_rate_id, :min_weight, :max_weight, :code, :country_ids => [])
41
- end
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
42
43
 
44
+ end
43
45
  end
@@ -1,45 +1,47 @@
1
- class Shoppe::DeliveryServicesController < Shoppe::ApplicationController
1
+ module Shoppe
2
+ class DeliveryServicesController < Shoppe::ApplicationController
2
3
 
3
- before_filter { @active_nav = :delivery_services }
4
- before_filter { params[:id] && @delivery_service = Shoppe::DeliveryService.find(params[:id]) }
4
+ before_filter { @active_nav = :delivery_services }
5
+ before_filter { params[:id] && @delivery_service = Shoppe::DeliveryService.find(params[:id]) }
5
6
 
6
- def index
7
- @delivery_services = Shoppe::DeliveryService.all
8
- end
7
+ def index
8
+ @delivery_services = Shoppe::DeliveryService.all
9
+ end
9
10
 
10
- def new
11
- @delivery_service = Shoppe::DeliveryService.new
12
- end
11
+ def new
12
+ @delivery_service = Shoppe::DeliveryService.new
13
+ end
13
14
 
14
- def create
15
- @delivery_service = DeliveryService.new(safe_params)
16
- if @delivery_service.save
17
- redirect_to :delivery_services, :flash => {:notice => "Delivery Service has been created successfully"}
18
- else
19
- render :action => "new"
15
+ def create
16
+ @delivery_service = Shoppe::DeliveryService.new(safe_params)
17
+ if @delivery_service.save
18
+ redirect_to :delivery_services, :flash => {:notice => "Delivery Service has been created successfully"}
19
+ else
20
+ render :action => "new"
21
+ end
20
22
  end
21
- end
22
23
 
23
- def edit
24
- end
24
+ def edit
25
+ end
25
26
 
26
- def update
27
- if @delivery_service.update(safe_params)
28
- redirect_to [:edit, @delivery_service], :flash => {:notice => "Delivery Service has been updated successfully"}
29
- else
30
- render :action => "edit"
27
+ def update
28
+ if @delivery_service.update(safe_params)
29
+ redirect_to [:edit, @delivery_service], :flash => {:notice => "Delivery Service has been updated successfully"}
30
+ else
31
+ render :action => "edit"
32
+ end
31
33
  end
32
- end
33
34
 
34
- def destroy
35
- @delivery_service.destroy
36
- redirect_to :delivery_services, :flash => {:notice => "Delivery Service has been removed successfully"}
37
- end
35
+ def destroy
36
+ @delivery_service.destroy
37
+ redirect_to :delivery_services, :flash => {:notice => "Delivery Service has been removed successfully"}
38
+ end
38
39
 
39
- private
40
+ private
40
41
 
41
- def safe_params
42
- params[:delivery_service].permit(:name, :code, :active, :default, :courier, :tracking_url)
43
- end
42
+ def safe_params
43
+ params[:delivery_service].permit(:name, :code, :active, :default, :courier, :tracking_url)
44
+ end
44
45
 
46
+ end
45
47
  end