spree_my_favourites 2.2.2 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/spree/frontend/my_account.scss +16 -0
- data/app/controllers/spree/account/favourites_controller.rb +17 -11
- data/app/controllers/spree/account/orders_controller.rb +10 -6
- data/app/views/spree/account/favourites/_table.haml +5 -0
- data/app/views/spree/account/favourites/index.haml +2 -0
- data/spec/controllers/spree/account/favourites_controller_spec.rb +1 -1
- data/spec/controllers/spree/account/orders_controller_spec.rb +1 -1
- data/spree_my_favourites.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 767fd8140f37c1168e7ae807c1fee928b9e28eb6
|
|
4
|
+
data.tar.gz: d32632f29744a46d183fc95f065b15e0b18656e2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c09a6229ea8304c76722c578ee73bef7b1e6774c107a8f0e74ac93c5177950266a2675df1a6a8d9b75d989151f20393c757bc142f41170c2b6f584bca7eb01a3
|
|
7
|
+
data.tar.gz: 48313c8636310f1a590bfede83da3474484e0b17e98ab48e32f5f13cecb5ea59cb8244bcde424b9a684d64410908cf1e76b414b62b6dcea0ec5c2873d1bbf8ef
|
|
@@ -37,3 +37,19 @@
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
@media screen and (max-width: '768px') {
|
|
42
|
+
|
|
43
|
+
#my-account table {
|
|
44
|
+
|
|
45
|
+
td.favourite-image {
|
|
46
|
+
display: none !important;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
th, td {
|
|
50
|
+
width: 100% !important;
|
|
51
|
+
display: block;
|
|
52
|
+
text-align: center;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -2,26 +2,32 @@ module Spree
|
|
|
2
2
|
module Account
|
|
3
3
|
class FavouritesController < Spree::StoreController
|
|
4
4
|
|
|
5
|
+
before_filter :check_logged_in_user
|
|
6
|
+
|
|
5
7
|
def index
|
|
6
8
|
@user = try_spree_current_user
|
|
7
9
|
if @user
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
result[line_item.variant.sku] = {variant: line_item.variant, number_of_orders: 1}
|
|
14
|
-
end
|
|
15
|
-
result
|
|
16
|
-
end
|
|
10
|
+
@line_items_by_variant = Spree::Variant.includes(line_items: [:order])
|
|
11
|
+
.where(['spree_orders.email = ?','francisco@yourgrocer.com.au'])
|
|
12
|
+
.where(['spree_orders.completed_at IS NOT NULL'])
|
|
13
|
+
.references(:orders).group('spree_variants.id')
|
|
14
|
+
.order('COUNT(spree_line_items.id) DESC').page(params[:page] || 1).per(15)
|
|
17
15
|
|
|
18
|
-
@favourites =
|
|
19
|
-
@
|
|
16
|
+
@favourites = []
|
|
17
|
+
@line_items_by_variant.count('spree_line_items.id').each do |variant_id, number_of_orders|
|
|
18
|
+
@favourites << {variant: Spree::Variant.find(variant_id), number_of_orders: number_of_orders}
|
|
19
|
+
end
|
|
20
20
|
else
|
|
21
21
|
unauthorized
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def check_logged_in_user
|
|
28
|
+
redirect_to spree_login_path unless try_spree_current_user
|
|
29
|
+
end
|
|
30
|
+
|
|
25
31
|
end
|
|
26
32
|
end
|
|
27
33
|
end
|
|
@@ -2,19 +2,23 @@ module Spree
|
|
|
2
2
|
module Account
|
|
3
3
|
class OrdersController < Spree::StoreController
|
|
4
4
|
|
|
5
|
+
before_filter :check_logged_in_user
|
|
6
|
+
|
|
5
7
|
def index
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@orders = @user.orders.complete.order('completed_at desc')
|
|
9
|
-
else
|
|
10
|
-
unauthorized
|
|
11
|
-
end
|
|
8
|
+
@user = try_spree_current_user
|
|
9
|
+
@orders = @user.orders.complete.order('completed_at desc')
|
|
12
10
|
end
|
|
13
11
|
|
|
14
12
|
def accurate_title
|
|
15
13
|
Spree.t(:my_account)
|
|
16
14
|
end
|
|
17
15
|
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def check_logged_in_user
|
|
19
|
+
redirect_to spree_login_path unless try_spree_current_user
|
|
20
|
+
end
|
|
21
|
+
|
|
18
22
|
end
|
|
19
23
|
end
|
|
20
24
|
end
|
|
@@ -6,5 +6,10 @@
|
|
|
6
6
|
%tbody
|
|
7
7
|
- favourites.each do |favourite|
|
|
8
8
|
%tr
|
|
9
|
+
%td.favourite-image
|
|
10
|
+
- if variant.images.length == 0
|
|
11
|
+
= link_to mini_image(variant.product), variant.product
|
|
12
|
+
- else
|
|
13
|
+
= link_to image_tag(variant.images.first.attachment.url(:small)), variant.product
|
|
9
14
|
%td.favourite-description= favourite[:variant].name
|
|
10
15
|
%td.favourite-number-orders= favourite[:number_of_orders]
|
|
@@ -16,7 +16,7 @@ describe Spree::Account::FavouritesController do
|
|
|
16
16
|
it 'should redirect to login if user is not logged in' do
|
|
17
17
|
controller.stub(:spree_current_user).and_return nil
|
|
18
18
|
spree_get :index
|
|
19
|
-
response.
|
|
19
|
+
response.should redirect_to(spree.login_path)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
end
|
|
@@ -23,7 +23,7 @@ describe Spree::Account::OrdersController do
|
|
|
23
23
|
it 'should redirect to login if user is not logged in' do
|
|
24
24
|
controller.stub(:spree_current_user).and_return nil
|
|
25
25
|
spree_get :index
|
|
26
|
-
response.
|
|
26
|
+
response.should redirect_to(spree.login_path)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
end
|
data/spree_my_favourites.gemspec
CHANGED