Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spree-4-5-0-only-backend #203

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions app/controllers/spree/admin/reviews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ def index
end

def approve

review = Spree::Review.find(params[:id])
if review.update_attribute(:approved, true)
flash[:notice] = Spree.t(:info_approve_review)
else
flash[:error] = Spree.t(:error_approve_review)
end

ActiveRecord::Base.connected_to(role: :writing) do

if review.update_attribute(:approved, true)
flash[:notice] = Spree.t(:info_approve_review)
else
flash[:error] = Spree.t(:error_approve_review)
end

redirect_to admin_reviews_path

end
end

def edit
Expand Down
2 changes: 1 addition & 1 deletion app/views/spree/admin/reviews/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= render 'spree/shared/error_messages', target: @review %>
<%= render 'spree/admin/shared/error_messages', target: @review %>

<div class="form-group">
<%= f.label :name %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/spree/admin/reviews/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% content_for :page_title do %>
<%= Spree.t(:editing_review_for_html, link: link_to(@review.product.name, product_path(@review.product))) %>
<%= Spree.t(:editing_review_for_html, link: link_to(@review.product.name, edit_admin_product_path(@review.product))) %>
<% end %>

<%= form_for [:admin, @review] do |f| %>
Expand Down
15 changes: 12 additions & 3 deletions app/views/spree/admin/reviews/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
<table class="table" id="listing_reviews">
<thead>
<tr>
<th><%= sort_link @search, :product, Spree.t(:product) %></th>
<th><%= sort_link @search, :rating, Spree::Review.human_attribute_name(:rating) %></th>
<th colspan= '2'><%= sort_link @search, :product, Spree.t(:product) %></th>
<th ><%= sort_link @search, :rating, Spree::Review.human_attribute_name(:rating) %></th>
<th><%= Spree.t(:feedback) %></th>
<th><%= sort_link @search, :user, Spree::Review.human_attribute_name(:user) %></th>
<th><%= sort_link @search, :ip_address, Spree::Review.human_attribute_name(:ip_address) %></th>
Expand All @@ -67,7 +67,16 @@
<tbody>
<% @reviews.each do |review| %>
<tr data-hook="admin_reviews_index_rows" id="<%= dom_id review %>" class="<%= cycle('odd', 'even') %>">
<td><%= link_to_if review.product, review.product.name, product_path(review.product) %></td>
<td scope="row" class="image">
<%= link_to edit_admin_product_path(review.product) do %>
<%= small_image review.product %>
<% end %>
</td>
<td >
<%= link_to review.product.name, edit_admin_product_path(review.product) %>
<br />
<small><%= review.product.sku rescue '' %></small>
</td>
<td><%= txt_stars(review.rating) %></td>
<td><%= link_to "(#{review.feedback_stars}/#{review.feedback_reviews.size})", admin_review_feedback_reviews_path(review) %></td>
<td><%= review.user_id ? link_to(review.user.try(:email), admin_user_path(review.user)) : Spree.t(:anonymous) %></td>
Expand Down
1 change: 0 additions & 1 deletion spree_reviews.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Gem::Specification.new do |s|
s.add_dependency 'deface', '~> 1.0'
s.add_dependency 'spree_api', spree_version
s.add_dependency 'spree_backend', spree_version
s.add_dependency 'spree_frontend', spree_version
s.add_dependency 'spree_core', spree_version
s.add_dependency 'spree_extension'

Expand Down