Skip to content
Browse files

able to inactivate variants

  • Loading branch information...
1 parent dbf08df commit 225c09e89e38dad3b22db02c5f53bf732fcb4a9c @drhenner committed May 25, 2012
Showing with 12 additions and 1 deletion.
  1. +9 −0 app/models/variant.rb
  2. +3 −1 app/views/admin/merchandise/multi/variants/_form.html.erb
View
9 app/models/variant.rb
@@ -74,6 +74,15 @@ def active?
deleted_at.nil? || deleted_at > Time.zone.now
end
+ # This is a form helper to inactivate a variant
+ def inactivate=(val)
+ self.deleted_at = Time.zone.now if !deleted_at && (val && (val == '1' || val.to_s == 'true'))
+ end
+
+ def inactivate
+ deleted_at ? true : false
+ end
+
# returns true if the stock level is above or == the out of stock level
#
# @param [none]
View
4 app/views/admin/merchandise/multi/variants/_form.html.erb
@@ -60,7 +60,9 @@
</tr><tr>
<td>Brand </td><td> <%= ff.select :brand_id, @brands, { :include_blank => true }, :class => 'span-3' %> </td>
</tr>
-
+ <tr>
+ <td>Inactivate </td><td> <%= ff.check_box :inactivate, :class => 'span-3' %> </td>
+ </tr>
<% @product.properties.each do |property| %>
<tr style='background:#ACF;text-align:center;'> <th colspan=2> <%= property.display_name %> </th> </tr>
<% variant_id = variant.id rescue nil %>

0 comments on commit 225c09e

Please sign in to comment.
Something went wrong with that request. Please try again.