mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-06 22:36:07 +00:00
DRY controller methods which became too long
This commit is contained in:
@@ -17,8 +17,7 @@ module Admin
|
||||
api = DfcRequest.new(spree_current_user)
|
||||
@catalog_url = params.require(:catalog_url).strip
|
||||
@catalog_json = api.call(@catalog_url)
|
||||
graph = DfcIo.import(@catalog_json)
|
||||
catalog = DfcCatalog.new(graph)
|
||||
catalog = DfcCatalog.from_json(@catalog_json)
|
||||
|
||||
# Render table and let user decide which ones to import.
|
||||
@items = catalog.products.map do |subject|
|
||||
@@ -48,8 +47,7 @@ module Admin
|
||||
ids = params.require(:semanticIds)
|
||||
|
||||
# Load DFC catalog JSON
|
||||
graph = DfcIo.import(params.require(:catalog_json))
|
||||
catalog = DfcCatalog.new(graph)
|
||||
catalog = DfcCatalog.from_json(params.require(:catalog_json))
|
||||
catalog.apply_wholesale_values!
|
||||
|
||||
# Import all selected products for given enterprise.
|
||||
|
||||
@@ -4,9 +4,12 @@ class DfcCatalog
|
||||
def self.load(user, catalog_url)
|
||||
api = DfcRequest.new(user)
|
||||
catalog_json = api.call(catalog_url)
|
||||
graph = DfcIo.import(catalog_json)
|
||||
|
||||
new(graph)
|
||||
from_json(catalog_json)
|
||||
end
|
||||
|
||||
def self.from_json(catalog_json)
|
||||
new(DfcIo.import(catalog_json))
|
||||
end
|
||||
|
||||
def initialize(graph)
|
||||
|
||||
Reference in New Issue
Block a user