spree_reviews_rating 0.70.7.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/README.md +7 -7
  2. data/app/assets/javascripts/store/review/index.js +13 -12
  3. data/app/assets/javascripts/store/spree_reviews_rating.js +15 -4
  4. data/app/assets/stylesheets/admin/spree_reviews_rating.css +1 -1
  5. data/app/assets/stylesheets/store/spree_reviews_rating.css +43 -0
  6. data/app/controllers/spree/admin/review_settings_controller.rb +25 -0
  7. data/app/controllers/spree/admin/reviews_controller.rb +30 -0
  8. data/app/controllers/spree/products_controller_decorator.rb +3 -0
  9. data/app/controllers/spree/reviews_controller.rb +55 -0
  10. data/app/helpers/spree/reviews_helper.rb +14 -0
  11. data/app/models/spree/ability_decorator.rb +11 -0
  12. data/app/models/{app_configuration_decorator.rb → spree/app_configuration_decorator.rb} +6 -3
  13. data/app/models/spree/product_decorator.rb +17 -0
  14. data/app/models/spree/review.rb +18 -0
  15. data/app/models/spree/review_sweeper.rb +24 -0
  16. data/app/models/spree/user_decorator.rb +7 -0
  17. data/app/overrides/add_review_bottom_sidebar.rb +2 -2
  18. data/app/overrides/reviews_admin_configuration_menu.rb +11 -0
  19. data/app/overrides/{add_reviews_tab_to_admin.rb → reviews_admin_tab.rb} +1 -1
  20. data/app/overrides/reviews_global_rating_product.rb +4 -0
  21. data/app/overrides/reviews_product_properties.rb +4 -0
  22. data/app/views/spree/admin/review_settings/edit.html.erb +18 -0
  23. data/app/views/spree/admin/review_settings/show.html.erb +44 -0
  24. data/app/views/spree/admin/reviews/_form.html.erb +6 -0
  25. data/app/views/spree/admin/reviews/edit.html.erb +19 -0
  26. data/app/views/{admin → spree/admin}/reviews/index.html.erb +7 -11
  27. data/app/views/spree/admin/shared/_reviews_setting_configurations_menu.html.erb +4 -0
  28. data/app/views/spree/reviews/_fine_print.html.erb +8 -0
  29. data/app/views/spree/reviews/_form.html.erb +22 -0
  30. data/app/views/spree/reviews/_new.html.erb +4 -0
  31. data/app/views/{reviews → spree/reviews}/_stars.html.erb +4 -1
  32. data/app/views/{reviews → spree/reviews}/all_list.html.erb +0 -0
  33. data/app/views/spree/reviews/error.js.erb +2 -0
  34. data/app/views/spree/reviews/index.html.erb +1 -0
  35. data/app/views/{reviews → spree/reviews}/new.html.erb +2 -3
  36. data/app/views/spree/reviews/success.js.erb +2 -0
  37. data/app/views/spree/shared/_rating.html.erb +28 -0
  38. data/app/views/spree/shared/_review.html.erb +19 -0
  39. data/app/views/{shared → spree/shared}/_review_link.html.erb +0 -0
  40. data/app/views/spree/shared/_review_summary.html.erb +7 -0
  41. data/app/views/spree/shared/_reviews.html.erb +23 -0
  42. data/app/views/{shared → spree/shared}/_shortrating.html.erb +1 -1
  43. data/app/views/spree/shared/_single_rating.html.erb +20 -0
  44. data/config/locales/en.yml +72 -6
  45. data/config/locales/it.yml +78 -12
  46. data/config/routes.rb +2 -9
  47. data/db/migrate/20081020220724_create_reviews.rb +2 -6
  48. data/db/migrate/20110406083603_add_rating_to_products.rb +3 -8
  49. data/db/migrate/20120123141326_recalculate_ratings.rb +3 -3
  50. data/db/migrate/20120323165848_reviews_rating_namespace.rb +5 -0
  51. data/lib/generators/spree_reviews_rating/install/install_generator.rb +1 -11
  52. data/lib/spree_reviews_rating.rb +0 -1
  53. metadata +135 -114
  54. data/app/controllers/admin/feedback_reviews_controller.rb +0 -6
  55. data/app/controllers/admin/review_settings_controller.rb +0 -16
  56. data/app/controllers/admin/reviews_controller.rb +0 -20
  57. data/app/controllers/feedback_reviews_controller.rb +0 -20
  58. data/app/controllers/products_controller_decorator.rb +0 -3
  59. data/app/controllers/reviews_controller.rb +0 -52
  60. data/app/helpers/admin/feedback_reviews_helper.rb +0 -2
  61. data/app/helpers/feedback_reviews_helper.rb +0 -2
  62. data/app/helpers/reviews_helper.rb +0 -11
  63. data/app/models/ability_decorator.rb +0 -14
  64. data/app/models/feedback_review.rb +0 -12
  65. data/app/models/product_decorator.rb +0 -15
  66. data/app/models/review.rb +0 -21
  67. data/app/models/review_sweeper.rb +0 -21
  68. data/app/models/user_decorator.rb +0 -7
  69. data/app/overrides/add_reviews_after_product_properties.rb +0 -4
  70. data/app/overrides/add_reviews_to_admin_configuration_menu.rb +0 -4
  71. data/app/views/admin/feedback_reviews/index.html.erb +0 -21
  72. data/app/views/admin/review_settings/edit.html.erb +0 -30
  73. data/app/views/admin/review_settings/show.html.erb +0 -30
  74. data/app/views/admin/reviews/_form.html.erb +0 -10
  75. data/app/views/admin/reviews/edit.html.erb +0 -17
  76. data/app/views/feedback_reviews/_form.html.erb +0 -15
  77. data/app/views/feedback_reviews/_summary.html.erb +0 -6
  78. data/app/views/feedback_reviews/create.js.erb +0 -7
  79. data/app/views/reviews/_fine_print.html.erb +0 -9
  80. data/app/views/reviews/_form.html.erb +0 -23
  81. data/app/views/reviews/index.html.erb +0 -1
  82. data/app/views/reviews/submissionguidelines.html.erb +0 -6
  83. data/app/views/reviews/terms.html.erb +0 -6
  84. data/app/views/shared/_rating.html.erb +0 -25
  85. data/app/views/shared/_review.html.erb +0 -17
  86. data/app/views/shared/_review_summary.html.erb +0 -10
  87. data/app/views/shared/_reviews.html.erb +0 -13
  88. data/config/initializers/helpers.rb +0 -2
  89. data/config/initializers/load_preferences.rb +0 -5
  90. data/db/migrate/20101222083309_create_feedback_reviews.rb +0 -18
metadata CHANGED
@@ -1,86 +1,103 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: spree_reviews_rating
3
- version: !ruby/object:Gem::Version
4
- version: 0.70.7.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Damiano Giacomello
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-07-22 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-03-29 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: spree_core
16
- requirement: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
22
32
  type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: spree_auth
23
36
  prerelease: false
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: formtastic
32
- requirement: !ruby/object:Gem::Requirement
37
+ requirement: &id002 !ruby/object:Gem::Requirement
33
38
  none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
38
46
  type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: formtastic
39
50
  prerelease: false
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: paperclip
48
- requirement: !ruby/object:Gem::Requirement
51
+ requirement: &id003 !ruby/object:Gem::Requirement
49
52
  none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: 2.5.0
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
54
60
  type: :runtime
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: paperclip
55
64
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
65
+ requirement: &id004 !ruby/object:Gem::Requirement
57
66
  none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 27
71
+ segments:
72
+ - 2
73
+ - 5
74
+ - 0
61
75
  version: 2.5.0
62
- - !ruby/object:Gem::Dependency
76
+ type: :runtime
77
+ version_requirements: *id004
78
+ - !ruby/object:Gem::Dependency
63
79
  name: rspec-rails
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
80
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
81
+ requirement: &id005 !ruby/object:Gem::Requirement
73
82
  none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ type: :development
91
+ version_requirements: *id005
78
92
  description:
79
93
  email: damiano.giacomello@diginess.it
80
94
  executables: []
95
+
81
96
  extensions: []
97
+
82
98
  extra_rdoc_files: []
83
- files:
99
+
100
+ files:
84
101
  - README.md
85
102
  - lib/generators/spree_reviews_rating/install/install_generator.rb
86
103
  - lib/spree_reviews_rating/engine.rb
@@ -115,82 +132,86 @@ files:
115
132
  - app/assets/javascripts/store/spree_reviews_rating.js
116
133
  - app/assets/stylesheets/admin/spree_reviews_rating.css
117
134
  - app/assets/stylesheets/store/spree_reviews_rating.css
118
- - app/controllers/admin/feedback_reviews_controller.rb
119
- - app/controllers/admin/review_settings_controller.rb
120
- - app/controllers/admin/reviews_controller.rb
121
- - app/controllers/feedback_reviews_controller.rb
122
- - app/controllers/products_controller_decorator.rb
123
- - app/controllers/reviews_controller.rb
124
- - app/helpers/admin/feedback_reviews_helper.rb
125
- - app/helpers/feedback_reviews_helper.rb
126
- - app/helpers/reviews_helper.rb
127
- - app/models/ability_decorator.rb
128
- - app/models/app_configuration_decorator.rb
129
- - app/models/feedback_review.rb
130
- - app/models/product_decorator.rb
131
- - app/models/review.rb
132
- - app/models/review_sweeper.rb
133
- - app/models/user_decorator.rb
135
+ - app/controllers/spree/admin/review_settings_controller.rb
136
+ - app/controllers/spree/admin/reviews_controller.rb
137
+ - app/controllers/spree/products_controller_decorator.rb
138
+ - app/controllers/spree/reviews_controller.rb
139
+ - app/helpers/spree/reviews_helper.rb
140
+ - app/models/spree/ability_decorator.rb
141
+ - app/models/spree/app_configuration_decorator.rb
142
+ - app/models/spree/product_decorator.rb
143
+ - app/models/spree/review.rb
144
+ - app/models/spree/review_sweeper.rb
145
+ - app/models/spree/user_decorator.rb
134
146
  - app/overrides/add_review_bottom_sidebar.rb
135
- - app/overrides/add_reviews_after_product_properties.rb
136
- - app/overrides/add_reviews_tab_to_admin.rb
137
- - app/overrides/add_reviews_to_admin_configuration_menu.rb
138
- - app/views/admin/feedback_reviews/index.html.erb
139
- - app/views/admin/review_settings/edit.html.erb
140
- - app/views/admin/review_settings/show.html.erb
141
- - app/views/admin/reviews/_form.html.erb
142
- - app/views/admin/reviews/edit.html.erb
143
- - app/views/admin/reviews/index.html.erb
144
- - app/views/feedback_reviews/_form.html.erb
145
- - app/views/feedback_reviews/_summary.html.erb
146
- - app/views/feedback_reviews/create.js.erb
147
- - app/views/reviews/_fine_print.html.erb
148
- - app/views/reviews/_form.html.erb
149
- - app/views/reviews/_stars.html.erb
150
- - app/views/reviews/all_list.html.erb
151
- - app/views/reviews/index.html.erb
152
- - app/views/reviews/new.html.erb
153
- - app/views/reviews/submissionguidelines.html.erb
154
- - app/views/reviews/terms.html.erb
155
- - app/views/shared/_rating.html.erb
156
- - app/views/shared/_review.html.erb
157
- - app/views/shared/_review_link.html.erb
158
- - app/views/shared/_review_summary.html.erb
159
- - app/views/shared/_reviews.html.erb
160
- - app/views/shared/_shortrating.html.erb
147
+ - app/overrides/reviews_admin_configuration_menu.rb
148
+ - app/overrides/reviews_admin_tab.rb
149
+ - app/overrides/reviews_global_rating_product.rb
150
+ - app/overrides/reviews_product_properties.rb
151
+ - app/views/spree/admin/review_settings/edit.html.erb
152
+ - app/views/spree/admin/review_settings/show.html.erb
153
+ - app/views/spree/admin/reviews/_form.html.erb
154
+ - app/views/spree/admin/reviews/edit.html.erb
155
+ - app/views/spree/admin/reviews/index.html.erb
156
+ - app/views/spree/admin/shared/_reviews_setting_configurations_menu.html.erb
157
+ - app/views/spree/reviews/_fine_print.html.erb
158
+ - app/views/spree/reviews/_form.html.erb
159
+ - app/views/spree/reviews/_new.html.erb
160
+ - app/views/spree/reviews/_stars.html.erb
161
+ - app/views/spree/reviews/all_list.html.erb
162
+ - app/views/spree/reviews/error.js.erb
163
+ - app/views/spree/reviews/index.html.erb
164
+ - app/views/spree/reviews/new.html.erb
165
+ - app/views/spree/reviews/success.js.erb
166
+ - app/views/spree/shared/_rating.html.erb
167
+ - app/views/spree/shared/_review.html.erb
168
+ - app/views/spree/shared/_review_link.html.erb
169
+ - app/views/spree/shared/_review_summary.html.erb
170
+ - app/views/spree/shared/_reviews.html.erb
171
+ - app/views/spree/shared/_shortrating.html.erb
172
+ - app/views/spree/shared/_single_rating.html.erb
161
173
  - db/migrate/20081020220724_create_reviews.rb
162
- - db/migrate/20101222083309_create_feedback_reviews.rb
163
174
  - db/migrate/20110406083603_add_rating_to_products.rb
164
175
  - db/migrate/20120123141326_recalculate_ratings.rb
176
+ - db/migrate/20120323165848_reviews_rating_namespace.rb
165
177
  - config/initializers/constants.rb
166
- - config/initializers/helpers.rb
167
- - config/initializers/load_preferences.rb
168
178
  - config/locales/en.yml
169
179
  - config/locales/it.yml
170
180
  - config/routes.rb
171
- homepage: https://github.com/romul/spree-reviews/
181
+ homepage:
172
182
  licenses: []
183
+
173
184
  post_install_message:
174
185
  rdoc_options: []
175
- require_paths:
186
+
187
+ require_paths:
176
188
  - lib
177
- required_ruby_version: !ruby/object:Gem::Requirement
189
+ required_ruby_version: !ruby/object:Gem::Requirement
178
190
  none: false
179
- requirements:
180
- - - ! '>='
181
- - !ruby/object:Gem::Version
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ hash: 57
195
+ segments:
196
+ - 1
197
+ - 8
198
+ - 7
182
199
  version: 1.8.7
183
- required_rubygems_version: !ruby/object:Gem::Requirement
200
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
201
  none: false
185
- requirements:
186
- - - ! '>='
187
- - !ruby/object:Gem::Version
188
- version: '0'
189
- requirements:
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ hash: 3
206
+ segments:
207
+ - 0
208
+ version: "0"
209
+ requirements:
190
210
  - none
191
211
  rubyforge_project:
192
- rubygems_version: 1.8.22
212
+ rubygems_version: 1.8.10
193
213
  signing_key:
194
214
  specification_version: 3
195
215
  summary: Basic review and ratings facility for Spree
196
216
  test_files: []
217
+
@@ -1,6 +0,0 @@
1
- class Admin::FeedbackReviewsController < Admin::ResourceController
2
- def index
3
- @review = Review.find(params[:review_id])
4
- @collection = @review.feedback_reviews
5
- end
6
- end
@@ -1,16 +0,0 @@
1
- class Admin::ReviewSettingsController < Admin::BaseController
2
- def update
3
- # workaround for unset checkbox behaviour
4
- params[:preferences][:include_unapproved_reviews] = false if params[:preferences][:include_unapproved_reviews].blank?
5
- params[:preferences][:feedback_rating] = false if params[:preferences][:feedback_rating].blank?
6
- params[:preferences][:show_email] = false if params[:preferences][:show_email].blank?
7
- params[:preferences][:require_login] = false if params[:preferences][:require_login].blank?
8
- Spree::Config.set(params[:preferences])
9
-
10
- respond_to do |format|
11
- format.html {
12
- redirect_to admin_review_settings_path
13
- }
14
- end
15
- end
16
- end
@@ -1,20 +0,0 @@
1
- class Admin::ReviewsController < Admin::ResourceController
2
- helper ReviewsHelper
3
-
4
- def index
5
- @unapproved_reviews = Review.not_approved.find(:all, :order => "created_at DESC")
6
- @approved_reviews = Review.approved.find(:all, :order => "created_at DESC")
7
- end
8
-
9
- def approve
10
- r = Review.find(params[:id])
11
-
12
- if r.update_attribute(:approved, true)
13
- r.product.recalculate_rating
14
- flash[:notice] = t("info_approve_review")
15
- else
16
- flash[:error] = t("error_approve_review")
17
- end
18
- redirect_to admin_reviews_path
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- class FeedbackReviewsController < Spree::BaseController
2
- helper Spree::BaseHelper
3
-
4
- def create
5
- params[:feedback_review][:rating].sub!(/\s*stars/,'') unless params[:feedback_review][:rating].blank?
6
-
7
- @review = Review.find_by_id(params[:review_id])
8
- if @review && @feedback_review = @review.feedback_reviews.new(params[:feedback_review])
9
- authorize! :create, @feedback_review
10
- @feedback_review.save
11
- end
12
-
13
- respond_to do |format|
14
- format.html { redirect_to :back }
15
- format.js { render :action => :create }
16
- end
17
-
18
- end
19
- end
20
-
@@ -1,3 +0,0 @@
1
- ProductsController.class_eval do
2
- helper ReviewsHelper
3
- end
@@ -1,52 +0,0 @@
1
- class ReviewsController < Spree::BaseController
2
- helper Spree::BaseHelper
3
-
4
- before_filter :load_product, :only => [:index, :new, :create]
5
- rescue_from ActiveRecord::RecordNotFound, :with => :render_404
6
-
7
- def index
8
- @approved_reviews = Review.approved.find_all_by_product_id(@product.id)
9
- end
10
-
11
- def all_list
12
- @approved_reviews = Review.approved.order("created_at DESC")
13
- respond_to do |f|
14
- f.html
15
- end
16
- end
17
-
18
- def new
19
- @review = Review.new(:product => @product)
20
- authorize! :new, @review
21
- render :layout => false
22
- end
23
-
24
- # save if all ok
25
- def create
26
- #params[:review][:rating].sub!(/\s*stars/,'') unless params[:review][:rating].blank?
27
-
28
- @review = Review.new(params[:review])
29
- @review.product = @product
30
- @review.user = current_user if user_signed_in?
31
- @review.location = request.remote_ip
32
-
33
- authorize! :create, @review
34
-
35
- if @review.save
36
- flash[:notice] = t('review_successfully_submitted')
37
- redirect_to (product_path(@product))
38
- else
39
- render :action => "new"
40
- end
41
- end
42
-
43
- def terms
44
- end
45
-
46
- private
47
-
48
- def load_product
49
- @product = Product.find_by_permalink!(params[:product_id])
50
- end
51
-
52
- end
@@ -1,2 +0,0 @@
1
- module Admin::FeedbackReviewsHelper
2
- end
@@ -1,2 +0,0 @@
1
- module FeedbackReviewsHelper
2
- end
@@ -1,11 +0,0 @@
1
- module ReviewsHelper
2
- def mk_stars(m)
3
- (1..5).collect {|n| n <= m ? star("lit") : star("unlit") }.join
4
- end
5
-
6
- def txt_stars(n, show_out_of = true)
7
- res = I18n.t('star', :count => n)
8
- res += ' ' + t('out_of_5') if show_out_of
9
- res
10
- end
11
- end
@@ -1,14 +0,0 @@
1
- class AbilityDecorator
2
- include CanCan::Ability
3
-
4
- def initialize(user)
5
- can :create, Review do |review|
6
- user.has_role?(:user) || !Spree::Config[:require_login]
7
- end
8
- can :read, Review
9
- can :create, FeedbackReview do |review|
10
- user.has_role?(:user) || !Spree::Config[:require_login]
11
- end
12
- end
13
- Ability.register_ability(AbilityDecorator)
14
- end
@@ -1,12 +0,0 @@
1
- class FeedbackReview < ActiveRecord::Base
2
- belongs_to :review
3
- belongs_to :user
4
-
5
- attr_accessible :rating, :comment, :review, :user, :review_id, :user_id
6
-
7
- validates_presence_of :review_id
8
- validates_numericality_of :rating, :only_integer => true, :greater_than_or_equal_to => 1, :less_than_or_equal_to => 5, :message => I18n.t('you_must_enter_value_for_rating')
9
-
10
- default_scope order("created_at DESC")
11
-
12
- end
@@ -1,15 +0,0 @@
1
- Product.class_eval do
2
- has_many :reviews
3
-
4
- attr_accessible :avg_rating, :reviews_count
5
-
6
- def get_stars
7
- {:star => ((2.0 * self.avg_rating).round / 2.0), :rcount => reviews_count}
8
- end
9
-
10
- def recalculate_rating
11
- reviews_count = reviews.reload.approved.where('rating IS NOT NULL').count
12
- avg_rating = (reviews_count > 0) ? (self.reviews.approved.sum(:rating).to_f / reviews_count) : 0
13
- self.update_attributes(:avg_rating => avg_rating, :reviews_count => reviews_count)
14
- end
15
- end
data/app/models/review.rb DELETED
@@ -1,21 +0,0 @@
1
- class Review < ActiveRecord::Base
2
- belongs_to :product
3
- belongs_to :user
4
- has_many :feedback_reviews
5
-
6
- attr_accessible :rating, :review, :name, :product, :user, :product_id, :user_id
7
-
8
- validates_presence_of :name, :review
9
- validates_numericality_of :rating, :if => Proc.new {|r| !r.rating.blank?}
10
-
11
- default_scope order("created_at DESC")
12
- scope :not_approved, where("approved = ?", false)
13
- scope :approved, lambda {|*args| {:conditions => ["(? = ?) or (approved = ?)", Spree::Config[:include_unapproved_reviews], true, true ]}}
14
- scope :oldest_first, :order => "created_at asc"
15
- scope :preview, :limit => Spree::Config[:preview_size], :order => "created_at desc"
16
-
17
- def feedback_stars
18
- return 0 if feedback_reviews.count <= 0
19
- ((feedback_reviews.sum(:rating)/feedback_reviews.count) + 0.5).floor
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- class ReviewSweeper < ActionController::Caching::Sweeper
2
- observe Review
3
-
4
- def after_create(review)
5
- expire_cache_for(review)
6
- end
7
-
8
- def after_update(review)
9
- expire_cache_for(review)
10
- end
11
-
12
- def after_destroy(review)
13
- expire_cache_for(review)
14
- end
15
-
16
- private
17
-
18
- def expire_cache_for(review)
19
- review.product.recalculate_rating
20
- end
21
- end
@@ -1,7 +0,0 @@
1
- User.class_eval do
2
- before_create :set_role
3
-
4
- def set_role
5
- self.role_ids = Role.find_by_name("user").id
6
- end
7
- end
@@ -1,4 +0,0 @@
1
- Deface::Override.new(:virtual_path => "products/show",
2
- :name => "converted_product_properties_767643482",
3
- :insert_after => "[data-hook='product_properties']",
4
- :partial => "shared/reviews")
@@ -1,4 +0,0 @@
1
- Deface::Override.new(:virtual_path => "admin/configurations/index",
2
- :name => "converted_admin_configurations_menu_286465532",
3
- :insert_after => "[data-hook='admin_configurations_menu']",
4
- :text => "<%= configurations_menu_item(t('spree_reviews.review_settings'), admin_review_settings_path, t('spree_reviews.manage_review_settings')) %>")
@@ -1,21 +0,0 @@
1
- <h1><%= link_to t('feedback_review_for', :review => @review.title ), admin_reviews_path %></h1>
2
-
3
-
4
- <table class="index">
5
- <tr>
6
- <th><%= t('date_') %></th>
7
- <th><%= t('user') %></th>
8
- <th><%= t('stars') %></th>
9
- <th></th>
10
- </tr>
11
- <% @collection.each do |feedback| %>
12
- <tr id="<%= dom_id(feedback) %>">
13
- <td><%= l feedback.created_at %></td>
14
- <td><%= feedback.user.try(:login) || "anonimus" %></td>
15
- <td><%= feedback.rating %></td>
16
- <td class="actions">
17
- <%= link_to_delete feedback %>
18
- </td>
19
- </tr>
20
- <% end %>
21
- </table>
@@ -1,30 +0,0 @@
1
- <%= render :partial => 'admin/shared/configuration_menu' %>
2
-
3
- <h1><%= t("spree_reviews.review_settings") %></h1>
4
-
5
- <%= form_tag(admin_review_settings_path, :method => :put) do %>
6
- <p>
7
- <label><%= t("spree_reviews.include_unapproved") %>:</label>
8
- <%= check_box_tag('preferences[include_unapproved_reviews]', "1", Spree::Config[:include_unapproved_reviews]) %>
9
- </p>
10
- <p>
11
- <label><%= t("spree_reviews.feedback_rating") %>:</label>
12
- <%= check_box_tag('preferences[feedback_rating]', "1", Spree::Config[:feedback_rating]) %>
13
- </p>
14
- <p>
15
- <label><%= t("spree_reviews.show_email") %>:</label>
16
- <%= check_box_tag('preferences[show_email]', "1", Spree::Config[:show_email]) %>
17
- </p>
18
- <p>
19
- <label><%= t("spree_reviews.require_login") %>:</label>
20
- <%= check_box_tag('preferences[require_login]', "1", Spree::Config[:require_login]) %>
21
- </p>
22
- <p>
23
- <label><%= t('spree_reviews.preview_size') %>:</label>
24
- <%= text_field_tag('preferences[preview_size]', Spree::Config[:preview_size], :size => 3) %>
25
- </p>
26
- <p class="form-buttons">
27
- <%= button t('update') %>
28
- <%= t("or") %> <%= link_to t("cancel"), admin_review_settings_url %>
29
- </p>
30
- <% end %>
@@ -1,30 +0,0 @@
1
- <%= render :partial => 'admin/shared/configuration_menu' %>
2
-
3
- <h1><%= t("spree_reviews.review_settings") %></h1>
4
-
5
- <table>
6
- <tr>
7
- <th scope="row"><%= t("spree_reviews.include_unapproved") %>:</th>
8
- <td><%= Spree::Config[:include_unapproved_reviews] ? t('yes') : t('no') %></td>
9
- </tr>
10
- <tr>
11
- <th scope="row"><%= t("spree_reviews.feedback_rating") %>:</th>
12
- <td><%= Spree::Config[:feedback_rating] ? t('yes') : t('no') %></td>
13
- </tr>
14
- <tr>
15
- <th scope="row"><%= t("spree_reviews.show_email") %>:</th>
16
- <td><%= Spree::Config[:show_email] ? t('yes') : t('no') %></td>
17
- </tr>
18
- <tr>
19
- <th scope="row"><%= t("spree_reviews.require_login") %>:</th>
20
- <td><%= Spree::Config[:require_login] ? t('yes') : t('no') %></td>
21
- </tr>
22
- <tr>
23
- <th scope="row"><%= t("spree_reviews.preview_size") %>:</th>
24
- <td><%= Spree::Config[:preview_size] %></td>
25
- </tr>
26
- </table>
27
-
28
- <p>
29
- <%= link_to_with_icon('edit', t("edit"), edit_admin_review_settings_path) %>
30
- </p>
@@ -1,10 +0,0 @@
1
- <%= render "shared/error_messages", :target => @review %>
2
- <br />
3
- <p>
4
- <%= form.text_area :review, :cols => 60, :rows => 10 %>
5
- </p>
6
- <br/>
7
- <p>
8
- <%= form.input, :submit button_name %>
9
- </p>
10
-