forked from saleor/saleor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4aea82
commit 10654c4
Showing
2 changed files
with
55 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
def add_product_attribute_data_to_expected_data(data, product, attribute_ids): | ||
for assigned_attribute in product.attributes.all(): | ||
if assigned_attribute: | ||
header = f"{assigned_attribute.attribute.slug} (product attribute)" | ||
if str(assigned_attribute.attribute.pk) in attribute_ids: | ||
data[header] = assigned_attribute.values.first().slug | ||
|
||
return data | ||
|
||
|
||
def add_variant_attribute_data_to_expected_data(data, variant, attribute_ids): | ||
for assigned_attribute in variant.attributes.all(): | ||
header = f"{assigned_attribute.attribute.slug} (variant attribute)" | ||
if str(assigned_attribute.attribute.pk) in attribute_ids: | ||
data[header] = assigned_attribute.values.first().slug | ||
|
||
return data | ||
|
||
|
||
def add_stocks_to_expected_data(data, variant, warehouse_ids): | ||
for stock in variant.stocks.all(): | ||
if str(stock.warehouse.pk) in warehouse_ids: | ||
slug = stock.warehouse.slug | ||
warehouse_headers = [ | ||
f"{slug} (warehouse quantity)", | ||
] | ||
data[warehouse_headers[0]] = stock.quantity | ||
|
||
return data |