spree_reviews_rating 0.70.6 → 0.70.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/store/review/new.js +2 -2
- data/app/models/{reviews_ability.rb → ability_decorator.rb} +4 -2
- data/app/models/app_configuration_decorator.rb +1 -4
- data/app/models/product_decorator.rb +4 -7
- data/app/models/review.rb +2 -2
- data/app/models/user_decorator.rb +7 -0
- data/db/migrate/20081020220724_create_reviews.rb +1 -1
- metadata +85 -96
@@ -12,6 +12,6 @@ $('.button-submit').click(function (event) {
|
|
12
12
|
url: $("#new_review").action,
|
13
13
|
data: ({authenticity_token: jQuery('meta[name="csrf-token"]').attr('content'), 'review[]': [$("#new_review").serializeArray()]}),
|
14
14
|
beforeSend: function(r){ $('#new_review').html('<p style="padding: 20px">Loading <img src="/assets/ratyloader.gif"/></p>');},
|
15
|
-
success: function(r){ $('#new_review').html(r);}
|
16
|
-
|
15
|
+
success: function(r){ $('#new_review').html(r);}
|
16
|
+
});
|
17
17
|
});
|
@@ -1,12 +1,14 @@
|
|
1
|
-
class
|
1
|
+
class AbilityDecorator
|
2
2
|
include CanCan::Ability
|
3
3
|
|
4
4
|
def initialize(user)
|
5
5
|
can :create, Review do |review|
|
6
6
|
user.has_role?(:user) || !Spree::Config[:require_login]
|
7
7
|
end
|
8
|
+
can :read, Review
|
8
9
|
can :create, FeedbackReview do |review|
|
9
10
|
user.has_role?(:user) || !Spree::Config[:require_login]
|
10
11
|
end
|
11
12
|
end
|
12
|
-
|
13
|
+
Ability.register_ability(AbilityDecorator)
|
14
|
+
end
|
@@ -1,16 +1,13 @@
|
|
1
1
|
AppConfiguration.class_eval do
|
2
|
+
|
2
3
|
# include non-approved reviews in (public) listings
|
3
4
|
preference :include_unapproved_reviews, :boolean, :default => false
|
4
|
-
|
5
5
|
# control how many reviews are shown in summaries etc.
|
6
6
|
preference :preview_size, :integer, :default => 3
|
7
|
-
|
8
7
|
# show a reviewer's email address
|
9
8
|
preference :show_email, :boolean, :default => false
|
10
|
-
|
11
9
|
# show helpfullness rating form elements
|
12
10
|
preference :feedback_rating, :boolean, :default => false
|
13
|
-
|
14
11
|
# require login to post reviews
|
15
12
|
preference :require_login, :boolean, :default => true
|
16
13
|
end
|
@@ -2,15 +2,12 @@ Product.class_eval do
|
|
2
2
|
has_many :reviews
|
3
3
|
|
4
4
|
def get_stars
|
5
|
-
{:star => avg_rating.round, :rcount => reviews_count}
|
5
|
+
{:star => ((2.0 * self.avg_rating).round / 2.0), :rcount => reviews_count}
|
6
6
|
end
|
7
7
|
|
8
8
|
def recalculate_rating
|
9
|
-
reviews_count = reviews.reload.approved.count
|
10
|
-
|
11
|
-
|
12
|
-
else
|
13
|
-
self.update_attribute :avg_rating, 0
|
14
|
-
end
|
9
|
+
reviews_count = reviews.reload.approved.where('rating IS NOT NULL').count
|
10
|
+
avg_rating = (reviews_count > 0) ? (self.reviews.approved.sum(:rating).to_f / reviews_count) : 0
|
11
|
+
self.update_attributes(:avg_rating => avg_rating, :reviews_count => reviews_count)
|
15
12
|
end
|
16
13
|
end
|
data/app/models/review.rb
CHANGED
@@ -4,14 +4,14 @@ class Review < ActiveRecord::Base
|
|
4
4
|
has_many :feedback_reviews
|
5
5
|
|
6
6
|
validates_presence_of :name, :review
|
7
|
-
validates_numericality_of :rating, :
|
7
|
+
validates_numericality_of :rating, :if => Proc.new {|r| !r.rating.blank?}
|
8
8
|
default_scope order("created_at DESC")
|
9
9
|
scope :not_approved, where("approved = ?", false)
|
10
10
|
|
11
11
|
scope :approved, lambda {|*args| {:conditions => ["(? = ?) or (approved = ?)", Spree::Config[:include_unapproved_reviews], true, true ]}}
|
12
12
|
|
13
13
|
scope :oldest_first, :order => "created_at asc"
|
14
|
-
scope :preview,
|
14
|
+
scope :preview, :limit => Spree::Config[:preview_size], :order => "created_at desc"
|
15
15
|
attr_protected :user_id, :product_id, :location
|
16
16
|
|
17
17
|
def feedback_stars
|
metadata
CHANGED
@@ -1,103 +1,102 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_reviews_rating
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.70.6.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 70
|
9
|
-
- 6
|
10
|
-
version: 0.70.6
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Damiano Giacomello
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-06-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: spree_core
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: spree_auth
|
36
23
|
prerelease: false
|
37
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: spree_auth
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
38
33
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
version: "0"
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
46
38
|
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: formtastic
|
50
39
|
prerelease: false
|
51
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: formtastic
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
52
49
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
segments:
|
58
|
-
- 0
|
59
|
-
version: "0"
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
60
54
|
type: :runtime
|
61
|
-
version_requirements: *id003
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: paperclip
|
64
55
|
prerelease: false
|
65
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
57
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: paperclip
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
75
69
|
version: 2.5.0
|
76
70
|
type: :runtime
|
77
|
-
version_requirements: *id004
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: rspec-rails
|
80
71
|
prerelease: false
|
81
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.5.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec-rails
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
82
81
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
segments:
|
88
|
-
- 0
|
89
|
-
version: "0"
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
90
86
|
type: :development
|
91
|
-
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
92
94
|
description:
|
93
95
|
email: damiano.giacomello@diginess.it
|
94
96
|
executables: []
|
95
|
-
|
96
97
|
extensions: []
|
97
|
-
|
98
98
|
extra_rdoc_files: []
|
99
|
-
|
100
|
-
files:
|
99
|
+
files:
|
101
100
|
- README.md
|
102
101
|
- lib/generators/spree_reviews_rating/install/install_generator.rb
|
103
102
|
- lib/spree_reviews_rating/engine.rb
|
@@ -141,12 +140,13 @@ files:
|
|
141
140
|
- app/helpers/admin/feedback_reviews_helper.rb
|
142
141
|
- app/helpers/feedback_reviews_helper.rb
|
143
142
|
- app/helpers/reviews_helper.rb
|
143
|
+
- app/models/ability_decorator.rb
|
144
144
|
- app/models/app_configuration_decorator.rb
|
145
145
|
- app/models/feedback_review.rb
|
146
146
|
- app/models/product_decorator.rb
|
147
147
|
- app/models/review.rb
|
148
148
|
- app/models/review_sweeper.rb
|
149
|
-
- app/models/
|
149
|
+
- app/models/user_decorator.rb
|
150
150
|
- app/overrides/add_review_bottom_sidebar.rb
|
151
151
|
- app/overrides/add_reviews_after_product_properties.rb
|
152
152
|
- app/overrides/add_reviews_tab_to_admin.rb
|
@@ -186,38 +186,27 @@ files:
|
|
186
186
|
- config/routes.rb
|
187
187
|
homepage: https://github.com/romul/spree-reviews/
|
188
188
|
licenses: []
|
189
|
-
|
190
189
|
post_install_message:
|
191
190
|
rdoc_options: []
|
192
|
-
|
193
|
-
require_paths:
|
191
|
+
require_paths:
|
194
192
|
- lib
|
195
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
196
194
|
none: false
|
197
|
-
requirements:
|
198
|
-
- -
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
hash: 57
|
201
|
-
segments:
|
202
|
-
- 1
|
203
|
-
- 8
|
204
|
-
- 7
|
195
|
+
requirements:
|
196
|
+
- - ! '>='
|
197
|
+
- !ruby/object:Gem::Version
|
205
198
|
version: 1.8.7
|
206
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
200
|
none: false
|
208
|
-
requirements:
|
209
|
-
- -
|
210
|
-
- !ruby/object:Gem::Version
|
211
|
-
|
212
|
-
|
213
|
-
- 0
|
214
|
-
version: "0"
|
215
|
-
requirements:
|
201
|
+
requirements:
|
202
|
+
- - ! '>='
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '0'
|
205
|
+
requirements:
|
216
206
|
- none
|
217
207
|
rubyforge_project:
|
218
|
-
rubygems_version: 1.8.
|
208
|
+
rubygems_version: 1.8.22
|
219
209
|
signing_key:
|
220
210
|
specification_version: 3
|
221
211
|
summary: Basic review and ratings facility for Spree
|
222
212
|
test_files: []
|
223
|
-
|