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
0
Merge Requests
0
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
huanvl
venshop
Commits
841bca67
Commit
841bca67
authored
Oct 29, 2013
by
vulehuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display error messages in some case raise exception
parent
e9292941
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
48 additions
and
32 deletions
+48
-32
venshop_app/app/assets/stylesheets/custom.css.scss
+4
-0
venshop_app/app/controllers/cards_controller.rb
+8
-6
venshop_app/app/controllers/product_categories_controller.rb
+6
-6
venshop_app/app/controllers/products_controller.rb
+16
-11
venshop_app/app/controllers/users_controller.rb
+8
-4
venshop_app/app/views/default_pages/home.html.erb
+2
-2
venshop_app/app/views/products/index.html.erb
+1
-0
venshop_app/app/views/products/show.html.erb
+3
-3
No files found.
venshop_app/app/assets/stylesheets/custom.css.scss
View file @
841bca67
...
...
@@ -469,3 +469,7 @@ footer {
.block-search-result
{
padding-top
:
10px
;
}
#block-message-visible
{
margin-top
:
10px
;
}
venshop_app/app/controllers/cards_controller.rb
View file @
841bca67
...
...
@@ -51,12 +51,14 @@ class CardsController < ApplicationController
# if add a product to card
# first time add to card
if
@card_infos
.
empty?
product
=
Product
.
find
(
params
[
:product_id
])
card_items
=
Array
.
new
card_items
.
push
({
product_id:
params
[
:product_id
],
quantity:
1
})
customer_info
=
Hash
.
new
@card_infos
=
{
card_items:
card_items
,
customer_info:
customer_info
}
session
[
:SHOPPING_CARD_SESSION_NAME
]
=
@card_infos
if
Product
.
exists?
(
params
[
:product_id
])
product
=
Product
.
find
(
params
[
:product_id
])
card_items
=
Array
.
new
card_items
.
push
({
product_id:
params
[
:product_id
],
quantity:
1
})
customer_info
=
Hash
.
new
@card_infos
=
{
card_items:
card_items
,
customer_info:
customer_info
}
session
[
:SHOPPING_CARD_SESSION_NAME
]
=
@card_infos
end
redirect_to
cards_path
else
card_items
=
@card_infos
[
:card_items
]
...
...
venshop_app/app/controllers/product_categories_controller.rb
View file @
841bca67
...
...
@@ -2,14 +2,14 @@ class ProductCategoriesController < ApplicationController
add_breadcrumb
"Products"
,
:products_path
def
show
term
=
ProductCategory
.
find
(
params
[
:id
])
if
term
.
nil?
@items
=
Array
.
new
@title
=
''
else
if
ProductCategory
.
exists?
(
params
[
:id
])
term
=
ProductCategory
.
find
(
params
[
:id
])
@items
=
Product
.
get_products_by_category
(
product_category_id:
params
[
:id
],
page:
params
[
:page
],
limit:
24
)
@title
=
term
.
name
add_breadcrumb
term
.
name
,
product_category_path
(
term
)
end
else
flash
[
:error
]
=
"Invalid product category!"
redirect_to
products_path
end
end
end
venshop_app/app/controllers/products_controller.rb
View file @
841bca67
...
...
@@ -7,19 +7,24 @@ class ProductsController < ApplicationController
end
def
show
@product
=
Product
.
find
(
params
[
:id
])
if
!
@product
.
status
user
=
current_user
if
user
.
nil?
||
@product
.
user_id
!=
user
.
id
redirect_to
products_path
begin
@product
=
Product
.
find
(
params
[
:id
])
if
!
@product
.
status
user
=
current_user
if
user
.
nil?
||
@product
.
user_id
!=
user
.
id
redirect_to
products_path
end
end
product_category
=
ProductCategory
.
find
(
@product
.
product_category_id
)
if
!
product_category
.
nil?
add_breadcrumb
product_category
.
name
,
product_category_path
(
product_category
)
add_breadcrumb
@product
.
name
,
product_path
(
@product
)
end
@other_products
=
Product
.
get_other_products
(
@product
.
id
,
product_category_id:
@product
.
product_category_id
,
limit:
20
)
rescue
flash
[
:error
]
=
"Invalid product!"
redirect_to
products_path
end
product_category
=
ProductCategory
.
find
(
@product
.
product_category_id
)
if
!
product_category
.
nil?
add_breadcrumb
product_category
.
name
,
product_category_path
(
product_category
)
add_breadcrumb
@product
.
name
,
product_path
(
@product
)
end
@other_products
=
Product
.
get_other_products
(
@product
.
id
,
product_category_id:
@product
.
product_category_id
,
limit:
20
)
end
def
new
...
...
venshop_app/app/controllers/users_controller.rb
View file @
841bca67
...
...
@@ -13,7 +13,12 @@ class UsersController < ApplicationController
end
def
show
@user
=
User
.
find
(
params
[
:id
])
if
User
.
exists?
(
params
[
:id
])
@user
=
User
.
find
(
params
[
:id
])
else
flash
[
:error
]
=
"Invalid user!"
redirect_to
root_path
end
end
def
create
...
...
@@ -56,7 +61,7 @@ class UsersController < ApplicationController
# Before filters
def
signed_in_user
unless
signed_in?
unless
signed_in?
store_location
redirect_to
signin_url
,
notice:
"Please sign in."
end
...
...
@@ -70,4 +75,4 @@ class UsersController < ApplicationController
def
admin_user
redirect_to
(
root_url
)
unless
current_user
.
admin?
end
end
\ No newline at end of file
end
venshop_app/app/views/default_pages/home.html.erb
View file @
841bca67
...
...
@@ -3,6 +3,7 @@
<h2
class=
"sprite-2"
>
Recommended Items
<span
class=
"sprite-2"
></span>
</h2>
<div
id=
"block-message-visible"
class=
"hidden"
></div>
<%=
render
'shared/grid'
,
items:
@recommed_items
%>
<div
class=
"clearfix"
></div>
</div>
...
...
@@ -12,4 +13,4 @@
Newest Items
<span
class=
"sprite-2"
></span>
</h2>
<%=
render
'shared/grid'
,
items:
@newest_items
%>
</div>
\ No newline at end of file
</div>
venshop_app/app/views/products/index.html.erb
View file @
841bca67
...
...
@@ -3,6 +3,7 @@
<h2
class=
"sprite-2"
>
Products
<span
class=
"sprite-2"
></span>
</h2>
<div
id=
"block-message-visible"
class=
"hidden"
></div>
<%=
render
'shared/grid'
,
items:
@products
%>
<%=
will_paginate
@products
,
renderer:
BootstrapPagination
::
Rails
%>
...
...
venshop_app/app/views/products/show.html.erb
View file @
841bca67
...
...
@@ -2,6 +2,7 @@
<div
class=
"body-box"
>
<h2
class=
"sprite-2"
>
<%=
@product
.
name
%>
<span
class=
"sprite-2"
></span></h2>
<div
class=
"text-justify product-detail"
>
<div
id=
"block-message-visible"
class=
"hidden"
></div>
<%
if
!
@product
.
status
%>
<div
class=
"alert alert-danger"
>
<p
class=
"text-center"
>
This product is only visible to you.
</p>
...
...
@@ -36,7 +37,7 @@
Other products
<span
class=
"sprite-2"
></span>
</h2>
<%=
render
'shared/grid'
,
items
:@other_products
%>
<div
class=
"clearfix"
></div>
</div>
<%
end
%>
\ No newline at end of file
<%
end
%>
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