forked from paulcc/spree-reviews
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreviews_extension.rb
40 lines (32 loc) · 1.17 KB
/
reviews_extension.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application'
class ReviewsExtension < Spree::Extension
version "1.0"
description "Support for reviews and ratings within Spree"
url "git://github.com/paulcc/spree-reviews.git"
def activate
# admin.tabs.add "Reviews", "/admin/reviews", :after => "Layouts", :visibility => [:all]
Admin::ConfigurationsController.class_eval do
before_filter :add_review_links, :only => :index
def add_review_links
@extension_links << {:link => admin_reviews_path, :link_text => t('review_management'), :description => t('review_management_description')}
@extension_links << {:link => admin_review_settings_path, :link_text => t('reviews.review_settings'), :description => t('reviews.manage_review_settings') }
end
end
# Add access to reviews/ratings to the product model
Product.class_eval do
has_one :rating
has_many :reviews
def get_stars
if rating.nil?
[0,0]
else
[rating.get_stars, rating.count]
end
end
end
end
def deactivate
# admin.tabs.remove "Reviews"
end
end