solidus_reviews 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gem_release.yml +5 -0
  3. data/.github/stale.yml +17 -0
  4. data/.gitignore +11 -8
  5. data/.rspec +1 -1
  6. data/.rubocop.yml +1 -11
  7. data/CHANGELOG.md +32 -0
  8. data/Gemfile +9 -13
  9. data/{LICENSE.md → LICENSE} +1 -1
  10. data/Rakefile +4 -19
  11. data/app/controllers/spree/reviews_controller.rb +29 -2
  12. data/app/decorators/controllers/solidus_reviews/spree/{admin/products_controller_decorator.rb → products_controller_decorator.rb} +0 -4
  13. data/app/models/spree/feedback_review.rb +1 -1
  14. data/app/models/spree/permission_sets/review_display.rb +11 -0
  15. data/app/models/spree/permission_sets/review_management.rb +11 -0
  16. data/app/models/spree/review.rb +16 -2
  17. data/app/models/spree/reviews_ability.rb +5 -0
  18. data/app/models/spree/reviews_configuration.rb +10 -1
  19. data/app/overrides/add_reviews_tab_to_admin.rb +12 -4
  20. data/app/overrides/add_reviews_to_admin_configuration_sidebar.rb +12 -5
  21. data/app/views/spree/admin/review_settings/edit.html.erb +7 -0
  22. data/app/views/spree/admin/reviews/edit.html.erb +4 -2
  23. data/app/views/spree/admin/reviews/index.html.erb +9 -5
  24. data/app/views/spree/reviews/_form.html.erb +6 -4
  25. data/app/views/spree/reviews/edit.html.erb +3 -0
  26. data/app/views/spree/shared/_review.html.erb +6 -4
  27. data/bin/console +17 -0
  28. data/bin/rails +11 -3
  29. data/bin/setup +8 -0
  30. data/config/locales/de-CH.yml +1 -1
  31. data/config/locales/de.yml +1 -1
  32. data/config/locales/en-GB.yml +2 -1
  33. data/config/locales/en.yml +2 -1
  34. data/config/locales/es.yml +2 -1
  35. data/config/locales/fr.yml +1 -1
  36. data/config/locales/it.yml +1 -1
  37. data/config/locales/pl.yml +1 -1
  38. data/config/locales/pt-BR.yml +1 -1
  39. data/config/locales/pt.yml +1 -1
  40. data/config/locales/ro.yml +1 -1
  41. data/config/locales/sv.yml +1 -1
  42. data/config/locales/tr.yml +1 -1
  43. data/config/locales/uk.yml +1 -1
  44. data/config/locales/zh-CN.yml +1 -1
  45. data/config/locales/zh-TW.yml +1 -1
  46. data/config/routes.rb +3 -1
  47. data/lib/controllers/spree/api/feedback_reviews_controller.rb +91 -0
  48. data/lib/solidus_reviews.rb +2 -4
  49. data/lib/solidus_reviews/engine.rb +12 -8
  50. data/lib/solidus_reviews/version.rb +1 -1
  51. data/solidus_reviews.gemspec +19 -12
  52. data/spec/controllers/spree/api/feedback_reviews_controller_spec.rb +136 -0
  53. data/spec/controllers/spree/reviews_controller_spec.rb +136 -0
  54. data/spec/models/review_spec.rb +27 -0
  55. data/spec/models/reviews_configuration_spec.rb +12 -0
  56. data/spec/spec_helper.rb +16 -3
  57. metadata +48 -39
  58. data/spec/controllers/spree/products_controller_spec.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d08b28f0274d8513a1b171c01fb30e52ef1c692e7166e9680cb62d19731605b3
4
- data.tar.gz: b091c19c062b9dd3cd98c9726b9aab52371817e901a87e15e812349b9ca1a032
3
+ metadata.gz: fd38dd224e866160ae90ea04068f08ca4c12d0d32337751ee58676bf8d757a84
4
+ data.tar.gz: d3d3f890af762394201f11aee1fa3c18fd97755b7c31ac200f04df0eafef5923
5
5
  SHA512:
6
- metadata.gz: 6d3044e1fa6a0d03491cef8269730d25be40d1ad3e1ebcd32cf81ce71c8dc520a29d8bd8e6415bc738075c11478461cb4be0eb53007d6adb8e613970d835f5e8
7
- data.tar.gz: a34b5ea8da48129b82c7063fa9806a635f3d92949fae6a0af0b98c58337480db6dc2e7cfe5f61e8cd1077834e14557ddc72d41127f8664b227fcc62b1fd0791a
6
+ metadata.gz: bb4483b6bdfbf36e9153ed347c4b6b0fc19c2fabeb3ef55eb3cc48bea3ce7eb0a185f5ef3bcf0b0ebdb317b45dc071beee7961d4883083e0936aed536c079958
7
+ data.tar.gz: 8a30750194cd8485cf9db0f4920718be0d5f7e71ced59187bba4a8fd43051eca0c5323113c9b3260836e5ef9bcec93fd00458f5e8c08311f889a197eb7150db7
@@ -0,0 +1,5 @@
1
+ bump:
2
+ recurse: false
3
+ file: 'lib/solidus_reviews/version.rb'
4
+ message: Bump SolidusReviews to %{version}
5
+ tag: true
@@ -0,0 +1,17 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 60
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: 7
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - pinned
8
+ - security
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: wontfix
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ recent activity. It will be closed if no further activity occurs. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
data/.gitignore CHANGED
@@ -1,13 +1,16 @@
1
1
  *.gem
2
- *.swp
3
- .bundle
4
- .idea
2
+ \#*
3
+ *~
4
+ .#*
5
5
  .DS_Store
6
+ .idea
7
+ .project
8
+ .sass-cache
9
+ coverage
6
10
  Gemfile.lock
7
- pkg/*
11
+ tmp
12
+ nbproject
13
+ pkg
14
+ *.swp
8
15
  spec/dummy
9
- coverage
10
- .rvmrc
11
- .ruby-version
12
- .ruby-gemset
13
16
  spec/examples.txt
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
1
  --color
2
- -f documentation
2
+ --require spec_helper
@@ -1,12 +1,2 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
1
  require:
4
- - solidus_extension_dev_tools/rubocop
5
-
6
- inherit_gem:
7
- solidus_extension_dev_tools: .rubocop.extension.yml
8
-
9
- AllCops:
10
- Exclude:
11
- - spec/dummy/**/*
12
- - vendor/**/*
2
+ - solidus_dev_support/rubocop
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.4.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.4.0) (2020-08-06)
4
+
5
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.3.0...v1.4.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - Cannot select star rating when creating or editing a review [\#88](https://github.com/solidusio-contrib/solidus_reviews/issues/88)
10
+ - uninitialized constant SolidusReviews::Spree::Admin \(NameError\) [\#77](https://github.com/solidusio-contrib/solidus_reviews/issues/77)
11
+ - Dependabot can't resolve your Ruby dependency files [\#75](https://github.com/solidusio-contrib/solidus_reviews/issues/75)
12
+ - Dependabot can't resolve your Ruby dependency files [\#74](https://github.com/solidusio-contrib/solidus_reviews/issues/74)
13
+ - Dependabot can't resolve your Ruby dependency files [\#73](https://github.com/solidusio-contrib/solidus_reviews/issues/73)
14
+ - Dependabot can't resolve your Ruby dependency files [\#71](https://github.com/solidusio-contrib/solidus_reviews/issues/71)
15
+ - Dependabot can't resolve your Ruby dependency files [\#70](https://github.com/solidusio-contrib/solidus_reviews/issues/70)
16
+ - Dependabot can't resolve your Ruby dependency files [\#69](https://github.com/solidusio-contrib/solidus_reviews/issues/69)
17
+ - Users should be able to upload images as part of their review [\#67](https://github.com/solidusio-contrib/solidus_reviews/issues/67)
18
+
19
+ **Merged pull requests:**
20
+
21
+ - Replace deprected ` SolidusSupport::EngineExtensions::Decorators` with ` SolidusSupport::EngineExtensions` [\#93](https://github.com/solidusio-contrib/solidus_reviews/pull/93) ([marcrohloff](https://github.com/marcrohloff))
22
+ - Allow solidus\_support 0.4 [\#92](https://github.com/solidusio-contrib/solidus_reviews/pull/92) ([mamhoff](https://github.com/mamhoff))
23
+ - Fixes review title [\#91](https://github.com/solidusio-contrib/solidus_reviews/pull/91) ([memotoro](https://github.com/memotoro))
24
+ - remove extraneous .css file [\#90](https://github.com/solidusio-contrib/solidus_reviews/pull/90) ([dhughesbc](https://github.com/dhughesbc))
25
+ - Relax solidus\_support dependency [\#86](https://github.com/solidusio-contrib/solidus_reviews/pull/86) ([kennyadsl](https://github.com/kennyadsl))
26
+ - Adds PermissionSets classes and checks for Reviews [\#85](https://github.com/solidusio-contrib/solidus_reviews/pull/85) ([memotoro](https://github.com/memotoro))
27
+ - Adds controls for image uploads [\#83](https://github.com/solidusio-contrib/solidus_reviews/pull/83) ([memotoro](https://github.com/memotoro))
28
+ - Add option to auto approve star only reviews [\#82](https://github.com/solidusio-contrib/solidus_reviews/pull/82) ([KaemonIsland](https://github.com/KaemonIsland))
29
+ - Add touch to feedback review model [\#81](https://github.com/solidusio-contrib/solidus_reviews/pull/81) ([KaemonIsland](https://github.com/KaemonIsland))
30
+ - Add feedback reviews to api [\#79](https://github.com/solidusio-contrib/solidus_reviews/pull/79) ([KaemonIsland](https://github.com/KaemonIsland))
31
+ - Fix path for Spree::ProductsControllerDecorator [\#78](https://github.com/solidusio-contrib/solidus_reviews/pull/78) ([aldesantis](https://github.com/aldesantis))
32
+ - Add edit and update methods to reviews controller [\#76](https://github.com/solidusio-contrib/solidus_reviews/pull/76) ([KaemonIsland](https://github.com/KaemonIsland))
33
+ - Update to solidus\_dev\_support [\#72](https://github.com/solidusio-contrib/solidus_reviews/pull/72) ([aldesantis](https://github.com/aldesantis))
34
+
3
35
  ## [v1.3.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.3.0) (2019-11-27)
4
36
 
5
37
  [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.2.0...v1.3.0)
data/Gemfile CHANGED
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
4
5
 
5
6
  branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
6
- gem 'solidus', git: 'https://github.com/solidusio/solidus.git', branch: branch
7
- gem 'solidus_auth_devise'
7
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
8
8
 
9
9
  # Needed to help Bundler figure out how to resolve dependencies,
10
- # otherwise it takes forever to resolve them
11
- if branch == 'master' || Gem::Version.new(branch[1..-1]) >= Gem::Version.new('2.10.0')
12
- gem 'rails', '~> 6.0'
13
- else
14
- gem 'rails', '~> 5.0'
15
- end
10
+ # otherwise it takes forever to resolve them.
11
+ # See https://github.com/bundler/bundler/issues/6677
12
+ gem 'rails', '>0.a'
13
+
14
+ # Provides basic authentication functionality for testing parts of your engine
15
+ gem 'solidus_auth_devise'
16
16
 
17
17
  case ENV['DB']
18
18
  when 'mysql'
@@ -23,10 +23,6 @@ else
23
23
  gem 'sqlite3'
24
24
  end
25
25
 
26
- group :test do
27
- gem 'rails-controller-testing'
28
- end
29
-
30
- gem 'solidus_extension_dev_tools', github: 'solidusio-contrib/solidus_extension_dev_tools'
26
+ gem 'rails-controller-testing', group: :test
31
27
 
32
28
  gemspec
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2019 Solidus and contributors.
1
+ Copyright (c) 2020 Solidus and contributors
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification,
data/Rakefile CHANGED
@@ -1,23 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler'
4
- Bundler::GemHelper.install_tasks
5
-
6
- require 'rspec/core/rake_task'
7
- require 'spree/testing_support/extension_rake'
3
+ require 'solidus_dev_support/rake_tasks'
4
+ SolidusDevSupport::RakeTasks.install
8
5
 
9
- RSpec::Core::RakeTask.new
6
+ task default: %w[extension:test_app extension:specs]
10
7
 
11
- task :default do
12
- if Dir["spec/dummy"].empty?
13
- Rake::Task[:test_app].invoke
14
- Dir.chdir("../../")
15
- end
16
- Rake::Task[:spec].invoke
17
- end
18
-
19
- desc 'Generates a dummy app for testing'
20
- task :test_app do
21
- ENV['LIB_NAME'] = 'solidus_reviews'
22
- Rake::Task['extension:test_app'].invoke
23
- end
8
+ Bundler::GemHelper.install_tasks
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Spree::ReviewsController < Spree::StoreController
4
4
  helper Spree::BaseHelper
5
- before_action :load_product, only: [:index, :new, :create]
5
+ before_action :load_product, only: [:index, :new, :create, :edit, :update]
6
6
 
7
7
  def index
8
8
  @approved_reviews = Spree::Review.approved.where(product: @product)
@@ -13,9 +13,17 @@ class Spree::ReviewsController < Spree::StoreController
13
13
  authorize! :create, @review
14
14
  end
15
15
 
16
+ def edit
17
+ @review = Spree::Review.find(params[:id])
18
+ if @review.product.nil?
19
+ flash[:error] = I18n.t('spree.error_no_product')
20
+ end
21
+ authorize! :update, @review
22
+ end
23
+
16
24
  # save if all ok
17
25
  def create
18
- params[:review][:rating].sub!(/\s*[^0-9]*\z/, '') if params[:review][:rating].present?
26
+ review_params[:rating].sub!(/\s*[^0-9]*\z/, '') if review_params[:rating].present?
19
27
 
20
28
  @review = Spree::Review.new(review_params)
21
29
  @review.product = @product
@@ -36,6 +44,25 @@ class Spree::ReviewsController < Spree::StoreController
36
44
  end
37
45
  end
38
46
 
47
+ def update
48
+ review_params[:rating].sub!(/\s*[^0-9]*\z/, '') if params[:review][:rating].present?
49
+
50
+ @review = Spree::Review.find(params[:id])
51
+
52
+ # Handle images
53
+ params[:review][:images]&.each do |image|
54
+ @review.images.new(attachment: image)
55
+ end
56
+
57
+ authorize! :update, @review
58
+ if @review.update(review_params)
59
+ flash[:notice] = I18n.t('spree.review_successfully_submitted')
60
+ redirect_to spree.product_path(@product)
61
+ else
62
+ render :edit
63
+ end
64
+ end
65
+
39
66
  private
40
67
 
41
68
  def load_product
@@ -7,10 +7,6 @@ module SolidusReviews
7
7
  base.class_eval do
8
8
  helper ::Spree::ReviewsHelper
9
9
  end
10
-
11
- [:avg_rating, :reviews_count].each do |attribute|
12
- ::Spree::PermittedAttributes.product_attributes << attribute
13
- end
14
10
  end
15
11
 
16
12
  ::Spree::ProductsController.prepend self
@@ -3,7 +3,7 @@
3
3
  class Spree::FeedbackReview < ApplicationRecord
4
4
  belongs_to :user, class_name: Spree.user_class.to_s, optional: true
5
5
 
6
- belongs_to :review, dependent: :destroy
6
+ belongs_to :review, touch: true
7
7
  validates :review, presence: true
8
8
 
9
9
  validates :rating, numericality: { only_integer: true,
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module PermissionSets
5
+ class ReviewDisplay < PermissionSets::Base
6
+ def activate!
7
+ can [:display, :admin], Spree::Review
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module PermissionSets
5
+ class ReviewManagement < PermissionSets::Base
6
+ def activate!
7
+ can :manage, Spree::Review
8
+ end
9
+ end
10
+ end
11
+ end
@@ -3,11 +3,12 @@
3
3
  class Spree::Review < ApplicationRecord
4
4
  belongs_to :product, touch: true, optional: true
5
5
  belongs_to :user, class_name: Spree.user_class.to_s, optional: true
6
- has_many :feedback_reviews
6
+ has_many :feedback_reviews, dependent: :destroy
7
7
  has_many :images, -> { order(:position) }, as: :viewable,
8
8
  dependent: :destroy, class_name: "Spree::Image"
9
9
 
10
- before_create :verify_purchaser
10
+ before_save :verify_purchaser
11
+ before_save :approve_review, unless: :approved?
11
12
  after_save :recalculate_product_rating, if: :approved?
12
13
  after_destroy :recalculate_product_rating
13
14
 
@@ -52,4 +53,17 @@ class Spree::Review < ApplicationRecord
52
53
 
53
54
  self.verified_purchaser = verified_purchase
54
55
  end
56
+
57
+ def star_only?
58
+ [title, review].all?(&:blank?) && rating.present?
59
+ end
60
+
61
+ def approve_review
62
+ # Checks if we should auto approve the review.
63
+ if Spree::Reviews::Config[:approve_star_only]
64
+ self.approved = true if star_only?
65
+ elsif Spree::Reviews::Config[:approve_star_only_for_verified_purchaser]
66
+ self.approved = true if star_only? && verified_purchaser?
67
+ end
68
+ end
55
69
  end
@@ -14,6 +14,11 @@ class Spree::ReviewsAbility
14
14
  review_ability_class.allow_anonymous_reviews? || user.email.present?
15
15
  end
16
16
 
17
+ # You can only change your own feedback_review
18
+ can [:update, :destroy], Spree::FeedbackReview do |feedback_review|
19
+ feedback_review.user == user
20
+ end
21
+
17
22
  # You can read your own reviews, and everyone can read approved ones
18
23
  can :read, Spree::Review do |review|
19
24
  review.user == user || review.approved?
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Spree::ReviewsConfiguration < Spree::Preferences::Configuration
4
4
  def self.boolean_preferences
5
- %w(display_unapproved_reviews include_unapproved_reviews feedback_rating show_email require_login track_locale)
5
+ %w(display_unapproved_reviews include_unapproved_reviews feedback_rating show_email require_login track_locale allow_image_upload)
6
6
  end
7
7
 
8
8
  # include non-approved reviews in (public) listings
@@ -31,4 +31,13 @@ class Spree::ReviewsConfiguration < Spree::Preferences::Configuration
31
31
 
32
32
  # render checkbox for a user to approve to show their identifier (name or email) on their review
33
33
  preference :render_show_identifier_checkbox, :boolean, default: false
34
+
35
+ # Approves star only reviews automatically (Reviews without a Title/Review)
36
+ preference :approve_star_only, :boolean, default: false
37
+
38
+ # Approves star only reviews for verified purchasers only.
39
+ preference :approve_star_only_for_verified_purchaser, :boolean, default: false
40
+
41
+ # allow customer to update image with the review
42
+ preference :allow_image_upload, :boolean, default: true
34
43
  end
@@ -6,7 +6,15 @@ Spree::Backend::Config.configure do |config|
6
6
  }.sections << :reviews
7
7
  end
8
8
 
9
- Deface::Override.new(virtual_path: "spree/admin/shared/_product_sub_menu",
10
- name: "reviews_admin_tab",
11
- insert_bottom: "[data-hook='admin_product_sub_tabs']",
12
- text: "<%= tab(:reviews, label: 'review_management') %>")
9
+ Deface::Override.new(
10
+ virtual_path: "spree/admin/shared/_product_sub_menu",
11
+ name: "reviews_admin_tab",
12
+ insert_bottom: "[data-hook='admin_product_sub_tabs']",
13
+ disabled: false
14
+ ) do
15
+ <<-HTML
16
+ <% if can? :admin, Spree::Review %>
17
+ <%= tab(:reviews, label: 'review_management') %>
18
+ <% end %>
19
+ HTML
20
+ end
@@ -6,8 +6,15 @@ Spree::Backend::Config.configure do |config|
6
6
  }.sections << :review_settings
7
7
  end
8
8
 
9
- Deface::Override.new(virtual_path: "spree/admin/shared/_settings_sub_menu",
10
- name: "converted_admin_configurations_menu",
11
- insert_bottom: "[data-hook='admin_settings_sub_tabs']",
12
- text: "<%= tab :reviews, url: spree.edit_admin_review_settings_path, match_path: /review_settings/ %>",
13
- disabled: false)
9
+ Deface::Override.new(
10
+ virtual_path: "spree/admin/shared/_settings_sub_menu",
11
+ name: "converted_admin_configurations_menu",
12
+ insert_bottom: "[data-hook='admin_settings_sub_tabs']",
13
+ disabled: false
14
+ ) do
15
+ <<-HTML
16
+ <% if can? :admin, Spree::ReviewsConfiguration %>
17
+ <%= tab :reviews, url: spree.edit_admin_review_settings_path, match_path: /review_settings/ %>
18
+ <% end %>
19
+ HTML
20
+ end
@@ -56,6 +56,13 @@
56
56
  <%= I18n.t("spree.spree_reviews.track_locale") %>
57
57
  </label>
58
58
  </div>
59
+ <div class="field">
60
+ <label>
61
+ <%= check_box_tag('preferences[allow_image_upload]', "1", Spree::Reviews::Config[:allow_image_upload]) %>
62
+ <%= I18n.t("spree.spree_reviews.allow_image_upload") %>
63
+ </label>
64
+ </div>
65
+
59
66
  <div class="field">
60
67
  <label><%= I18n.t("spree.spree_reviews.preview_size") %></label><br>
61
68
  <%= text_field_tag('preferences[preview_size]', Spree::Reviews::Config[:preview_size], size: 3) %>
@@ -1,5 +1,5 @@
1
1
  <% content_for :page_title do %>
2
- <%= I18n.t("spree.editing_review_for_html", link: link_to(@review.product.name, product_path(@review.product))) %>
2
+ <%= I18n.t("spree.editing_review_for_html", product_name: @review.product.name) %>
3
3
  <% end %>
4
4
 
5
5
  <% render 'spree/admin/shared/product_sub_menu' %>
@@ -21,6 +21,8 @@
21
21
  <div class="clear"></div>
22
22
 
23
23
  <fieldset class="no-border-top">
24
- <%= render 'spree/admin/shared/edit_resource_links' %>
24
+ <% if can? :manage, Spree::Review %>
25
+ <%= render 'spree/admin/shared/edit_resource_links' %>
26
+ <% end %>
25
27
  </fieldset>
26
28
  <% end %>
@@ -5,7 +5,9 @@
5
5
  <% end %>
6
6
 
7
7
  <% content_for :table_filter_title do %>
8
- <%= I18n.t("spree.search") %>
8
+ <% if can? :display, Spree::Review %>
9
+ <%= I18n.t("spree.search") %>
10
+ <% end %>
9
11
  <% end %>
10
12
 
11
13
  <% content_for :table_filter do %>
@@ -94,7 +96,7 @@
94
96
  <% end %>
95
97
  </td>
96
98
  <td class="align-center">
97
- <%= review.user_id ? link_to(review.user.try(:email), [:admin, review.user]) : I18n.t("spree.anonymous") %></p>
99
+ <p><%= review.user_id ? link_to(review.user.try(:email), [:admin, review.user]) : I18n.t("spree.anonymous") %></p>
98
100
  <p><%= Spree::Review.human_attribute_name(:ip_address) %>: <%= review.ip_address ? link_to(review.ip_address, "http://whois.domaintools.com/#{review.ip_address}") : '-' %></p>
99
101
  </td>
100
102
  <td class="align-center">
@@ -106,9 +108,11 @@
106
108
  <% end %>
107
109
  </td>
108
110
  <td class="actions">
109
- <%= link_to_with_icon 'ok', I18n.t("spree.approve"), approve_admin_review_url(review), no_text: true, class: 'approve' unless review.approved %>
110
- <%= link_to_edit review, no_text: true, class: 'edit' %>
111
- <%= link_to_delete review, no_text: true %>
111
+ <% if can? :manage, Spree::Review %>
112
+ <%= link_to_with_icon 'ok', I18n.t("spree.approve"), approve_admin_review_url(review), no_text: true, class: 'approve' unless review.approved %>
113
+ <%= link_to_edit review, no_text: true, class: 'edit' %>
114
+ <%= link_to_delete review, no_text: true %>
115
+ <% end %>
112
116
  </td>
113
117
  </tr>
114
118
  <% end %>