Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VenShop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Truong Ba Dieu
VenShop
Commits
c0dab2d3
Commit
c0dab2d3
authored
Jul 17, 2015
by
Truong Ba Dieu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor
parent
ce5b42b0
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5 additions
and
6 deletions
+5
-6
app/controllers/application_controller.rb
+1
-0
app/models/line_item.rb
+1
-1
app/models/order.rb
+0
-1
app/services/cart_service.rb
+0
-1
app/services/vacuum_aws_service.rb
+3
-3
No files found.
app/controllers/application_controller.rb
View file @
c0dab2d3
...
@@ -20,6 +20,7 @@ class ApplicationController < ActionController::Base
...
@@ -20,6 +20,7 @@ class ApplicationController < ActionController::Base
end
end
end
end
private
def
configure_permitted_parameters
def
configure_permitted_parameters
devise_parameter_sanitizer
.
for
(
:sign_up
).
push
(
:name
)
devise_parameter_sanitizer
.
for
(
:sign_up
).
push
(
:name
)
devise_parameter_sanitizer
.
for
(
:account_update
).
push
(
:name
)
devise_parameter_sanitizer
.
for
(
:account_update
).
push
(
:name
)
...
...
app/models/line_item.rb
View file @
c0dab2d3
...
@@ -18,7 +18,7 @@ class LineItem < ActiveRecord::Base
...
@@ -18,7 +18,7 @@ class LineItem < ActiveRecord::Base
def
check_product_stock
def
check_product_stock
change_square
=
quantity
-
quantity_was
change_square
=
quantity
-
quantity_was
if
change_square
>
product
.
stock
if
change_square
>
product
.
stock
self
.
errors
.
add
(
:quantity
,
"Product
#{
product
.
t
itle
}
is not enough in stock"
)
self
.
errors
.
add
(
:quantity
,
"Product
#{
product
.
t
ry
(
:title
)
}
is not enough in stock"
)
return
false
return
false
end
end
end
end
...
...
app/models/order.rb
View file @
c0dab2d3
...
@@ -7,7 +7,6 @@ class Order < ActiveRecord::Base
...
@@ -7,7 +7,6 @@ class Order < ActiveRecord::Base
accepts_nested_attributes_for
:line_items
accepts_nested_attributes_for
:line_items
def
recalculate
def
recalculate
puts
"===================================
#{
line_items
.
inject
(
0
)
{
|
sum
,
item
|
sum
+
item
.
quantity
*
item
.
price
}
}"
count
=
line_items
.
sum
(
:quantity
)
count
=
line_items
.
sum
(
:quantity
)
self
.
update_columns
(
self
.
update_columns
(
item_count:
count
,
item_count:
count
,
...
...
app/services/cart_service.rb
View file @
c0dab2d3
...
@@ -27,7 +27,6 @@ class CartService
...
@@ -27,7 +27,6 @@ class CartService
end
end
def
self
.
update_cart
(
current_order
,
params
)
def
self
.
update_cart
(
current_order
,
params
)
if
current_order
.
update_attributes
(
params
)
if
current_order
.
update_attributes
(
params
)
return
true
,
"Update cart successfully"
return
true
,
"Update cart successfully"
else
else
...
...
app/services/vacuum_aws_service.rb
View file @
c0dab2d3
...
@@ -5,9 +5,9 @@ class VacuumAwsService
...
@@ -5,9 +5,9 @@ class VacuumAwsService
request
=
Vacuum
.
new
(
options
[
:country_code
])
request
=
Vacuum
.
new
(
options
[
:country_code
])
request
.
configure
(
request
.
configure
(
aws_access_key_id:
'AKIAJ77C4CTZOP7TUVWQ'
,
aws_access_key_id:
ENV
[
'aws_access_key_id'
]
,
aws_secret_access_key:
'cYJYb/MLGV0M6oi1+DjlliL1cfxmh78tKXnT6ZmX'
,
aws_secret_access_key:
ENV
[
'aws_secret_access_key'
]
,
associate_tag:
'zigexn6400-22'
associate_tag:
ENV
[
'associate_tag'
]
)
)
request
.
item_search
(
request
.
item_search
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment