mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
PI inventories timestamps
This commit is contained in:
@@ -448,11 +448,33 @@ class ProductImporter
|
||||
@already_created[entry.supplier_id] = {entry.name => product.id}
|
||||
end
|
||||
|
||||
def display_in_inventory(variant_override, is_new=false)
|
||||
unless is_new
|
||||
existing_item = InventoryItem.where(
|
||||
variant_id: variant_override.variant_id,
|
||||
enterprise_id: variant_override.hub_id).
|
||||
first
|
||||
|
||||
if existing_item
|
||||
existing_item.assign_attributes(visible: true)
|
||||
existing_item.save
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
InventoryItem.new(
|
||||
variant_id: variant_override.variant_id,
|
||||
enterprise_id: variant_override.hub_id,
|
||||
visible: true).
|
||||
save
|
||||
end
|
||||
|
||||
def save_new_inventory_item(entry)
|
||||
new_item = entry.product_object
|
||||
assign_defaults(new_item, entry)
|
||||
new_item.import_date = @import_time
|
||||
if new_item.valid? and new_item.save
|
||||
display_in_inventory(new_item, true)
|
||||
@inventory_created += 1
|
||||
@updated_ids.push new_item.id
|
||||
else
|
||||
@@ -465,6 +487,7 @@ class ProductImporter
|
||||
assign_defaults(existing_item, entry)
|
||||
existing_item.import_date = @import_time
|
||||
if existing_item.valid? and existing_item.save
|
||||
display_in_inventory(existing_item)
|
||||
@inventory_updated += 1
|
||||
@updated_ids.push existing_item.id
|
||||
else
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Api::Admin::VariantOverrideSerializer < ActiveModel::Serializer
|
||||
attributes :id, :hub_id, :variant_id, :sku, :price, :count_on_hand, :on_demand, :default_stock, :resettable
|
||||
attributes :tag_list, :tags
|
||||
attributes :tag_list, :tags, :import_date
|
||||
|
||||
def tag_list
|
||||
object.tag_list.join(",")
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
%col.inheritance{ width: "5%", ng: { show: 'columns.inheritance.visible' } }
|
||||
%col.tags{ width: "30%", ng: { show: 'columns.tags.visible' } }
|
||||
%col.visibility{ width: "10%", ng: { show: 'columns.visibility.visible' } }
|
||||
%col.visibility{ width: "10%", ng: { show: 'columns.import_date.visible' } }
|
||||
%thead
|
||||
%tr{ ng: { controller: "ColumnsCtrl" } }
|
||||
%th.producer{ ng: { show: 'columns.producer.visible' } }=t('admin.producer')
|
||||
@@ -25,6 +26,7 @@
|
||||
%th.inheritance{ ng: { show: 'columns.inheritance.visible' } }=t('admin.variant_overrides.index.inherit?')
|
||||
%th.tags{ ng: { show: 'columns.tags.visible' } }=t('admin.tags')
|
||||
%th.visibility{ ng: { show: 'columns.visibility.visible' } }=t('admin.variant_overrides.index.hide')
|
||||
%th.import_date{ ng: { show: 'columns.import_date.visible' } }=t('admin.variant_overrides.index.import_date')
|
||||
%tbody{ ng: {repeat: 'product in filteredProducts = (products | hubPermissions:hubPermissions:hub_id | inventoryProducts:hub_id:views | attrFilter:{producer_id:producerFilter} | filter:query) | limitTo:productLimit' } }
|
||||
= render 'admin/variant_overrides/products_product'
|
||||
= render 'admin/variant_overrides/products_variants'
|
||||
|
||||
@@ -9,3 +9,4 @@
|
||||
%td.inheritance{ ng: { show: 'columns.inheritance.visible' } }
|
||||
%td.tags{ ng: { show: 'columns.tags.visible' } }
|
||||
%td.visibility{ ng: { show: 'columns.visibility.visible' } }
|
||||
%td.import_date{ ng: { show: 'columns.import_date.visible' } }
|
||||
|
||||
@@ -23,3 +23,5 @@
|
||||
%td.visibility{ ng: { show: 'columns.visibility.visible' } }
|
||||
%button.icon-remove.hide.fullwidth{ :type => 'button', ng: { click: "setVisibility(hub_id,variant.id,false)" } }
|
||||
= t('admin.variant_overrides.index.hide')
|
||||
%td.import_date{ ng: { show: 'columns.import_date.visible' } }
|
||||
%span {{variantOverrides[hub_id][variant.id].import_date | date:"MMMM dd, yyyy HH:mm"}}
|
||||
@@ -485,6 +485,7 @@ en:
|
||||
inherit?: Inherit?
|
||||
add: Add
|
||||
hide: Hide
|
||||
import_date: Imported
|
||||
select_a_shop: Select A Shop
|
||||
review_now: Review Now
|
||||
new_products_alert_message: There are %{new_product_count} new products available to add to your inventory.
|
||||
|
||||
@@ -289,6 +289,7 @@ en_GB:
|
||||
inherit?: Inherit?
|
||||
add: Add
|
||||
hide: Hide
|
||||
import_date: Imported
|
||||
select_a_shop: Select A Shop
|
||||
review_now: Review Now
|
||||
new_products_alert_message: There are %{new_product_count} new products available to add to your inventory.
|
||||
|
||||
@@ -19,7 +19,8 @@ module OpenFoodNetwork
|
||||
reset: { name: I18n.t("#{node}.enable_reset?"), visible: false },
|
||||
inheritance: { name: I18n.t("#{node}.inherit?"), visible: false },
|
||||
tags: { name: I18n.t("admin.tags"), visible: false },
|
||||
visibility: { name: I18n.t("#{node}.hide"), visible: false }
|
||||
visibility: { name: I18n.t("#{node}.hide"), visible: false },
|
||||
import_date: { name: I18n.t("#{node}.import_date"), visible: false }
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user