spree_reviews_rating 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,7 @@ module Spree
5
5
  end
6
6
 
7
7
  def txt_stars(n, show_out_of = true)
8
+ return t('no_rated') unless n
8
9
  res = I18n.t('star', :count => n)
9
10
  res += ' ' + t('out_of_5') if show_out_of
10
11
  res
@@ -2,16 +2,13 @@ Spree::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
- if reviews_count > 0
11
- self.update_attributes(:avg_rating => self.reviews.approved.sum(:rating).to_f / reviews_count, :reviews_count => reviews_count)
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
 
17
14
  end
@@ -12,7 +12,7 @@ module Spree
12
12
 
13
13
  scope :oldest_first, :order => "created_at asc"
14
14
  scope :preview, :limit => Spree::Config[:preview_size], :order => "created_at desc"
15
- attr_protected :user_id, :product_id, :location
15
+ attr_accessible :rating, :review, :name
16
16
 
17
17
  end
18
18
  end
@@ -67,7 +67,7 @@ en:
67
67
  dow: "%A"
68
68
 
69
69
  approve: Approve
70
- on_stars: on
70
+ on_stars: 'on'
71
71
  stars: stars!
72
72
  Approved_reviews: Approved
73
73
  approved_text: Unlocked comments will be published within 1-2 business days.
@@ -89,6 +89,7 @@ en:
89
89
  leave_us_a_review: Leave us a review and a rating
90
90
  original_version: 'Original version'
91
91
  out_of_5: "out of 5"
92
+ no_rated: No rated
92
93
  created_at: Created at
93
94
  rating: rating
94
95
  reviews: Reviews
@@ -108,7 +109,7 @@ en:
108
109
  show_email: Show user email
109
110
  require_login: Authentication required
110
111
  form_show: View form for insert review
111
- on_stars: on
112
+ on_stars: 'on'
112
113
  write: Write
113
114
  a_review: a Review
114
115
  name: Name
@@ -67,7 +67,7 @@ it:
67
67
  dow: "%A"
68
68
 
69
69
  approve: Approvare
70
- on_stars: su
70
+ on_stars: "su"
71
71
  stars: stelle!
72
72
  Approved_reviews: Approvate
73
73
  approved_text: Unlocked comments will be published within 1-2 business days.
@@ -90,6 +90,7 @@ it:
90
90
  leave_us_a_review: Lasciaci un commento e un voto
91
91
  original_version: 'Original version'
92
92
  out_of_5: "su 5"
93
+ no_rated: Nessun voto
93
94
  created_at: Creata il
94
95
  rating: Voto
95
96
  review: Recensione
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_reviews_rating
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Damiano Giacomello
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-29 00:00:00 Z
18
+ date: 2012-04-05 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: spree_core
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  requirements:
210
210
  - none
211
211
  rubyforge_project:
212
- rubygems_version: 1.8.10
212
+ rubygems_version: 1.8.21
213
213
  signing_key:
214
214
  specification_version: 3
215
215
  summary: Basic review and ratings facility for Spree