Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
50373ef
1. add product backend, 2. add product new, index controller and view
sinorga Jun 9, 2014
ba4cc71
add devise into project
sinorga Jun 9, 2014
e20cc2e
1. add is_admin in user model, 2. add login/logout
sinorga Jun 9, 2014
58cd933
add bootstrap gem
sinorga Jun 9, 2014
ddc9839
add home page
sinorga Jun 11, 2014
3731722
1. move admin link to application.html
sinorga Jun 11, 2014
6edc67a
add photo model for store multi image in one product
sinorga Jun 11, 2014
5878249
add admin/product show
sinorga Jun 11, 2014
1e6750a
using simple_form
sinorga Jun 11, 2014
b4a6e15
add new link in index page of products
sinorga Jun 11, 2014
b68dcc0
add nav bar
sinorga Jun 11, 2014
9bd414d
custom devise sign in layout with bootstrap and simple_form
sinorga Jun 11, 2014
f5846e1
admin/product: fix show page error, if product without photo
sinorga Jun 12, 2014
b6a2d20
add sign-in style which from example of bootstrap into application.css
sinorga Jun 12, 2014
182b3ec
adm/product: modify layout of show page
sinorga Jun 12, 2014
ef2b426
adm/product: modify layout of new page
sinorga Jun 12, 2014
e5e4d36
adm/product: modify layout of index page and update TODO
sinorga Jun 12, 2014
c8b3c55
admin/products: add edit, destroy and update actions
sinorga Jun 13, 2014
0aa27db
admin/product: add price
sinorga Jun 13, 2014
0686bfb
product add validate attributes
sinorga Jun 14, 2014
e2e5cab
only admin can get into management page
sinorga Jun 14, 2014
31adc6c
refactor application.html: extract some layout
sinorga Jun 14, 2014
e1ac0ca
Fix price won't be stored: add price attribute into strong parameter
sinorga Jun 15, 2014
cdb9020
alt is necessary attribute of img tag
sinorga Jun 15, 2014
fbdedb2
move render image into helper and show text of No Pic if the product …
sinorga Jun 15, 2014
a5ac8de
render image: using image instead of raw text of No Pic
sinorga Jun 15, 2014
7db1d14
resize image when it uploaded and provide a image with different size
sinorga Jun 15, 2014
a6329a7
add product controller and view for normal users access
sinorga Jun 15, 2014
986d0da
add products link to nav bar
sinorga Jun 15, 2014
51bd5b6
update todo file
sinorga Jun 15, 2014
cd852b3
update contents of class v2
sinorga Jun 16, 2014
aff7643
update schema.rb
sinorga Jun 16, 2014
0e2c20f
update TODO
sinorga Jun 16, 2014
0515653
update TODO list for homework v2
sinorga Jun 16, 2014
9dbcad7
user can delete product from cart
sinorga Jun 17, 2014
1a5a4b9
user can choose number of products before add it to cart
sinorga Jun 17, 2014
eaa03f5
user can choose number of products before add it to cart (missing files)
sinorga Jun 17, 2014
dd4a287
add quantity for each prodcut in cart
sinorga Jun 18, 2014
f57ffa3
correct total price of cart
sinorga Jun 18, 2014
0ffd605
user can't add product with 0 quantity into cart
sinorga Jun 18, 2014
81cb94f
1. User can get correct quantity on order page.
sinorga Jun 18, 2014
1734f0d
user can check order history at account/orders
sinorga Jun 18, 2014
5de5b84
after pay order, redirect to account/orders
sinorga Jun 18, 2014
fbcae0d
1. As a admin, he can see all orders at admin/orders
sinorga Jun 19, 2014
96239c1
format the html files and add div of container class in some views
sinorga Jun 19, 2014
485da89
add TODO item
sinorga Jun 19, 2014
c40a563
update nav_bar: add more links
sinorga Jun 19, 2014
284b71f
refactor: using reflection for order state transition
sinorga Jun 19, 2014
0ad8b86
create cart_times controller and move add/delete product to cart to c…
sinorga Jun 22, 2014
2f3ebda
update gitignore
sinorga Jun 22, 2014
560e669
class 3 content
sinorga Jun 23, 2014
e814cfa
extract class: order_placing_service
sinorga Jun 24, 2014
39eff21
1. send email after card paid
sinorga Jun 24, 2014
ed20820
add order link into mail
sinorga Jun 24, 2014
b9ea1a3
add settingslogic for moving stripe key to yml file
sinorga Jun 25, 2014
5571d15
move email key to yml file
sinorga Jun 25, 2014
31c0fdc
extract class from card_charges_controller
sinorga Jun 26, 2014
362a374
add search product feature (ransack)
sinorga Jun 26, 2014
8dfff46
1. update simple_form. 2. add devise zh-TW
sinorga Jun 27, 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 image files
/public/uploads

# Ignore rubymine config file
.idea
31 changes: 31 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,34 @@ gem 'spring', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]

#for account authentication
gem 'devise'

#for front-end
gem 'bootstrap-sass'

#for upload file
gem 'carrierwave'
#for process uploaded image
gem 'subexec', :git => "https://github.com/nulayer/subexec.git"
gem 'mini_magick'

gem 'simple_form'

#for state machines
gem "aasm"

#for dispaly email at local
group :development do
gem "letter_opener"
gem "roadie"
end

#for credit card payment
gem "stripe"

#for store secure key info
gem "settingslogic"

#for search product
gem "ransack"
81 changes: 76 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
GIT
remote: https://github.com/nulayer/subexec.git
revision: 2e4d92870d4ad3322d6fca14416f63e6eff55cbc
specs:
subexec (0.2.3)

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,32 +34,61 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
addressable (2.3.6)
arel (5.0.1.20140414130214)
bcrypt (3.1.7)
bootstrap-sass (3.2.0.0)
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)
css_parser (1.3.5)
addressable
devise (3.2.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
thread_safe (~> 0.1)
warden (~> 1.2.3)
erubis (2.7.0)
execjs (2.2.0)
execjs (2.2.1)
hike (1.2.3)
i18n (0.6.9)
jbuilder (2.0.8)
jbuilder (2.1.1)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (3.1.0)
jquery-rails (3.1.1)
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)
minitest (5.3.4)
mini_magick (3.7.0)
subexec (~> 0.2.1)
mini_portile (0.6.0)
minitest (5.3.5)
multi_json (1.10.1)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
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 @@ -73,8 +109,21 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.3.2)
ransack (1.2.3)
actionpack (>= 3.0)
activerecord (>= 3.0)
activesupport (>= 3.0)
i18n
polyamorous (~> 1.0.0)
rdoc (4.1.1)
json (~> 1.4)
rest-client (1.6.7)
mime-types (>= 1.16)
roadie (2.4.3)
actionmailer (> 3.0.0, < 5.0.0)
css_parser (~> 1.3.4)
nokogiri (> 1.5.0)
sprockets
sass (3.2.19)
sass-rails (4.0.3)
railties (>= 4.0.0, < 5.0)
Expand All @@ -84,6 +133,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 +148,10 @@ 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)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
Expand All @@ -105,21 +162,35 @@ GEM
coffee-rails
tzinfo (1.2.1)
thread_safe (~> 0.1)
uglifier (2.5.0)
uglifier (2.5.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
warden (1.2.3)
rack (>= 1.0)

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
roadie
sass-rails (~> 4.0.3)
sdoc (~> 0.4.0)
settingslogic
simple_form
spring
sqlite3
stripe
subexec!
turbolinks
uglifier (>= 1.3.0)
70 changes: 70 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
後台管理:
☐ 身為商家的管理者,我要能夠在後台上架我的東西,並設定能夠販賣
✔ 管理者必須要有一個後台 @done (14-06-09 21:51)
✔ 後台必須要可以新增產品 @done (14-06-09 21:51)
✔ 新增產品必須要有標題, 數量, 價格的內容 @done(2014-06-14 09:59)
✔ 新增產品使用simple_form @done(2014-06-11 10:11)
✔ 產品內容必須要有標題,文字,數量 @done (14-06-09 21:52)
✔ 產品必須要有圖片 @done(2014-06-11 08:28)
✔ 如果沒有產品圖片,使用預設文字取代'No Pic' @done(2014-06-15 12:53) @project(後台管理)
✔ 如果沒有產品圖片,使用No Pic圖片取代 @done(2014-06-15 01:07) @project(後台管理)
☐ 一個產品可以有很多圖片
✔ 產品必須要有價格 @done(2014-06-14 01:51)
✔ 限制圖片顯示大小 @done(2014-06-12 11:43)
✔ 設定圖片在上傳時的大小並且提供各種大小的版本 @done(2014-06-15 02:33) @project(後台管理)
☐ 在產品列表顯示產品的小圖片
✔ 身為管理者,可以在後台看到上架產品的內容 @done(2014-06-11 09:58)
✔ 管理者可以在後台看到所有產品 @done(2014-06-11 10:17)
✔ 管理者可以在所有產品頁面進入新增產品頁面 @done(2014-06-11 10:17)
✔ 管理者希望看到美觀的後台管理界面, 使用bootstrap @done(2014-06-12 11:43)
✔ 管理者希望可以在後台修改產品 @done(2014-06-14 10:33)
✔ 管理者希望可以在後台刪除產品 @done(2014-06-14 10:32)


☐ 身為商家的管理者,我要能夠在後台設定權限,權限分成管理者以及消費者
✔ 身為管理者,才可以進入後台 @done(2014-06-14 10:33)
✔ 身為管理者,必須要登入且是admin @done(2014-06-11 10:00)
✔ 管理者身份必須要被分為admin/user @done(2014-06-11 10:12)
✔ 身為一般使用者, 需要能看到所有產品 @done(2014-06-15 03:02)

✔ 身為商家的管理者,可以在後台看到所有訂單 @done(2014-06-19 08:55)
✔ 身為商家的管理者,可以在後台的訂單列表看到每張訂單的狀態 @done(2014-06-19 08:55)
✔ 身為商家的管理者,可以在後台每張訂單內按照狀態圖改變狀態 @done(2014-06-19 08:55)



購物:
✔ 任何使用者都能在navbar點擊進入商品選單區. @done(2014-06-15 03:27) @project(購物)
☐ 作為一個消費者,我要在前台能夠找到商品並結賬
✔ 身為消費者,我要在前台能夠找到商品並加到購物⾞ @done(2014-06-16 09:58) @project(購物)
✔ ⾝為消費者,我要在前台能看到購物⾞明細 @done(2014-06-16 09:58) @project(購物)
☐ ⾝為消費者,我要在前台能夠將多樣商品加到購物車,並生成一張訂單
✔ ⾝為消費者,當系統生成一張訂單前,我可以填寫寄送資訊 @done(2014-06-16 09:58) @project(購物)
✔ 身為消費者,當系統⽣生成⼀張訂單後,我可以用信用卡結帳 @done(2014-06-16 09:58) @project(購物)
☐ ⾝為消費者,當我用信用卡結帳後,我的信箱要能收到一張訂單確認信
✔ 信用卡付款成功後也要收到通知信 @done(2014-06-25 12:18) @project(購物)
✔ 將通知信用的key放入SettingLogic提供的yml內 @done(2014-06-25 11:30) @project(購物)
✔ 將信用卡繳費用的key放入SettingLogic提供的yml內 @done(2014-06-25 09:58) @project(購物)
✔ 身為消費者, 可以從信中連結到訂單網頁 @done(2014-06-25 12:35) @project(購物)
✔ 身為消費者,當訂單成立後,購物車需要清空 @done(2014-06-18 10:21) @project(購物)
✔ 身為消費者,需要在訂單頁面看到正確的商品數量 @done(2014-06-18 10:21) @project(購物)
☐ 美化訂單畫面
✔ 身為消費者,需要可以在購物車內刪除商品 @done(2014-06-17 10:11) @project(購物)
✔ 身為消費者,可以選擇商品數量,加入購物車 @done(2014-06-18 08:33) @project(購物)
✔ 身為消費者, 能看在購物車看到正確的總額(商品數量X商品價格) @done(2014-06-18 09:36) @project(購物)
✔ 身為消費者, 不能將數量為0的商品加入購物車 @done(2014-06-18 09:50) @project(購物)
✔ 身為消費者, 能在account/orders看到過去的訂單記錄 @done(2014-06-18 10:45) @project(購物)
✔ 身為消費者, 能夠在結賬後自動跳轉到account/orders#index @done(2014-06-18 10:51) @project(購物)
✔ 身為消費者, 能夠搜尋標題及價格範圍找到想要的產品 @done(2014-06-26 11:40) @project(購物)


系統訊息:
☐ 身為使用者, 我需要在頁面上看見包含error以外其他種類的通知訊息.
☐ 身為使用者, 我需要在頁面上看到詳細的model validate error.


重構:
✔ 將application.html中的nav bar和error message 用partial抽出 @done(2014-06-14 12:29) @project(Refactoring)
✔ 簡化admin/order#show狀態轉換的code, 包含viwe, controller @done(2014-06-20 02:44) @project(重構)
✔ 將加入/移除購物車功能, 轉移到cart_items controller相對應的create/destroy action @done(2014-06-22 10:58) @project(重構)
✔ 將card_charges controller內過多的程式碼移出. @done(2014-06-26 09:57) @project(重構)
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/
2 changes: 2 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require bootstrap
//= require orders
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/pages.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/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/
6 changes: 6 additions & 0 deletions app/assets/stylesheets/admin/products.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// 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/
img{
max-width: 100%;
}
Loading