Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
9943f34
新增 Todo
FunnyQ Jun 10, 2014
340072d
建立admin 下的 products controller, 並設定 routes
FunnyQ Jun 10, 2014
92428a9
完成後台的 new 功能
FunnyQ Jun 10, 2014
f91c024
完成admin/products 的 index
FunnyQ Jun 10, 2014
3504bb7
更新 todo
FunnyQ Jun 10, 2014
fd13fa3
完成使用者登入功能與權限區分
FunnyQ Jun 10, 2014
77d4261
新增 simple form gem, 把 admin/products/new 的 form_for 改成 simple_form_for.
FunnyQ Jun 10, 2014
41e2e03
更新 simple_form_bootstrap.rb 為 bootstrap 3 適用版本
FunnyQ Jun 10, 2014
111f342
更新 todo
FunnyQ Jun 10, 2014
ad6a554
更新 Todo、mount bootstrap javascript、把 application.css 改成 scss
FunnyQ Jun 13, 2014
105d562
更新 TODO 加上後台 User story.
FunnyQ Jun 13, 2014
ff1c3e1
完成 products index, show.
FunnyQ Jun 13, 2014
34b41e0
完成 navbar 與 dropdown 選單
FunnyQ Jun 13, 2014
8419cd7
trying carrierwave 4th time
FunnyQ Jun 15, 2014
f31356c
完成圖片上傳功能...
FunnyQ Jun 15, 2014
ad4514c
product#show 可以顯示圖片,但 product 沒圖片時會 error.
FunnyQ Jun 15, 2014
6dc8103
index 圖片顯示不出來
FunnyQ Jun 15, 2014
1c74a4d
新增 price 欄位,變更數量的預設值為0
FunnyQ Jun 16, 2014
0db371a
新增 edit 與更新 view
FunnyQ Jun 16, 2014
78bc6ee
後台增加 DELET 功能
FunnyQ Jun 16, 2014
7d0040c
完成圖片顯示功能
FunnyQ Jun 16, 2014
3045b18
update products view
FunnyQ Jun 16, 2014
261f8ff
加入購物車按鈕
FunnyQ Jun 16, 2014
a589865
update views and helper
FunnyQ Jun 17, 2014
82fa929
update views and helper
FunnyQ Jun 17, 2014
4869d94
add 新增產品 option in navbar and admin page
FunnyQ Jun 17, 2014
1c9e045
add notice message
FunnyQ Jun 17, 2014
e2b60ef
add cart and cartItem model
FunnyQ Jun 17, 2014
b325586
fix admin::productController update action
FunnyQ Jun 17, 2014
8292f70
add to cart
FunnyQ Jun 17, 2014
7f2f582
完成加到購物車
FunnyQ Jun 17, 2014
0074af1
rails#4 p38
FunnyQ Jun 17, 2014
321b176
rails#4 p48
FunnyQ Jun 17, 2014
4b6b14d
generate random url for orders
FunnyQ Jun 19, 2014
6530495
消費者可以選擇用信用卡結賬
FunnyQ Jun 19, 2014
87f9ebc
setting up aasm
FunnyQ Jun 19, 2014
b0ee469
課程練習done
FunnyQ Jun 19, 2014
6db1053
結賬產生訂單後清除購物車
FunnyQ Jun 19, 2014
cea63ae
增加移除商品按鈕
FunnyQ Jun 19, 2014
69e5cb8
新增 controller 並增加 routes
FunnyQ Jun 19, 2014
666f94d
建立 destroy action, 更新按鈕連結,使用者可以從購物車內刪掉一件物品
FunnyQ Jun 19, 2014
b1bd0cb
add quantity column to cart_items
FunnyQ Jun 19, 2014
2d8290e
更新 add_product_to_cart method
FunnyQ Jun 19, 2014
79daa3d
使用者可以多重購買,並可以在購物車看到正確的數量與總價
FunnyQ Jun 19, 2014
02095f1
庫存為0的商品不能購買
FunnyQ Jun 19, 2014
b0a0652
使用者在購物車可以變更數量
FunnyQ Jun 19, 2014
39b29b9
修改訂單 checkout view
FunnyQ Jun 19, 2014
0308846
修改訂單畫面,新增數量
FunnyQ Jun 19, 2014
a310278
建立 account/orders#index 可以查詢所有訂單,結賬後跳轉至此
FunnyQ Jun 19, 2014
8aa3e9e
準備建立 admin/orders
FunnyQ Jun 19, 2014
dc35331
管理者可以看到系統內所有訂單
FunnyQ Jun 20, 2014
81c39ae
列表可以顯示訂購者、付款方式、與訂單狀態
FunnyQ Jun 20, 2014
23f593a
增加 admin 更改訂單選項
FunnyQ Jun 20, 2014
dfa96c5
新增 route
FunnyQ Jun 20, 2014
71dcfeb
更新change_state_admin_orders_path
FunnyQ Jun 20, 2014
da2ef7a
can change state now
FunnyQ Jun 23, 2014
023afce
locals/en.yml
FunnyQ Jun 23, 2014
81da366
add stripe gem
FunnyQ Jun 24, 2014
3179455
下單後可收到郵件通知
FunnyQ Jun 24, 2014
ebd5533
完成 stripe charge
FunnyQ Jun 24, 2014
6cc808a
使用 mailgun 寄信
FunnyQ Jun 24, 2014
d986355
把 place order 收納成 Service object
FunnyQ Jun 24, 2014
9022105
把generate_token 收納到 concerns
FunnyQ Jun 24, 2014
87d6c07
✔ 信用卡付款成功也要可以寄信
FunnyQ Jun 24, 2014
b7ff482
✔ 消費者可以透過 email 裡的連結檢視原先的 order
FunnyQ Jun 24, 2014
7eb6f44
add gem
FunnyQ Jun 25, 2014
6cd28cd
將敏感資料放到 yml 裡
FunnyQ Jun 27, 2014
70ee15b
✔ 把 CardChargesController 收納成 Service Object
FunnyQ Jun 27, 2014
a5d7ee1
新增 gam ransack
FunnyQ Jun 27, 2014
e4018e3
adding search form
FunnyQ Jun 27, 2014
74f5e90
ransack
FunnyQ Jun 30, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

# ignore upload files
/public/uploads

# ignore pravite data
/config/application.yml
25 changes: 25 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,28 @@ gem 'spring', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]

# Devise 提供使用者登入功能
gem 'devise'
# 加入 bootstrap css framework
gem 'bootstrap-sass'
# Rails forms made easy
gem 'simple_form'

# 圖片上傳
gem 'carrierwave'
# 圖片壓縮 resize
gem 'mini_magick'
# 有線狀態機
gem 'aasm'
# 線上刷卡
gem 'stripe'

gem 'settingslogic'

gem 'ransack', github: "activerecord-hackery/ransack", branch: "rails-4.1"
gem 'will_paginate'

group :development do
# 在本機看信
gem "letter_opener"
end
63 changes: 63 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
GIT
remote: git://github.com/activerecord-hackery/ransack.git
revision: 625e58cbb5ea5e155464ea2d79497838313352f2
branch: rails-4.1
specs:
ransack (1.2.4)
actionpack (>= 4.0)
activerecord (>= 4.0)
activesupport (>= 4.0)
i18n
polyamorous (~> 1.0.0)

GEM
remote: https://rubygems.org/
specs:
aasm (3.2.1)
actionmailer (4.1.0)
actionpack (= 4.1.0)
actionview (= 4.1.0)
Expand All @@ -27,15 +40,31 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
addressable (2.3.6)
arel (5.0.1.20140414130214)
bcrypt (3.1.7)
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
bootstrap-sass (3.1.1.1)
sass (~> 3.2)
builder (3.2.2)
carrierwave (0.10.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.7.0)
devise (3.0.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
warden (~> 1.2.3)
erubis (2.7.0)
execjs (2.2.0)
hike (1.2.3)
Expand All @@ -47,12 +76,21 @@ GEM
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
launchy (2.4.2)
addressable (~> 2.3)
letter_opener (1.2.0)
launchy (~> 2.2)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
mini_magick (3.7.0)
subexec (~> 0.2.1)
minitest (5.3.4)
multi_json (1.10.1)
orm_adapter (0.5.0)
polyamorous (1.0.0)
activerecord (>= 3.0)
polyglot (0.3.5)
rack (1.5.2)
rack-test (0.6.2)
Expand All @@ -75,6 +113,8 @@ GEM
rake (10.3.2)
rdoc (4.1.1)
json (~> 1.4)
rest-client (1.6.7)
mime-types (>= 1.16)
sass (3.2.19)
sass-rails (4.0.3)
railties (>= 4.0.0, < 5.0)
Expand All @@ -84,6 +124,10 @@ GEM
sdoc (0.4.0)
json (~> 1.8)
rdoc (~> 4.0, < 5.0)
settingslogic (2.0.9)
simple_form (3.0.2)
actionpack (~> 4.0)
activemodel (~> 4.0)
spring (1.1.3)
sprockets (2.11.0)
hike (~> 1.2)
Expand All @@ -95,6 +139,11 @@ GEM
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.9)
stripe (1.14.0)
json (~> 1.8.1)
mime-types (~> 1.25)
rest-client (~> 1.4)
subexec (0.2.3)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
Expand All @@ -108,18 +157,32 @@ GEM
uglifier (2.5.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
warden (1.2.3)
rack (>= 1.0)
will_paginate (3.0.3)

PLATFORMS
ruby

DEPENDENCIES
aasm
bootstrap-sass
carrierwave
coffee-rails (~> 4.0.0)
devise
jbuilder (~> 2.0)
jquery-rails
letter_opener
mini_magick
rails (= 4.1.0)
ransack!
sass-rails (~> 4.0.3)
sdoc (~> 0.4.0)
settingslogic
simple_form
spring
sqlite3
stripe
turbolinks
uglifier (>= 1.3.0)
will_paginate
3 changes: 3 additions & 0 deletions app/assets/javascripts/account/orders.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/admin/orders.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/admin/products.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require bootstrap
3 changes: 3 additions & 0 deletions app/assets/javascripts/card_charges.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/cart_items.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/carts.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
35 changes: 35 additions & 0 deletions app/assets/javascripts/orders.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

jQuery ($) ->
$("#payment-form").submit (event) ->
$form = $(this)

# Disable the submit button to prevent repeated clicks
$form.find("button").prop "disabled", true
Stripe.createToken $form, stripeResponseHandler

# Prevent the form from submitting with the default action
false

return

stripeResponseHandler = (status, response) ->
$form = $("#payment-form")
if response.error

# Show the errors on the form
$form.find(".payment-errors").text response.error.message
$form.find("button").prop "disabled", false
else

# token contains id, last4, and card type
token = response.id

# Insert the token into the form so it gets submitted to the server
$form.append $("<input type=\"hidden\" name=\"stripeToken\" />").val(token)

# and submit
$form.get(0).submit()
return
3 changes: 3 additions & 0 deletions app/assets/javascripts/products.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/account/orders.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the account::orders controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/admin/orders.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the admin::orders controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
14 changes: 14 additions & 0 deletions app/assets/stylesheets/admin/products.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Place all the styles related to the admin::products controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

.admin{
a {
margin: 10px 5px;
}
.buttonsGroup {
background-color: #ccc;
padding: 0 10px;
margin: 5px 0 20px 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require bootstrap
*= require_tree .
*= require_self
*/

body {
margin-top: 60px;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/card_charges.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the card_charges controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/cart_items.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the cart_items controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
15 changes: 15 additions & 0 deletions app/assets/stylesheets/carts.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Place all the styles related to the carts controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
$money-red: #c00;

.cart, .checkout, .order, .orderlist {
th, .price, .delete, .qt, .timeAgo {
text-align: center;
}
.price, .total {
color: $money-red;
font-weight: bold;
font-size: 1.2em;
}
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/orders.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the orders controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
24 changes: 24 additions & 0 deletions app/assets/stylesheets/products.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Place all the styles related to the products controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

$text-color: #888;
$title-color: #555;

.products{
padding: 15px;
margin-bottom: 10px;
border-bottom: 1px solid #ccc;
h3 a, h4{
color: $title-color;
}
h4{
margin-top: 55px;
}
p{
color: $text-color;
}
.addToCart {
margin: 15px 0;
}
}
7 changes: 7 additions & 0 deletions app/controllers/account/orders_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Account::OrdersController < ApplicationController

def index
@orders = current_user.orders
end

end
41 changes: 41 additions & 0 deletions app/controllers/admin/orders_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class Admin::OrdersController < ApplicationController

before_filter :find_order, :except => [:index]

def index
# TODO Pagenavi
@orders = Order.all.limit(50)
end

def show
@order_info = @order.info
@order_items = @order.items
end

def ship
@order.ship!
redirect_to :back
end

def shipped
@order.deliver!
redirect_to :back
end

def cancel
@order.cancel_order!
redirect_to :back
end

def return
@order.return_good!
redirect_to :back
end

protected

def find_order
@order = Order.find_by_token(params[:id])
end

end
Loading