spree_core 1.0.7 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. data/app/assets/javascripts/admin/admin.js.erb +9 -18
  2. data/app/assets/javascripts/admin/calculator.js +7 -6
  3. data/app/assets/javascripts/admin/checkouts/edit.js +2 -2
  4. data/app/assets/javascripts/admin/image_settings.js +49 -0
  5. data/app/assets/javascripts/admin/orders/edit_form.js +14 -14
  6. data/app/assets/stylesheets/admin/admin.css.erb +36 -54
  7. data/app/assets/stylesheets/store/screen.css.scss +25 -12
  8. data/app/controllers/spree/admin/base_controller.rb +3 -3
  9. data/app/controllers/spree/admin/image_settings_controller.rb +71 -0
  10. data/app/controllers/spree/admin/images_controller.rb +22 -21
  11. data/app/controllers/spree/admin/mail_methods_controller.rb +1 -1
  12. data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -2
  13. data/app/controllers/spree/admin/orders_controller.rb +13 -13
  14. data/app/controllers/spree/admin/payment_methods_controller.rb +1 -1
  15. data/app/controllers/spree/admin/payments_controller.rb +1 -1
  16. data/app/controllers/spree/admin/product_properties_controller.rb +3 -4
  17. data/app/controllers/spree/admin/products_controller.rb +49 -47
  18. data/app/controllers/spree/admin/properties_controller.rb +1 -1
  19. data/app/controllers/spree/admin/prototypes_controller.rb +12 -6
  20. data/app/controllers/spree/admin/reports_controller.rb +15 -16
  21. data/app/controllers/spree/admin/resource_controller.rb +1 -1
  22. data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
  23. data/app/controllers/spree/admin/shipments_controller.rb +0 -3
  24. data/app/controllers/spree/admin/states_controller.rb +9 -9
  25. data/app/controllers/spree/admin/users_controller.rb +18 -42
  26. data/app/controllers/spree/admin/variants_controller.rb +22 -21
  27. data/app/controllers/spree/admin/zones_controller.rb +11 -11
  28. data/app/controllers/spree/content_controller.rb +1 -1
  29. data/app/controllers/spree/locale_controller.rb +2 -2
  30. data/app/controllers/spree/orders_controller.rb +4 -6
  31. data/app/controllers/spree/products_controller.rb +1 -1
  32. data/app/controllers/spree/states_controller.rb +4 -7
  33. data/app/helpers/spree/admin/base_helper.rb +4 -0
  34. data/app/helpers/spree/admin/navigation_helper.rb +4 -16
  35. data/app/helpers/spree/base_helper.rb +22 -3
  36. data/app/models/spree/activator.rb +4 -1
  37. data/app/models/spree/address.rb +45 -45
  38. data/app/models/spree/adjustment.rb +4 -4
  39. data/app/models/spree/app_configuration.rb +12 -0
  40. data/app/models/spree/calculator/default_tax.rb +1 -3
  41. data/app/models/spree/calculator/flat_percent_item_total.rb +0 -2
  42. data/app/models/spree/calculator/flat_rate.rb +0 -3
  43. data/app/models/spree/calculator/flexi_rate.rb +1 -3
  44. data/app/models/spree/calculator/per_item.rb +1 -6
  45. data/app/models/spree/calculator/price_sack.rb +0 -2
  46. data/app/models/spree/country.rb +1 -1
  47. data/app/models/spree/creditcard.rb +9 -10
  48. data/app/models/spree/gateway.rb +0 -2
  49. data/app/models/spree/image.rb +18 -2
  50. data/app/models/spree/inventory_unit.rb +4 -2
  51. data/app/models/spree/mail_method.rb +1 -6
  52. data/app/models/spree/option_type.rb +3 -1
  53. data/app/models/spree/order.rb +68 -62
  54. data/app/models/spree/payment.rb +1 -1
  55. data/app/models/spree/payment_method.rb +0 -6
  56. data/app/models/spree/product/scopes.rb +44 -44
  57. data/app/models/spree/product.rb +44 -26
  58. data/app/models/spree/product_property.rb +0 -2
  59. data/app/models/spree/property.rb +0 -16
  60. data/app/models/spree/prototype.rb +0 -1
  61. data/app/models/spree/return_authorization.rb +0 -2
  62. data/app/models/spree/shipment.rb +2 -3
  63. data/app/models/spree/shipping_category.rb +0 -2
  64. data/app/models/spree/shipping_method.rb +1 -2
  65. data/app/models/spree/shipping_rate.rb +9 -0
  66. data/app/models/spree/state.rb +10 -2
  67. data/app/models/spree/{state_event.rb → state_change.rb} +1 -4
  68. data/app/models/spree/tax_rate.rb +3 -3
  69. data/app/models/spree/taxon.rb +1 -6
  70. data/app/models/spree/taxonomy.rb +3 -6
  71. data/app/models/spree/user.rb +1 -0
  72. data/app/models/spree/variant.rb +3 -4
  73. data/app/models/spree/zone.rb +0 -10
  74. data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +1 -1
  75. data/app/views/spree/admin/configurations/index.html.erb +4 -0
  76. data/app/views/spree/admin/image_settings/edit.html.erb +91 -0
  77. data/app/views/spree/admin/image_settings/show.html.erb +11 -0
  78. data/app/views/spree/admin/images/index.html.erb +3 -3
  79. data/app/views/spree/admin/mail_methods/_form.html.erb +1 -1
  80. data/app/views/spree/admin/mail_methods/index.html.erb +1 -1
  81. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +1 -1
  82. data/app/views/spree/admin/option_types/index.html.erb +1 -1
  83. data/app/views/spree/admin/option_types/new.js.erb +1 -1
  84. data/app/views/spree/admin/orders/_form.html.erb +3 -5
  85. data/app/views/spree/admin/orders/_line_item.html.erb +1 -1
  86. data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
  87. data/app/views/spree/admin/orders/history.html.erb +2 -2
  88. data/app/views/spree/admin/orders/index.html.erb +19 -19
  89. data/app/views/spree/admin/payment_methods/_form.html.erb +1 -1
  90. data/app/views/spree/admin/payment_methods/index.html.erb +1 -3
  91. data/app/views/spree/admin/payments/_list.html.erb +1 -1
  92. data/app/views/spree/admin/product_properties/index.html.erb +1 -1
  93. data/app/views/spree/admin/products/_form.html.erb +30 -27
  94. data/app/views/spree/admin/products/index.html.erb +9 -9
  95. data/app/views/spree/admin/products/new.html.erb +28 -4
  96. data/app/views/spree/admin/products/new.js.erb +1 -1
  97. data/app/views/spree/admin/properties/index.html.erb +1 -1
  98. data/app/views/spree/admin/properties/new.js.erb +1 -1
  99. data/app/views/spree/admin/prototypes/index.html.erb +1 -1
  100. data/app/views/spree/admin/prototypes/new.js.erb +1 -1
  101. data/app/views/spree/admin/prototypes/show.html.erb +42 -0
  102. data/app/views/spree/admin/return_authorizations/index.html.erb +1 -1
  103. data/app/views/spree/admin/shared/_address_form.html.erb +1 -1
  104. data/app/views/spree/admin/shared/_calculator_fields.html.erb +2 -2
  105. data/app/views/spree/admin/shared/_head.html.erb +3 -3
  106. data/app/views/spree/admin/shared/_order_details.html.erb +1 -1
  107. data/app/views/spree/admin/shared/_order_tabs.html.erb +6 -6
  108. data/app/views/spree/admin/shared/_product_sub_menu.html.erb +0 -1
  109. data/app/views/spree/admin/shared/_report_criteria.html.erb +3 -3
  110. data/app/views/spree/admin/shared/_tabs.html.erb +1 -1
  111. data/app/views/spree/admin/shared/_update_order_state.js +5 -4
  112. data/app/views/spree/admin/shipments/index.html.erb +1 -1
  113. data/app/views/spree/admin/shipping_categories/index.html.erb +1 -1
  114. data/app/views/spree/admin/shipping_methods/index.html.erb +1 -1
  115. data/app/views/spree/admin/states/_state_list.html.erb +1 -1
  116. data/app/views/spree/admin/states/new.js.erb +1 -1
  117. data/app/views/spree/admin/tax_categories/index.html.erb +2 -2
  118. data/app/views/spree/admin/tax_rates/index.html.erb +2 -2
  119. data/app/views/spree/admin/taxonomies/_list.html.erb +1 -1
  120. data/app/views/spree/admin/trackers/_form.html.erb +1 -1
  121. data/app/views/spree/admin/trackers/index.html.erb +1 -1
  122. data/app/views/spree/admin/users/_form.html.erb +1 -16
  123. data/app/views/spree/admin/users/index.html.erb +3 -4
  124. data/app/views/spree/admin/variants/index.html.erb +2 -2
  125. data/app/views/spree/admin/variants/new.js.erb +1 -1
  126. data/app/views/spree/admin/zones/index.html.erb +1 -1
  127. data/app/views/spree/checkout/_address.html.erb +1 -1
  128. data/app/views/spree/checkout/edit.html.erb +1 -1
  129. data/app/views/spree/checkout/registration.html.erb +2 -2
  130. data/app/views/spree/order_mailer/confirm_email.text.erb +3 -3
  131. data/app/views/spree/orders/show.html.erb +2 -2
  132. data/app/views/spree/products/_cart_form.html.erb +1 -2
  133. data/app/views/spree/products/_image.html.erb +1 -1
  134. data/app/views/spree/products/show.html.erb +3 -3
  135. data/app/views/spree/shared/_filters.html.erb +26 -24
  136. data/app/views/spree/shared/_google_analytics.html.erb +26 -26
  137. data/app/views/spree/shared/_products.html.erb +2 -2
  138. data/app/views/spree/shared/_search.html.erb +1 -1
  139. data/app/views/spree/shared/_store_menu.html.erb +1 -1
  140. data/app/views/spree/states/index.js.erb +1 -1
  141. data/config/initializers/rails_3_1.rb +3 -3
  142. data/config/locales/en.yml +40 -35
  143. data/config/routes.rb +5 -13
  144. data/db/migrate/20101026184714_migrate_transactions_to_payment_state.rb +4 -4
  145. data/db/migrate/20111007143030_namespace_top_level_models.rb +0 -3
  146. data/db/migrate/20120203001428_rename_state_events_to_state_changes.rb +9 -0
  147. data/db/migrate/20120315064358_migrate_images_from_products_to_variants.rb +35 -0
  148. data/lib/generators/spree/dummy/templates/rails/database.yml +48 -20
  149. data/lib/generators/spree/install/install_generator.rb +17 -1
  150. data/lib/generators/spree/install/templates/app/assets/javascripts/admin/all.js +0 -1
  151. data/lib/generators/spree/install/templates/app/assets/javascripts/store/all.js +0 -1
  152. data/lib/generators/spree/install/templates/app/assets/stylesheets/admin/all.css +0 -1
  153. data/lib/generators/spree/install/templates/app/assets/stylesheets/store/all.css +0 -1
  154. data/lib/generators/spree/sandbox/sandbox_generator.rb +9 -2
  155. data/lib/spree/core/calculated_adjustments.rb +29 -34
  156. data/lib/spree/core/controller_helpers.rb +36 -34
  157. data/lib/spree/core/custom_fixtures.rb +1 -1
  158. data/lib/spree/core/delegate_belongs_to.rb +22 -24
  159. data/lib/spree/core/engine.rb +3 -3
  160. data/lib/spree/core/environment_extension.rb +12 -15
  161. data/lib/spree/core/mail_settings.rb +1 -1
  162. data/lib/spree/core/permalinks.rb +24 -16
  163. data/lib/spree/core/preference_rescue.rb +1 -1
  164. data/lib/spree/core/respond_with.rb +13 -8
  165. data/lib/spree/core/responder.rb +1 -2
  166. data/lib/spree/core/search/base.rb +36 -19
  167. data/lib/spree/core/ssl_requirement.rb +18 -10
  168. data/lib/spree/core/testing_support/common_rake.rb +1 -1
  169. data/lib/spree/core/testing_support/factories/product_factory.rb +9 -9
  170. data/lib/spree/core/testing_support/factories/role_factory.rb +1 -1
  171. data/lib/spree/core/testing_support/factories/shipping_category_factory.rb +1 -1
  172. data/lib/spree/core/testing_support/factories/shipping_method_factory.rb +3 -3
  173. data/lib/spree/core/testing_support/factories/user_factory.rb +1 -1
  174. data/lib/spree/core/testing_support/factories/zone_factory.rb +4 -2
  175. data/lib/spree/core/validators/email.rb +23 -0
  176. data/lib/spree/core/version.rb +1 -1
  177. data/lib/spree/core.rb +2 -2
  178. data/lib/spree/product_filters.rb +10 -19
  179. data/lib/tasks/core.rake +1 -1
  180. data/vendor/assets/javascripts/jquery.alerts/jquery.alerts.css.erb +5 -5
  181. data/vendor/assets/stylesheets/jquery-ui.datepicker.css.erb +1 -1
  182. metadata +68 -140
  183. data/app/assets/images/noimage/large.png +0 -0
  184. data/app/controllers/spree/admin/product_groups_controller.rb +0 -49
  185. data/app/controllers/spree/admin/product_scopes_controller.rb +0 -39
  186. data/app/helpers/spree/admin/product_groups_helper.rb +0 -14
  187. data/app/helpers/spree/admin/product_properties_helper.rb +0 -24
  188. data/app/models/spree/product_group.rb +0 -200
  189. data/app/models/spree/product_scope.rb +0 -79
  190. data/app/views/spree/admin/banners/_gateway.html.erb +0 -14
  191. data/app/views/spree/admin/product_groups/_preview.html.erb +0 -33
  192. data/app/views/spree/admin/product_groups/_product_scope.html.erb +0 -24
  193. data/app/views/spree/admin/product_groups/edit.html.erb +0 -59
  194. data/app/views/spree/admin/product_groups/index.html.erb +0 -37
  195. data/app/views/spree/admin/product_groups/new.html.erb +0 -12
  196. data/app/views/spree/admin/product_groups/show.html.erb +0 -32
  197. data/app/views/spree/admin/product_scopes/create.js.erb +0 -6
  198. data/app/views/spree/admin/product_scopes/destroy.js.erb +0 -3
  199. data/app/views/spree/admin/product_scopes/new.html.erb +0 -1
  200. data/app/views/spree/admin/shared/_group_from_products_form.html.erb +0 -12
  201. data/db/migrate/20091012120519_product_groups_and_scopes.rb +0 -18
  202. data/db/migrate/20100126103714_create_products_product_groups.rb +0 -8
  203. data/db/migrate/20100306153445_fix_by_popularity.rb +0 -9
  204. data/db/migrate/20120523061241_convert_sales_tax_to_default_tax.rb +0 -9
  205. data/lib/spree/core/testing_support/factories/product_group_factory.rb +0 -5
  206. data/lib/spree/core/testing_support/factories/product_scope_factory.rb +0 -7
  207. data/lib/spree/core/theme_support/hook_listener.rb +0 -145
  208. data/lib/spree/core/theme_support.rb +0 -1
  209. data/vendor/assets/javascripts/jquery.alerts/jquery.alerts.css +0 -57
@@ -1,200 +0,0 @@
1
- # *ProductGroups* are used for creating and managing sets of products.
2
- # Product group can be either anonymous(adhoc) or named.
3
- #
4
- # Anonymous Product groups are created by combining product scopes generated from url
5
- # in 2 formats:
6
- #
7
- # /t/*taxons/s/name_of_scope/comma_separated_arguments/name_of_scope_that_doesn_take_any//order
8
- # */s/name_of_scope/comma_separated_arguments/name_of_scope_that_doesn_take_any//order
9
- #
10
- # Named product groups can be created from anonymous ones, lub from another named scope
11
- # (using ProductGroup.from_url method).
12
- # Named product groups have pernament urls, that don't change even after changes
13
- # to scopes are made, and come in two types.
14
- #
15
- # /t/*taxons/pg/named_product_group
16
- # */pg/named_product_group
17
- #
18
- # first one is used for combining named scope with taxons, named product group can
19
- # have #in_taxon or #taxons_name_eq scope defined, result should combine both
20
- # and return products that exist in both taxons.
21
- #
22
- # ProductGroup#dynamic_products returns chain of named scopes generated from order and
23
- # product scopes. So you can do counting, calculations etc, on resulted set of products,
24
- # without retriving all records.
25
- #
26
- # ProductGroup operates on named scopes defined for product in Scopes::Product,
27
- # or generated automatically by meta_search
28
- #
29
- module Spree
30
- class ProductGroup < ActiveRecord::Base
31
- validates :name, :permalink, :presence => true
32
- validates_associated :product_scopes
33
-
34
- after_save :update_memberships
35
-
36
- has_and_belongs_to_many :cached_products, :class_name => 'Spree::Product',
37
- :join_table => 'spree_product_groups_products'
38
- has_many :product_scopes
39
- accepts_nested_attributes_for :product_scopes
40
-
41
- make_permalink
42
-
43
- # Testing utility: creates new *ProductGroup* from search permalink url.
44
- # Follows conventions for accessing PGs from URLs, as decoded in routes
45
- def self.from_url(url)
46
- pg = nil;
47
- case url
48
- when /\/t\/(.+?)\/s\/(.+)/ then taxons = $1; attrs = $2;
49
- when /\/t\/(.+?)\/pg\/(.+)/ then taxons = $1; pg_name = $2;
50
- when /(.*?)\/s\/(.+)/ then attrs = $2;
51
- when /(.*?)\/pg\/(.+)/ then pg_name = $2;
52
- else return(nil)
53
- end
54
-
55
- if pg_name && opg = ProductGroup.find_by_permalink(pg_name)
56
- pg = new.from_product_group(opg)
57
- elsif attrs
58
- attrs = url.split('/')
59
- pg = new.from_route(attrs)
60
- end
61
- taxon = taxons && taxons.split('/').last
62
- pg.add_scope('in_taxon', taxon) if taxon
63
-
64
- pg
65
- end
66
-
67
- def from_product_group(opg)
68
- self.product_scopes = opg.product_scopes.map{|ps|
69
- ps = ps.clone;
70
- ps.product_group_id = nil;
71
- ps.product_group = self;
72
- ps
73
- }
74
- self
75
- end
76
-
77
- def from_route(attrs)
78
- self.order_scope = attrs.pop if attrs.length % 2 == 1
79
- attrs.each_slice(2) do |scope|
80
- next unless Product.respond_to?(scope.first)
81
- add_scope(scope.first, scope.last.split(','))
82
- end
83
- self
84
- end
85
-
86
- def from_search(search_hash)
87
- search_hash.each_pair do |scope_name, scope_attribute|
88
- add_scope(scope_name, scope_attribute)
89
- end
90
-
91
- self
92
- end
93
-
94
- def add_scope(scope_name, arguments=[])
95
- if scope_name.to_s !~ /eval|send|system|[^a-z0-9_!?]/
96
- self.product_scopes << ProductScope.new({
97
- :name => scope_name.to_s,
98
- :arguments => [*arguments]
99
- })
100
- else
101
- raise ArgumentError.new("'#{scope_name}` can't be used as scope")
102
- end
103
- self
104
- end
105
-
106
- def apply_on(scopish, use_order = true)
107
- # There's bug in AR, it doesn't merge :order, instead it takes order
108
- # from first nested_scope so we have to apply ordering FIRST.
109
- # see #2253 on rails LH
110
- base_product_scope = scopish
111
- if use_order && !self.order_scope.blank? && Product.respond_to?(self.order_scope.intern)
112
- base_product_scope = base_product_scope.send(self.order_scope)
113
- end
114
-
115
- return self.product_scopes.reject { |s| s.is_ordering? }.inject(base_product_scope) do |result, scope|
116
- scope.apply_on(result)
117
- end
118
-
119
- end
120
-
121
- # returns chain of named scopes generated from order scope and product scopes.
122
- def dynamic_products(use_order = true)
123
- apply_on(Product.group_by_products_id, use_order)
124
- end
125
-
126
- # Does the final ordering if requested
127
- # TODO: move the order stuff out of the above - is superfluous now
128
- def products(use_order = true)
129
- cached_group = Product.in_cached_group(self)
130
- if cached_group.limit(1).blank?
131
- dynamic_products(use_order)
132
- elsif !use_order
133
- cached_group
134
- else
135
- product_scopes.select { |s|
136
- s.is_ordering?
137
- }.inject(cached_group) { |res,order|
138
- order.apply_on(res)
139
- }
140
- end
141
- end
142
-
143
- def include?(product)
144
- res = apply_on(Product.where(:id => product.id), false)
145
- res.count > 0
146
- end
147
-
148
- def scopes_to_hash
149
- result = {}
150
- self.product_scopes.each do |scope|
151
- result[scope.name] = scope.arguments
152
- end
153
- result
154
- end
155
-
156
- def to_param
157
- permalink.present? ? permalink : (permalink_was || name.to_s.to_url)
158
- end
159
-
160
- def update_memberships
161
- # wipe everything directly to avoid expensive in-rails sorting
162
- ActiveRecord::Base.connection.execute "DELETE FROM spree_product_groups_products WHERE product_group_id = #{self.id}"
163
-
164
- # and generate the new group entirely in SQL
165
- ActiveRecord::Base.connection.execute "INSERT INTO spree_product_groups_products #{dynamic_products(false).scoped(:select => "spree_products.id, #{self.id}").to_sql}"
166
- end
167
-
168
- def generate_preview(size = Spree::Config[:admin_pgroup_preview_size])
169
- count = self.class.count_by_sql ["SELECT COUNT(*) FROM spree_product_groups_products WHERE spree_product_groups_products.product_group_id = ?", self]
170
-
171
- return count, products.limit(size)
172
- end
173
-
174
- def to_s
175
- "<Spree::ProductGroup" + (id && "[#{id}]").to_s + ":'#{to_url}'>"
176
- end
177
-
178
-
179
- def order_scope
180
- if scope = product_scopes.detect {|s| s.is_ordering?}
181
- scope.name
182
- end
183
- end
184
-
185
- def order_scope=(scope_name)
186
- if scope = product_scopes.detect {|s| s.is_ordering?}
187
- scope.update_attribute(:name, scope_name)
188
- else
189
- self.product_scopes.build(:name => scope_name, :arguments => [])
190
- end
191
- end
192
-
193
- # Build a new product group with a scope to filter by specified products
194
- def self.new_from_products(products, attrs = {})
195
- pg = new(attrs)
196
- pg.product_scopes.build(:name => 'with_ids', :arguments => [products.map(&:id).join(',')])
197
- pg
198
- end
199
- end
200
- end
@@ -1,79 +0,0 @@
1
- # *Spree::ProductScope* is model for storing named scopes with their arguments,
2
- # to be used with Spree::ProductGroups.
3
- #
4
- # Each product Scope can be applied to Spree::Product (or product scope) with #apply_on method
5
- # which returns new combined named scope
6
- #
7
- module Spree
8
- class ProductScope < ActiveRecord::Base
9
- # name
10
- # arguments
11
- belongs_to :product_group
12
- serialize :arguments
13
-
14
- validate :check_validity_of_scope
15
-
16
- extend ::Spree::Scopes::Dynamic
17
-
18
- # Get all products with this scope
19
- def products
20
- if Product.respond_to?(name)
21
- Product.send(name, *arguments)
22
- end
23
- end
24
-
25
- # Applies product scope on Spree::Product model or another named scope
26
- def apply_on(another_scope)
27
- array = Array.wrap(self.arguments)
28
- if Product.respond_to?(self.name.intern)
29
- relation2 = if (array.blank? || array.size < 2)
30
- if Product.method(self.name.intern).arity == 0
31
- Product.send(self.name.intern)
32
- else
33
- Product.send(self.name.intern, array.try(:first))
34
- end
35
- else
36
- Product.send(self.name.intern, *array)
37
- end
38
- else
39
- relation2 = Product.metasearch({ self.name.intern => array.join("") }).relation
40
- end
41
- unless another_scope.class == ActiveRecord::Relation
42
- another_scope = another_scope.send(:relation)
43
- end
44
- another_scope.merge(relation2)
45
- end
46
-
47
- # checks validity of the named scope (if its safe and can be applied on Spree::Product)
48
- def check_validity_of_scope
49
- errors.add(:name, 'is not a valid scope name') unless Product.respond_to?(self.name.intern)
50
- apply_on(Product).limit(0) != nil
51
- rescue Exception => e
52
- unless Rails.env.production?
53
-
54
- puts "name: #{self.name}"
55
- puts "arguments: #{self.arguments.inspect}"
56
- puts e.message
57
- puts e.backtrace
58
- end
59
- errors.add(:arguments, 'are incorrect')
60
- end
61
-
62
- # test ordering scope by looking for name pattern or missed arguments
63
- def is_ordering?
64
- name =~ /^(ascend_by|descend_by)/ || arguments.blank?
65
- end
66
-
67
- def to_sentence
68
- result = I18n.t(:sentence, :scope => [:product_scopes, :scopes, self.name], :default => '')
69
- result = I18n.t(:name, :scope => [:product_scopes, :scopes, self.name]) if result.blank?
70
- result % [*self.arguments]
71
- end
72
-
73
- def to_s
74
- to_sentence
75
- end
76
- end
77
- end
78
-
79
- require_dependency 'spree/product_scope/scopes'
@@ -1,14 +0,0 @@
1
- <% if !current_user.dismissed_banner?(:gateway) &&
2
- Spree::PaymentMethod.production.where("type != 'Spree::Gateway::Bogus'").empty? %>
3
-
4
- <div class="banner payment_banner">
5
- <p class="message">
6
- <%= t(:payment_processor_choose_banner_text)%>
7
- <%= link_to t(:payment_processor_choose_link), "http://spreecommerce.com/products/payment_processing", :target => '_blank' %>
8
- </p>
9
-
10
- <%= link_to t(:dismiss_banner), dismiss_banner_admin_user_path(current_user, :banner_id => :gateway),
11
- :remote => true, :method => :post, :class => 'dismiss' %>
12
- </div>
13
-
14
- <% end %>
@@ -1,33 +0,0 @@
1
- <% count, preview = @product_group.generate_preview(Spree::Config[:admin_pgroup_preview_size]) %>
2
-
3
- <h2><%= Spree::ProductGroup.human_attribute_name(:products) %> (<%= count %>)</h2>
4
-
5
- <% if count == 0 %>
6
- <p data-hook="preview_empty"><%= t(:no_match_found) %></p>
7
- <% else %>
8
-
9
- <% if count > Spree::Config[:admin_pgroup_preview_size] %>
10
- <p data-hook="preview_showing"><%= t(:showing_first_n, :n => Spree::Config[:admin_pgroup_preview_size]) %></p>
11
- <% end %>
12
-
13
- <table class="index" data-hook="preview">
14
- <thead>
15
- <tr data-hook="preview_header">
16
- <th><%= Spree::Product.human_attribute_name(:name) %></th>
17
- <th><%= t(:action) %></th>
18
- </tr>
19
- </thead>
20
- <tbody>
21
- <% preview.each do |product| %>
22
- <tr data-hook="preview_row">
23
- <td>
24
- <%= link_to product.name, product_url(product) %>
25
- </td>
26
- <td>
27
- <%= link_to t(:edit), edit_admin_product_path(product) %>
28
- </td>
29
- </tr>
30
- <% end %>
31
- </tbody>
32
- </table>
33
- <% end %>
@@ -1,24 +0,0 @@
1
- <tr id="<%= dom_id product_scope %>" data-hook="product_scope">
2
- <td data-hook="description">
3
- <%= label_tag nil, t(:name, :scope => [:product_scopes, :scopes, product_scope.name]) %>
4
- <% if description = t(:description, :scope => [:product_scopes, :scopes, product_scope.name], :default => "") and description.present? %>
5
- <br /><%= description %>
6
- <% end %>
7
- </td>
8
- <td data-hook="arguments">
9
- <% if arguments = Spree::ProductScope.arguments_for_scope_name(product_scope.name.strip) %>
10
- <table><tr>
11
- <% arguments.each_with_index do |argument, i| %>
12
- <td>
13
- <%= label_tag nil, t(argument, :scope => [:product_scopes, :scopes, product_scope.name, :args]) %><br />
14
- <%= hidden_field_tag 'product_group[product_scopes_attributes][][id]', product_scope.id %>
15
- <%= product_scope_field product_scope, i %>
16
- </td>
17
- <% end %>
18
- </tr></table>
19
- <% end %>
20
- </td>
21
- <td class="actions" data-hook="actions">
22
- <%= link_to_with_icon 'cross', '', admin_product_group_product_scope_path(@product_group, product_scope), :remote => true, :method => 'delete' %>
23
- </td>
24
- </tr>
@@ -1,59 +0,0 @@
1
- <%= render :partial => 'spree/admin/shared/product_sub_menu' %>
2
-
3
- <h1><%= t(:editing_product_group) %></h1>
4
-
5
- <fieldset id="product_group_forms_container" data-hook>
6
-
7
- <%= form_for [:admin, @product_group], :html => { :id => 'product-group-form', :method => :put } do |f| %>
8
-
9
- <%= f.field_container :name do %>
10
- <%= f.label :name, t(:name) %><br />
11
- <%= f.text_field :name %>
12
- <%= f.error_message_on :name %>
13
- <% end %>
14
-
15
- <%= f.field_container :permalink do %>
16
- <%= f.label :permalink, t(:permalink) %><br />
17
- <%= f.text_field :permalink %>
18
- <%= f.error_message_on :permalink %>
19
- <% end %>
20
-
21
- <%= f.field_container :order_scope do %>
22
- <%= f.label :order_scope, t(:sort_ordering) %><br />
23
- <%= f.select(:order_scope, Spree::Product.simple_scopes.collect{|p| [ t(:name, :scope =>[:product_scopes, :scopes, p]), p.to_s ] }) %>
24
- <% end %>
25
-
26
- <table id="product_scopes" data-hook>
27
- <%= render :partial => 'product_scope', :collection => @product_group.product_scopes.reject {|s| s.is_ordering? } %>
28
- </table>
29
-
30
- <%= button t(:update) %>
31
-
32
- <% end %>
33
-
34
- <%= form_tag admin_product_group_product_scopes_path(@product_group), :remote => true, :id => 'new_product_group_form' do %>
35
- <%
36
- options =
37
- grouped_options_for_select(
38
- Spree::ProductScope.all_scopes.map do |group_name, scopes|
39
- [
40
- t(:name, :scope => [:product_scopes, :groups, group_name]),
41
- scopes.keys.map do |scope_name|
42
- [ t(:name, :scope => [:product_scopes, :scopes, scope_name]), scope_name]
43
- end
44
- ]
45
- end
46
- )
47
- %>
48
- <p>
49
- <%= label_tag :product_scope_name, t(:add_scope) %>
50
- <%= select_tag 'product_scope[name]', options %>
51
- <%= submit_tag t(:add) %>
52
- </p>
53
- <% end %>
54
-
55
- </fieldset>
56
-
57
- <fieldset id="preview_container" data-hook>
58
- <%= render :partial => 'preview' %>
59
- </fieldset>
@@ -1,37 +0,0 @@
1
- <% render :partial => 'spree/admin/shared/product_sub_menu' %>
2
- <div class="toolbar" data-hook="toolbar">
3
- <ul class="actions">
4
- <li>
5
- <%= button_link_to t(:new_product_group), new_object_url, :icon => 'add', :id => 'new_product_group_link' %>
6
- </li>
7
- </ul>
8
- <br class="clear" />
9
- </div>
10
-
11
- <h1><%= t(:listing_product_groups) %></h1>
12
-
13
- <table class="index" id='listing_product_groups' data-hook>
14
- <thead>
15
- <tr data-hook="product_group_header">
16
- <th><%= Spree::ProductGroup.human_attribute_name(:name) %></th>
17
- <th><%= Spree::ProductGroup.human_attribute_name(:url) %></th>
18
- <th><%= Spree::ProductGroup.human_attribute_name(:product_scopes) %></th>
19
- <th><%= Spree::ProductGroup.human_attribute_name(:product_count) %></th>
20
- <th><%= t(:action) %></th>
21
- </tr>
22
- </thead>
23
- <tbody>
24
- <% @product_groups.each do |pg| %>
25
- <tr id="<%= dom_id pg %>" data-hook="product_group_row">
26
- <td><%= link_to pg.name, [:admin, pg] %></td>
27
- <td><%= link_to pg_search_path(:product_group_name => pg.permalink), pg_search_path(:product_group_name => pg.permalink) %></td>
28
- <td><%== pg.product_scopes.map(&:to_sentence).join('<br />') %></td>
29
- <td><%= pg.products.count %></td>
30
- <td>
31
- <%= link_to_edit pg, :class => 'admin_edit_product_group' %> &nbsp; <%= link_to_delete pg %>
32
- </td>
33
- </tr>
34
- <% end %>
35
- </tbody>
36
- </table>
37
- <%= paginate @product_groups %>
@@ -1,12 +0,0 @@
1
- <%= render :partial => 'spree/admin/shared/product_sub_menu' %>
2
- <%= form_for [:admin, @product_group], :html => { :id => 'product-group-form', :multipart => true } do |f| %>
3
- <fieldset data-hook="name">
4
- <legend><%= t(:product_group) %></legend>
5
- <%= f.field_container :name do %>
6
- <%= f.label :name, t(:name) %>
7
- <%= f.text_field :name %>
8
- <%= f.error_message_on :name %>
9
- <% end %>
10
- </fieldset>
11
- <%= button t(:create) %>
12
- <% end %>
@@ -1,32 +0,0 @@
1
- <% render :partial => 'spree/admin/shared/product_sub_menu' %>
2
- <h2><%= Spree::ProductGroup.model_name.human %></h2>
3
- <p>
4
- <%= Spree::ProductGroup.human_attribute_name(:name) %>: <%= @product_group.name %>
5
- </p>
6
- <p>
7
- <%= Spree::ProductGroup.human_attribute_name(:url) %>: <%= link_to @product_group.permalink, "/pg/#{@product_group.permalink}" %>
8
- </p>
9
-
10
- <h2><%= Spree::ProductGroup.human_attribute_name(:product_scopes) %>(<%= @product_group.product_scopes.count %>)</h2>
11
- <table class="product-scopes" data-hook="product_scopes">
12
- <thead>
13
- <tr data-hook="product_scopes_header">
14
- <th><%= Spree::ProductScope.human_attribute_name(:description) %></th>
15
- <th><%= Spree::ProductScope.human_attribute_name(:arguments) %></th>
16
- </tr>
17
- </thead>
18
- <tbody>
19
- <% @product_group.product_scopes.each do |product_scope| %>
20
- <tr <%= !product_scope.valid? ? "class='invalid'":'' %> data-hook="product_scopes_row">
21
- <td>
22
- <%= product_scope.to_sentence %>
23
- </td>
24
- <td>
25
- <%= product_scope.arguments.join(', ') %>
26
- </td>
27
- </tr>
28
- <% end %>
29
- </tbody>
30
- </table>
31
-
32
- <%= render :partial => 'preview.html' %>
@@ -1,6 +0,0 @@
1
- $('#product_scopes').append('<%= escape_javascript( render('spree/admin/product_groups/product_scope', :product_scope => @product_scope) ) %>');
2
- $('#<%= dom_id @product_scope %>').hide();
3
- $('#<%= dom_id @product_scope %>').fadeIn();
4
- if(!$('.token-input-list').is('*')){
5
- $('.tokeninput.products').productPicker();
6
- }
@@ -1,3 +0,0 @@
1
- $('#<%= dom_id @product_scope %>').fadeOut();
2
- $('#<%= dom_id @product_scope %>').remove();
3
- $('#preview_container').html('<%= escape_javascript( render('spree/admin/product_groups/preview') ) %>');
@@ -1 +0,0 @@
1
- <%= object.errors.full_messages %>
@@ -1,12 +0,0 @@
1
- <% if products.any? %>
2
- <% form_tag admin_product_groups_path do %>
3
- <%= hidden_field_tag 'product_group[product_scopes_attributes][][name]', 'with_ids' %>
4
- <%= hidden_field_tag 'product_group[product_scopes_attributes][][arguments][]', products.map(&:id).join(',') %>
5
- <fieldset data-hook="create_group">
6
- <legend><%= t(:create_product_group_from_products) %></legend>
7
- <%= label_tag nil, t(:name) %>
8
- <%= text_field_tag 'product_group[name]', t(:new_group) %>
9
- <%= submit_tag t(:create) %>
10
- </fieldset>
11
- <% end %>
12
- <% end %>
@@ -1,18 +0,0 @@
1
- class ProductGroupsAndScopes < ActiveRecord::Migration
2
- def change
3
- create_table :product_groups do |t|
4
- t.string :name, :permalink, :order
5
- end
6
-
7
- create_table :product_scopes do |t|
8
- t.string :name
9
- t.text :arguments
10
- t.references :product_group
11
- end
12
-
13
- add_index :product_groups, :name
14
- add_index :product_groups, :permalink
15
- add_index :product_scopes, :name
16
- add_index :product_scopes, :product_group_id
17
- end
18
- end
@@ -1,8 +0,0 @@
1
- class CreateProductsProductGroups < ActiveRecord::Migration
2
- def change
3
- create_table :product_groups_products, :id => false do |t|
4
- t.references :product
5
- t.references :product_group
6
- end
7
- end
8
- end
@@ -1,9 +0,0 @@
1
- class FixByPopularity < ActiveRecord::Migration
2
- def up
3
- execute("UPDATE product_scopes SET name='descend_by_popularity' WHERE name='by_popularity'")
4
- end
5
-
6
- def down
7
- execute("UPDATE product_scopes SET name='by_popularity' WHERE name='descend_by_popularity'")
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class ConvertSalesTaxToDefaultTax < ActiveRecord::Migration
2
- def up
3
- execute "UPDATE spree_calculators SET type='Spree::Calculator::DefaultTax' WHERE type='Spree::Calculator::SalesTax'"
4
- end
5
-
6
- def down
7
- execute "UPDATE spree_calculators SET type='Spree::Calculator::SalesTax' WHERE type='Spree::Calculator::DefaultTax'"
8
- end
9
- end
@@ -1,5 +0,0 @@
1
- FactoryGirl.define do
2
- factory :product_group, :class => Spree::ProductGroup do
3
- name 'sports'
4
- end
5
- end
@@ -1,7 +0,0 @@
1
- FactoryGirl.define do
2
- factory :product_scope, :class => Spree::ProductScope do
3
- product_group { Factory(:product_group) }
4
- name 'on_hand'
5
- arguments 'some arguments'
6
- end
7
- end