Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
dhp-venshop
dhp-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
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Hoang Phuc Do
  • dhp-venshopdhp-venshop
  • Merge Requests
  • !3

Merged
Opened Jun 14, 2017 by Hoang Phuc Do@phucdh 
  • Report abuse
Report abuse

[Review] Cart feature

Edited Jun 15, 2017 by Trong Huu Nguyen
  • Discussion 18
  • Commits 7
  • Changes 50
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
  • Hoang Phuc Do @phucdh

    added 1 commit

    • e78b364a - Merge branch 'bk_dhp_buying' into dhp_cart

    Compare with previous version

    Jun 14, 2017

    added 1 commit

    • e78b364a - Merge branch 'bk_dhp_buying' into dhp_cart

    Compare with previous version

    added 1 commit * e78b364a - Merge branch 'bk_dhp_buying' into dhp_cart [Compare with previous version](https://gitlab.zigexn.vn/phucdh/dhp-venshop/merge_requests/3/diffs?diff_id=3338&start_sha=c5c3eaa768f631ebf76d525c382f455035288fb8)
    Toggle commit list
  • Hoang Phuc Do @phucdh

    added 2 commits

    • 55214d21 - Merge branch 'bk_dhp_buying' into dhp_cart
    • a1294599 - Merge branch into dhp_cart

    Compare with previous version

    Jun 15, 2017

    added 2 commits

    • 55214d21 - Merge branch 'bk_dhp_buying' into dhp_cart
    • a1294599 - Merge branch into dhp_cart

    Compare with previous version

    added 2 commits * 55214d21 - Merge branch 'bk_dhp_buying' into dhp_cart * a1294599 - Merge branch into dhp_cart [Compare with previous version](https://gitlab.zigexn.vn/phucdh/dhp-venshop/merge_requests/3/diffs?diff_id=3339&start_sha=e78b364a49f41e077ccaefc6fba856d8aea680af)
    Toggle commit list
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Resolved by Hoang Phuc Do Jun 15, 2017
    Gemfile
    54 59 # Adds support for Capybara system testing and selenium driver
    55 60 gem 'capybara', '~> 2.13'
    56 61 gem 'selenium-webdriver'
    62 # When mail is sent from your application, Letter Opener will open a preview in the browser instead of sending.
    63 gem 'letter_opener', '~> 1.4', '>= 1.4.1'
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Please move gem letter_opener in group development

      Edited Jun 15, 2017 by Trong Huu Nguyen
      Please move gem letter_opener in group development
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Last updated by Hoang Phuc Do Jun 15, 2017
    app/assets/javascripts/shop-14.js.erb 0 → 100644
    1 (function($) {
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Please move to javascript/cart/shop-14.js.erb

      Please move to javascript/cart/shop-14.js.erb
    • Hoang Phuc Do @phucdh commented Jun 15, 2017
      Master

      I've moved it into javascripts/cart/cart.js.erb

      Edited Jun 15, 2017
      I've moved it into ```javascripts/cart/cart.js.erb```
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Resolved by Hoang Phuc Do Jun 15, 2017
    app/controllers/application_controller.rb
    1 1 class ApplicationController < ActionController::Base
    2 2 protect_from_forgery with: :exception
    3 # rescue_from ActiveRecord::RecordNotFound, :with => :render_404
    3
    4 rescue_from ActiveRecord::RecordNotFound, :with => :render_404
    5
    6 include CartsHelper
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Move this line below class ApplicationController < ActionController::Base

      Edited Jun 15, 2017
      Move this line below `class ApplicationController < ActionController::Base`
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Resolved by Hoang Phuc Do Jun 15, 2017
    app/controllers/line_items_controller.rb 0 → 100644
    1 class LineItemsController < ApplicationController
    2 include CartsHelper
    3
    4 before_action :set_cart, only: [:create, :update, :destroy]
    5
    6 def show
    7 redirect_to product_url(params[:id])
    8 end
    9
    10 # POST /line_items
    11 def create
    12 product = Product.find(params[:product_id])
    13 add_to_cart(product.id.to_s, params[:product_vqty].to_i)
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Please change product_vqty to product_quantity

      Edited Jun 15, 2017 by Trong Huu Nguyen
      Please change `product_vqty` to `product_quantity`
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Last updated by Hoang Phuc Do Jun 15, 2017
    app/controllers/line_items_controller.rb 0 → 100644
    17 format.js
    18 end
    19 end
    20
    21 # PATCH/PUT /line_items/1
    22 def update
    23 update_cart_item(*update_params.to_h.values)
    24
    25 respond_to do |format|
    26 format.html { redirect_to cart_index_url }
    27 end
    28 end
    29
    30 # DELETE /line_items/1
    31 def destroy
    32 remove_from_cart(params[:id])
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Is it remove_product_out_of_cart ?

      Is it remove_product_out_of_cart ?
    • Hoang Phuc Do @phucdh commented Jun 15, 2017
      Master

      I've renamed this method into remove_line_item_from_cart

      Edited Jun 15, 2017
      I've renamed this method into ```remove_line_item_from_cart```
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Resolved by Hoang Phuc Do Jun 15, 2017
    app/controllers/line_items_controller.rb 0 → 100644
    18 end
    19 end
    20
    21 # PATCH/PUT /line_items/1
    22 def update
    23 update_cart_item(*update_params.to_h.values)
    24
    25 respond_to do |format|
    26 format.html { redirect_to cart_index_url }
    27 end
    28 end
    29
    30 # DELETE /line_items/1
    31 def destroy
    32 remove_from_cart(params[:id])
    33 product_title = Product.select(:title).find(params[:id]).title
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Please change @product = Product.find(params[:id])

      Edited Jun 15, 2017
      Please change @product = Product.find(params[:id])
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Resolved by Hoang Phuc Do Jun 15, 2017
    app/controllers/line_items_controller.rb 0 → 100644
    21 # PATCH/PUT /line_items/1
    22 def update
    23 update_cart_item(*update_params.to_h.values)
    24
    25 respond_to do |format|
    26 format.html { redirect_to cart_index_url }
    27 end
    28 end
    29
    30 # DELETE /line_items/1
    31 def destroy
    32 remove_from_cart(params[:id])
    33 product_title = Product.select(:title).find(params[:id]).title
    34
    35 respond_to do |format|
    36 format.html { redirect_to cart_index_url, notice: "#{product_title} was sucessfully removed from your cart" }
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Change product_title to @product.title

      Edited Jun 15, 2017
      Change `product_title` to @product.title
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Resolved by Hoang Phuc Do Jun 15, 2017
    app/controllers/orders_controller.rb 0 → 100644
    24 format.html { redirect_to root_url }
    25 else
    26 format.html { redirect_to root_url }
    27 end
    28 end
    29 end
    30
    31 def create_line_items_for_order(order)
    32 @cart.each do |product_id, product_attrs|
    33 order.line_items.create(product_id: product_id, quantity: product_attrs['quantity'])
    34 end
    35 end
    36
    37 private
    38
    39 def ensure_cart_is_not_empty
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Please remove this method. I think it no need. Please move redirect_to root_url if @cart.blank? to def new action

      Edited Jun 15, 2017
      Please remove this method. I think it no need. Please move `redirect_to root_url if @cart.blank?` to def new action
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Resolved by Hoang Phuc Do Jun 15, 2017
    app/controllers/orders_controller.rb 0 → 100644
    1 class OrdersController < ApplicationController
    2 include CartsHelper
    3 include LineItemsHelper
    4
    5 before_action :authenticate_user!, only: :new
    6 before_action :set_cart, only: [:new, :create]
    7 before_action :get_line_items, only: :new
    8 before_action :ensure_cart_is_not_empty, only: :new
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Please remove this code

      Edited Jun 15, 2017
      Please remove this code
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on the diff Jun 15, 2017
    Last updated by Hoang Phuc Do Jun 15, 2017
    app/controllers/static_pages_controller.rb
    3 3 @latest_products = Product.page(params[:page]).per(10)
    4 4 # @TODO: Get recommended products
    5 5 @recommended_products = Product.last(6)
    6 # session.clear
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Why do you comment here?

      Why do you comment here?
    • Hoang Phuc Do @phucdh commented Jun 15, 2017
      Master

      This line is used for testing purpose.

      This line is used for testing purpose.
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Resolved by Hoang Phuc Do Jun 15, 2017
    app/helpers/carts_helper.rb 0 → 100644
    11 else
    12 @cart[product_id] = { quantity: quantity }
    13 end
    14 end
    15
    16 def update_cart_item(product_id, quantity)
    17 return unless @cart.key?(product_id)
    18 if quantity.to_i.zero?
    19 remove_from_cart(product_id)
    20 else
    21 @cart[product_id][:quantity.to_s] = quantity.to_i
    22 end
    23 end
    24
    25 def remove_from_cart(product_id)
    26 @cart = @cart.delete(product_id) if @cart.key?(product_id)
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Please use @cart.tap { |cart| cart.delete(product_id) } if @cart.key?(product_id)

      Edited Jun 15, 2017
      Please use `@cart`.tap { |cart| cart.delete(`product_id`) } `if @cart.key?(product_id)`
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Resolved by Hoang Phuc Do Jun 15, 2017
    app/helpers/carts_helper.rb 0 → 100644
    20 else
    21 @cart[product_id][:quantity.to_s] = quantity.to_i
    22 end
    23 end
    24
    25 def remove_from_cart(product_id)
    26 @cart = @cart.delete(product_id) if @cart.key?(product_id)
    27 end
    28
    29 def destroy_cart_session
    30 session[:cart] = nil
    31 end
    32
    33 def cart_total_price
    34 @cart.sum do |product_id, product_attrs|
    35 product_price = Product.select(:price).find(product_id).price
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Please change product_price = Product.find(product_id).price

      Edited Jun 15, 2017 by Trong Huu Nguyen
      Please change `product_price = Product.find(product_id).price`
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Resolved by Hoang Phuc Do Jun 15, 2017
    app/mailers/order_mailer.rb 0 → 100644
    1 class OrderMailer < ApplicationMailer
    2 def order_detail(user, order)
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Please change method name send_order_detail_to_user

      Edited Jun 15, 2017
      Please change method name send_order_detail_to_user
    Please register or sign in to reply
  • Trong Huu Nguyen
    @huunt started a discussion on an old version of the diff Jun 15, 2017
    Last updated by Hoang Phuc Do Jun 15, 2017
    app/models/line_item.rb 0 → 100644
    1 class LineItem < ApplicationRecord
    2 belongs_to :product, optional: true
    3 belongs_to :order, optional: true
    4
    5 def create_line_items_from_cart(cart)
    • Trong Huu Nguyen @huunt commented Jun 15, 2017
      Master

      Why put this method here. I think it have to in controller. Please check again.

      Why put this method here. I think it have to in controller. Please check again.
    • Hoang Phuc Do @phucdh commented Jun 15, 2017
      Master

      This is a redundant method. I've removed it

      Edited Jun 15, 2017 by Hoang Phuc Do
      This is a redundant method. I've removed it
    Please register or sign in to reply
  • Hoang Phuc Do @phucdh

    added 1 commit

    • 2311c08a - Fix merge request #3

    Compare with previous version

    Jun 15, 2017

    added 1 commit

    • 2311c08a - Fix merge request #3

    Compare with previous version

    added 1 commit * 2311c08a - Fix merge request #3 [Compare with previous version](https://gitlab.zigexn.vn/phucdh/dhp-venshop/merge_requests/3/diffs?diff_id=3340&start_sha=a1294599a3a58f0dedea6590ba4166cb49dad055)
    Toggle commit list
  • Hoang Phuc Do @phucdh

    added 1 commit

    • 5a103955 - Fix merge request #3

    Compare with previous version

    Jun 15, 2017

    added 1 commit

    • 5a103955 - Fix merge request #3

    Compare with previous version

    added 1 commit * 5a103955 - Fix merge request #3 [Compare with previous version](https://gitlab.zigexn.vn/phucdh/dhp-venshop/merge_requests/3/diffs?diff_id=3343&start_sha=2311c08a7103910452807210ee2cc83546a66f49)
    Toggle commit list
  • Hoang Phuc Do @phucdh

    added 1 commit

    • ccd4ffc7 - Fix merge request #3

    Compare with previous version

    Jun 15, 2017

    added 1 commit

    • ccd4ffc7 - Fix merge request #3

    Compare with previous version

    added 1 commit * ccd4ffc7 - Fix merge request #3 [Compare with previous version](https://gitlab.zigexn.vn/phucdh/dhp-venshop/merge_requests/3/diffs?diff_id=3344&start_sha=5a103955eeac584a863e4d9225d20413718a0199)
    Toggle commit list
  • Trong Huu Nguyen @huunt

    closed

    Jun 15, 2017

    closed

    closed
    Toggle commit list
  • Trong Huu Nguyen @huunt

    reopened

    Jun 15, 2017

    reopened

    reopened
    Toggle commit list
  • Trong Huu Nguyen @huunt

    unmarked as a Work In Progress

    Jun 15, 2017

    unmarked as a Work In Progress

    unmarked as a **Work In Progress**
    Toggle commit list
  • Trong Huu Nguyen @huunt

    changed title from [WIP] Cart feature to [Review] Cart feature

    Jun 15, 2017

    changed title from [WIP] Cart feature to [Review] Cart feature

    changed title from **[{-WIP-}] Cart feature** to **[{+Review+}] Cart feature**
    Toggle commit list
  • Trong Huu Nguyen @huunt

    mentioned in commit f0d57a97

    Jun 15, 2017

    mentioned in commit f0d57a97

    mentioned in commit f0d57a9712e3c723b0bed59458036dd18aa54468
    Toggle commit list
  • Trong Huu Nguyen @huunt

    merged

    Jun 15, 2017

    merged

    merged
    Toggle commit list
  • Write
  • Preview
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment
Trong Huu Nguyen
Assignee
Trong Huu Nguyen @huunt
Assign to
None
Milestone
None
Assign milestone
Time tracking
2
2 participants
Reference: phucdh/dhp-venshop!3
×

Revert this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.
×

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.