mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Create EnterpriseSet as subclass of ModelSet
This commit is contained in:
@@ -6,7 +6,7 @@ module Admin
|
||||
helper 'spree/products'
|
||||
|
||||
def bulk_update
|
||||
@enterprise_set = ModelSet.new(Enterprise.all, params[:model_set])
|
||||
@enterprise_set = EnterpriseSet.new(params[:enterprise_set])
|
||||
if @enterprise_set.save
|
||||
redirect_to main_app.admin_enterprises_path, :notice => 'Distributor collection times updated.'
|
||||
else
|
||||
@@ -16,7 +16,7 @@ module Admin
|
||||
|
||||
private
|
||||
def load_enterprise_set
|
||||
@enterprise_set = ModelSet.new Enterprise.all, :collection => collection
|
||||
@enterprise_set = EnterpriseSet.new :collection => collection
|
||||
end
|
||||
|
||||
def load_countries
|
||||
|
||||
5
app/models/enterprise_set.rb
Normal file
5
app/models/enterprise_set.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class EnterpriseSet < ModelSet
|
||||
def initialize(attributes={})
|
||||
super(Enterprise.all, attributes)
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,4 @@
|
||||
# Tableless model to handle updating multiple models at once from a
|
||||
# single form. For example, it is used to update the enterprise next_collection_at
|
||||
# field for all distributors in the admin backend.
|
||||
# Tableless model to handle updating multiple models at once from a single form
|
||||
class ModelSet
|
||||
include ActiveModel::Conversion
|
||||
extend ActiveModel::Naming
|
||||
|
||||
@@ -109,9 +109,9 @@ feature %q{
|
||||
click_link 'Enterprises'
|
||||
|
||||
# And I fill in some new collection times and save them
|
||||
fill_in 'model_set_collection_attributes_0_next_collection_at', :with => 'One'
|
||||
fill_in 'model_set_collection_attributes_1_next_collection_at', :with => 'Two'
|
||||
fill_in 'model_set_collection_attributes_2_next_collection_at', :with => 'Three'
|
||||
fill_in 'enterprise_set_collection_attributes_0_next_collection_at', :with => 'One'
|
||||
fill_in 'enterprise_set_collection_attributes_1_next_collection_at', :with => 'Two'
|
||||
fill_in 'enterprise_set_collection_attributes_2_next_collection_at', :with => 'Three'
|
||||
click_button 'Update'
|
||||
|
||||
# Then my times should have been saved
|
||||
|
||||
Reference in New Issue
Block a user