mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Refactor PI
This commit is contained in:
@@ -7,17 +7,13 @@ angular.module("ofn.admin").filter 'entriesFilterValid', ->
|
||||
|
||||
angular.forEach entries, (entry, line_number) ->
|
||||
validates_as = entry.validates_as
|
||||
if type == 'valid' and (validates_as != '')
|
||||
filtered[line_number] = entry
|
||||
if type == 'invalid' and (validates_as == '')
|
||||
filtered[line_number] = entry
|
||||
if type == 'create_product' and (validates_as == 'new_product' or validates_as == 'new_variant')
|
||||
filtered[line_number] = entry
|
||||
if type == 'update_product' and validates_as == 'existing_variant'
|
||||
filtered[line_number] = entry
|
||||
if type == 'create_inventory' and validates_as == 'new_inventory_item'
|
||||
filtered[line_number] = entry
|
||||
if type == 'update_inventory' and validates_as == 'existing_inventory_item'
|
||||
|
||||
if type == 'valid' and validates_as != '' \
|
||||
or type == 'invalid' and validates_as == '' \
|
||||
or type == 'create_product' and validates_as == 'new_product' or validates_as == 'new_variant' \
|
||||
or type == 'update_product' and validates_as == 'existing_variant' \
|
||||
or type == 'create_inventory' and validates_as == 'new_inventory_item' \
|
||||
or type == 'update_inventory' and validates_as == 'existing_inventory_item'
|
||||
filtered[line_number] = entry
|
||||
|
||||
filtered
|
||||
|
||||
@@ -17,12 +17,6 @@ class Admin::ProductImportController < Spree::Admin::BaseController
|
||||
@shipping_categories = Spree::ShippingCategory.order('name ASC')
|
||||
end
|
||||
|
||||
# def save
|
||||
# @importer = ProductImporter.new(File.new(params[:filepath]), spree_current_user, params[:settings])
|
||||
# @importer.save_all if @importer.has_valid_entries?
|
||||
# @import_into = params[:settings][:import_into]
|
||||
# end
|
||||
|
||||
def process_data
|
||||
@importer = ProductImporter.new(File.new(params[:filepath]), spree_current_user, start: params[:start], end: params[:end], settings: params[:settings])
|
||||
|
||||
|
||||
@@ -56,10 +56,20 @@ module Admin
|
||||
variant_override_enterprises_per_hub
|
||||
|
||||
@inventory_items = InventoryItem.where(enterprise_id: @hubs)
|
||||
@import_dates = inventory_import_dates.uniq.to_json
|
||||
end
|
||||
|
||||
import_dates = [{id: '0', name: 'All'}]
|
||||
inventory_import_dates.map { |i| import_dates.push(id: i.to_date, name: i.to_date.to_formatted_s(:long)) }
|
||||
@import_dates = import_dates.uniq.to_json
|
||||
def inventory_import_dates
|
||||
options = [{id: '0', name: 'All'}]
|
||||
|
||||
import_dates = VariantOverride.
|
||||
select('variant_overrides.import_date').
|
||||
where('variant_overrides.hub_id IN (?)
|
||||
AND variant_overrides.import_date IS NOT NULL', editable_enterprises.collect(&:id))
|
||||
|
||||
import_dates.uniq.collect(&:import_date).sort.reverse.map { |i| options.push(id: i.to_date, name: i.to_date.to_formatted_s(:long)) }
|
||||
|
||||
options
|
||||
end
|
||||
|
||||
def load_collection
|
||||
|
||||
@@ -80,12 +80,10 @@ class SpreadsheetEntry
|
||||
end
|
||||
|
||||
def is_a_valid?(type)
|
||||
#@validates_as[type]
|
||||
@validates_as == type
|
||||
end
|
||||
|
||||
def is_a_valid(type)
|
||||
#@validates_as.push type
|
||||
@validates_as = type
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user