Skip to content

Commit c29eef6

Browse files
committed
Shop Cart implementation
- Order and OrderItem
1 parent 9e877b6 commit c29eef6

File tree

14 files changed

+81
-11
lines changed

14 files changed

+81
-11
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ gem 'redis', '~>3.2'
2323
gem 'sidekiq'
2424
gem 'sidekiq-scheduler', '~> 2.1.4'
2525
gem 'simple_form'
26+
gem 'font-awesome-rails'
2627

2728
gem 'courses', path: 'components/courses'
2829
gem 'shop', path: 'components/shop'

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ GEM
226226
faraday (1.0.1)
227227
multipart-post (>= 1.2, < 3)
228228
ffi (1.12.2)
229+
font-awesome-rails (4.7.0.7)
230+
railties (>= 3.2, < 7)
229231
formatador (0.2.5)
230232
friendly_id (5.3.0)
231233
activerecord (>= 4.0.0)
@@ -650,6 +652,7 @@ DEPENDENCIES
650652
ez-settings
651653
factory_bot_rails
652654
faker
655+
font-awesome-rails
653656
friendly_id (~> 5.1)
654657
gibbon (~> 3.0)
655658
groupdate (~> 4.0)

app/assets/stylesheets/app/application.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
@import "https://fonts.googleapis.com/css2?family=Oswald&display=swap'";
1616
@import "local_fonts";
17+
@import "font-awesome";
1718

1819
@import "normalize";
1920

app/helpers/admin/events_helper.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def event_status_label(event)
4242
class: ['ui label', BG_STATUS_CLASS[event.status.to_sym]]
4343
end
4444

45-
# rubocop:disable Metrics/AbcSize
4645
def event_visitors(event)
4746
requested = event.pending_visit_requests.length
4847
approved = event.approved_visit_requests.length
@@ -56,7 +55,6 @@ def event_visitors(event)
5655
t('events.index.visitors.visited') => visited
5756
}
5857
end
59-
# rubocop:enable Metrics/AbcSize
6058

6159
def event_verified_user_data(event)
6260
verified = event.verified_visitors.length

app/views/layouts/app/_header.slim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,8 @@ header.pk-header class="#{header_classlist.compact.join(' ')}"
6767
li.pk-header__li-list-item = register_link
6868
li.pk-header__li-list-item = login_link
6969

70+
li.pk-list__unit
71+
= link_to supporters_path do
72+
i.fas.fa-shopping-cart.fa-2x
7073
li.pk-list__unit
7174
= support_us_link(class: 'btn pk-btn--green-bg donate-btn')

app/views/layouts/application.slim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ html
1313
link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16"
1414
link rel="manifest" href="/manifest.json"
1515
link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"
16+
link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/all.css"
1617
== render 'layouts/ga/head' if Rails.env.production?
1718

1819
body.pk-main-layout class="#{yield(:main_body_class)}"

components/shop/Gemfile.lock

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ GEM
6565
rack-test (>= 0.6.3)
6666
regexp_parser (>= 1.5, < 3.0)
6767
xpath (~> 3.2)
68-
carrierwave (1.3.2)
69-
activemodel (>= 4.0.0)
70-
activesupport (>= 4.0.0)
71-
mime-types (>= 1.16)
72-
ssrf_filter (~> 1.0)
7368
coderay (1.1.3)
7469
concurrent-ruby (1.1.8)
7570
crass (1.0.6)
@@ -130,9 +125,6 @@ GEM
130125
mini_mime (>= 0.1.1)
131126
marcel (1.0.1)
132127
method_source (1.0.0)
133-
mime-types (3.3.1)
134-
mime-types-data (~> 3.2015)
135-
mime-types-data (3.2021.0225)
136128
mini_mime (1.1.0)
137129
minitest (5.14.4)
138130
nenv (0.3.0)
@@ -227,7 +219,6 @@ GEM
227219
activesupport (>= 4.0)
228220
sprockets (>= 3.0.0)
229221
sqlite3 (1.4.2)
230-
ssrf_filter (1.0.7)
231222
temple (0.8.2)
232223
thor (1.1.0)
233224
thread_safe (0.3.6)

components/shop/app/controllers/shop/items_controller.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ module Shop
44
class ItemsController < BaseController
55
helper_method :items
66

7+
# @deprecated
8+
# def add_to_cart
9+
# cart = session[:cart] || []
10+
# cart << item.id unless cart.include?(item.id)
11+
12+
# session[:cart] = cart
13+
14+
# redirect_back(fallback_location: root_path, notice: "#{item.name} was successfully added to cart")
15+
# end
16+
17+
# def remove_from_cart
18+
# session[:cart].delete(item.id)
19+
# redirect_back(fallback_location: root_path, notice: "#{item.name} was successfully removed from cart")
20+
# end
21+
722
private
823

924
def items
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
module Shop
4+
class OrderItemsController < BaseController
5+
helper_method :item
6+
7+
def index
8+
end
9+
10+
def update
11+
end
12+
13+
def destroy
14+
end
15+
16+
private
17+
18+
def item
19+
@items ||= Shop::Item.find(params[:id])
20+
end
21+
end
22+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
# status: shopping_cart, placed, processing, shipping, complete, canceled
4+
# user: optional
5+
# buyer: anonymous user
6+
# shipment_address
7+
8+
module Shop
9+
class Order < ApplicationRecord
10+
self.table_name = 'shop_orders'
11+
12+
has_many :order_items
13+
14+
def total
15+
@totoal ||= 0
16+
end
17+
end
18+
end

0 commit comments

Comments
 (0)