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
8d3a2c4a
Commit
8d3a2c4a
authored
Oct 25, 2013
by
hades
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
card: send smtp mail
parent
55625ba6
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
85 additions
and
30 deletions
+85
-30
venshop_app/app/controllers/cards_controller.rb
+12
-7
venshop_app/app/mailers/user_mailer.rb
+11
-0
venshop_app/app/views/cards/_customer_info.html.erb
+23
-0
venshop_app/app/views/cards/_item_list.html.erb
+1
-1
venshop_app/app/views/cards/confirm_checkout.html.erb
+1
-22
venshop_app/app/views/user_mailer/card_send_to_consignee.html.erb
+17
-0
venshop_app/config/application.rb
+1
-0
venshop_app/config/environment.rb
+14
-0
venshop_app/spec/mailers/user_mailer_spec.rb
+5
-0
No files found.
venshop_app/app/controllers/cards_controller.rb
View file @
8d3a2c4a
...
@@ -37,21 +37,25 @@ class CardsController < ApplicationController
...
@@ -37,21 +37,25 @@ class CardsController < ApplicationController
redirect_to
cards_path
redirect_to
cards_path
else
else
card_items
=
@card_infos
[
:card_items
]
card_items
=
@card_infos
[
:card_items
]
card_items
.
each
do
|
card_item
,
key
|
found
=
false
card_items
.
each
do
|
card_item
|
# if a product exist in card
# if a product exist in card
if
card_item
[
:product_id
]
==
params
[
:product_id
]
if
card_item
[
:product_id
]
==
params
[
:product_id
]
card_item
[
:quantity
]
+=
1
# card_item[:quantity] += 1
card_items
[
key
]
=
card_item
# @card_infos = { card_items: card_items, customer_info: @card_infos[:customer_info] }
@card_infos
=
{
card_items:
card_items
,
customer_info:
@card_infos
[
:customer_info
]
}
# session[:SHOPPING_CARD_SESSION_NAME] = @card_infos
session
[
:SHOPPING_CARD_SESSION_NAME
]
=
@card_infos
# redirect_to cards_path
redirect_to
cards_path
found
=
true
break
end
end
end
end
# if a product not exist in card
# if a product not exist in card
if
!
found
card_items
.
push
({
product_id:
params
[
:product_id
],
quantity:
1
})
card_items
.
push
({
product_id:
params
[
:product_id
],
quantity:
1
})
customer_info
=
@card_infos
[
:customer_info
]
customer_info
=
@card_infos
[
:customer_info
]
@card_infos
=
{
card_items:
card_items
,
customer_info:
customer_info
}
@card_infos
=
{
card_items:
card_items
,
customer_info:
customer_info
}
session
[
:SHOPPING_CARD_SESSION_NAME
]
=
@card_infos
session
[
:SHOPPING_CARD_SESSION_NAME
]
=
@card_infos
end
redirect_to
cards_path
redirect_to
cards_path
end
end
end
end
...
@@ -137,13 +141,14 @@ class CardsController < ApplicationController
...
@@ -137,13 +141,14 @@ class CardsController < ApplicationController
note:
customer_info
[
:note
],
note:
customer_info
[
:note
],
items:
xml_data
items:
xml_data
)
)
session
[
:SHOPPING_CARD_SESSION_NAME
]
=
nil
UserMailer
.
card_send_to_consignee
(
customer_info
[
:email
],
@card_infos
).
deliver
redirect_to
url_for
(
action:
'thankyou'
)
redirect_to
url_for
(
action:
'thankyou'
)
end
end
end
end
def
thankyou
def
thankyou
add_breadcrumb
"Thank out"
,
url_for
(
action:
'thankyou'
)
add_breadcrumb
"Thank out"
,
url_for
(
action:
'thankyou'
)
session
[
:SHOPPING_CARD_SESSION_NAME
]
=
nil
render
:layout
=>
"application_one_col"
render
:layout
=>
"application_one_col"
end
end
end
end
venshop_app/app/mailers/user_mailer.rb
0 → 100644
View file @
8d3a2c4a
class
UserMailer
<
ActionMailer
::
Base
default
from:
"from@example.com"
def
card_send_to_consignee
(
email
,
card_infos
)
@card_infos
=
card_infos
mail
(
to:
email
,
subject:
'Shopping information'
)
end
end
venshop_app/app/views/cards/_customer_info.html.erb
0 → 100644
View file @
8d3a2c4a
<table
class=
"table"
>
<tr>
<td><b>
Full name
</b>
:
</td>
<td>
<%=
customer_info
[
:full_name
]
%>
</td>
</tr>
<tr>
<td><b>
Email
</b>
:
</td>
<td>
<%=
customer_info
[
:email
]
%>
</td>
</tr>
<tr>
<td><b>
Phone
</b>
:
</td>
<td>
<%=
customer_info
[
:phone
]
%>
</td>
</tr>
<tr>
<td><b>
Address
</b>
:
</td>
<td>
<%=
customer_info
[
:address
]
%>
</td>
</tr>
<tr>
<td><b>
Note
</b>
:
</td>
<td>
<%=
customer_info
[
:note
]
%>
</td>
</tr>
</table>
\ No newline at end of file
venshop_app/app/views/cards/_item_list.html.erb
View file @
8d3a2c4a
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
%>
%>
<tr>
<tr>
<td>
<%=
$i
%>
</td>
<td>
<%=
$i
%>
</td>
<td>
<%=
link_to
product
.
name
,
product_
path
(
product
)
%>
</td>
<td>
<%=
link_to
product
.
name
,
product_
url
(
product
)
%>
</td>
<%
if
can_edit
%>
<%
if
can_edit
%>
<td><input
type=
"text"
class=
"form-control"
value=
"
<%=
card_item
[
:quantity
]
%>
"
/></td>
<td><input
type=
"text"
class=
"form-control"
value=
"
<%=
card_item
[
:quantity
]
%>
"
/></td>
<%
else
%>
<%
else
%>
...
...
venshop_app/app/views/cards/confirm_checkout.html.erb
View file @
8d3a2c4a
...
@@ -5,28 +5,7 @@
...
@@ -5,28 +5,7 @@
</h2>
</h2>
<p><br
/>
Please check your information:
</p>
<p><br
/>
Please check your information:
</p>
<%
customer_info
=
@card_infos
[
:customer_info
]
%>
<%
customer_info
=
@card_infos
[
:customer_info
]
%>
<table
class=
"table"
>
<%=
render
partial:
'cards/customer_info'
,
locals:
{
customer_info:
customer_info
}
%>
<tr>
<td><b>
Full name
</b>
:
</td>
<td>
<%=
customer_info
[
:full_name
]
%>
</td>
</tr>
<tr>
<td><b>
Email
</b>
:
</td>
<td>
<%=
customer_info
[
:email
]
%>
</td>
</tr>
<tr>
<td><b>
Phone
</b>
:
</td>
<td>
<%=
customer_info
[
:phone
]
%>
</td>
</tr>
<tr>
<td><b>
Address
</b>
:
</td>
<td>
<%=
customer_info
[
:address
]
%>
</td>
</tr>
<tr>
<td><b>
Note
</b>
:
</td>
<td>
<%=
customer_info
[
:note
]
%>
</td>
</tr>
</table>
<%=
render
partial:
'cards/item_list'
,
locals:
{
card_infos:
@card_infos
,
can_edit:
false
}
%>
<%=
render
partial:
'cards/item_list'
,
locals:
{
card_infos:
@card_infos
,
can_edit:
false
}
%>
<%=
form_tag
do
%>
<%=
form_tag
do
%>
<div
class=
"text-center"
>
<div
class=
"text-center"
>
...
...
venshop_app/app/views/user_mailer/card_send_to_consignee.html.erb
0 → 100644
View file @
8d3a2c4a
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Venshop
</title>
</head>
<body>
<%
customer_info
=
@card_infos
[
:customer_info
]
%>
<p>
Hi
<b>
<%=
customer_info
[
:full_name
]
%>
</b>
,
<br
/><br
/>
You or someone has been ordered on our website with the following information:
</p>
<%=
render
partial:
'cards/customer_info'
,
locals:
{
customer_info:
customer_info
}
%>
<%=
render
partial:
'cards/item_list'
,
locals:
{
card_infos:
@card_infos
,
can_edit:
false
}
%>
</body>
</html>
\ No newline at end of file
venshop_app/config/application.rb
View file @
8d3a2c4a
...
@@ -24,5 +24,6 @@ module VenshopApp
...
@@ -24,5 +24,6 @@ module VenshopApp
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# config.i18n.default_locale = :de
config
.
action_mailer
.
default_url_options
=
{
host:
'localhost:3000'
}
end
end
end
end
venshop_app/config/environment.rb
View file @
8d3a2c4a
...
@@ -9,5 +9,18 @@ RecaptchaMailhide.configure do |c|
...
@@ -9,5 +9,18 @@ RecaptchaMailhide.configure do |c|
c
.
public_key
=
'6LfDL-kSAAAAAG8JuwZhxLaT8X8iHZYpWu-7DAFe'
c
.
public_key
=
'6LfDL-kSAAAAAG8JuwZhxLaT8X8iHZYpWu-7DAFe'
end
end
VenshopApp
::
Application
.
configure
do
config
.
action_mailer
.
delivery_method
=
:smtp
config
.
action_mailer
.
smtp_settings
=
{
address:
'smtp.gmail.com'
,
port:
587
,
domain:
'alphaplus.vn'
,
user_name:
'coi.no.reply@gmail.com'
,
password:
'q5cE05OUwJ'
,
authentication:
'plain'
,
enable_starttls_auto:
true
}
end
YAHOO_SHOPPING_DATA_APP_ID
=
'dj0zaiZpPXpIMzBsMUQyTk55dSZkPVlXazlZWGxzYjNoWU0yVW1jR285TUEtLSZzPWNvbnN1bWVyc2VjcmV0Jng9MzI-'
YAHOO_SHOPPING_DATA_APP_ID
=
'dj0zaiZpPXpIMzBsMUQyTk55dSZkPVlXazlZWGxzYjNoWU0yVW1jR285TUEtLSZzPWNvbnN1bWVyc2VjcmV0Jng9MzI-'
YAHOO_SHOPPING_DATA_SECRECT
=
'45b3584021d48d65984b515a2cd23623a3ec90cc'
YAHOO_SHOPPING_DATA_SECRECT
=
'45b3584021d48d65984b515a2cd23623a3ec90cc'
\ No newline at end of file
venshop_app/spec/mailers/user_mailer_spec.rb
0 → 100644
View file @
8d3a2c4a
require
"spec_helper"
describe
UserMailer
do
pending
"add some examples to (or delete)
#{
__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