Skip to content

Commit 3845511

Browse files
authored
Fix bug in product list resource (#233)
* Fix bug: unexpected argument 'defaultgroups' * Fix string-int comparison and update documentation
1 parent 69e34a1 commit 3845511

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

importer/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,12 @@ The coverage report `coverage.html` will be at the working directory
137137
- The csv_file containing the exported resources is labelled using the current time, to know when the resources were exported for example, csv/exports/2024-02-21-12-21-export_Location.csv
138138

139139
### 10. Import products from openSRP 1
140-
- Run `python3 main.py --csv_file csv/import/product.csv --setup products --log_level info`
140+
- Run `python3 main.py --csv_file csv/import/product.csv --setup products --list_resource_id 123 --log_level info`
141141
- See example csv [here](/importer/csv/import/product.csv)
142142
- This creates a Group resource for each product imported, a Binary resource for any products with an image, and a List resource with references to all the Group and Binary resources created
143143
- The first two columns __name__ and __active__ is the minimum required
144144
- The last column __imageSourceUrl__ contains a url to the product image. If this source requires authentication, then you need to provide the `product_access_token` in the config file. The image is added as a binary resource and referenced in the product's Group resource
145+
- You can pass in a `list_resource_id` to be used as the identifier for the List resource, or you can leave it empty and a random uuid will be generated
145146

146147
### 11. Import inventories from openSRP 1
147148
- Run `python3 main.py --csv_file csv/import/inventory.csv --setup inventories --log_level info`

importer/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,7 @@ def filter(self, record):
18181818
@click.option("--setup", required=False)
18191819
@click.option("--group", required=False)
18201820
@click.option("--roles_max", required=False, default=500)
1821-
@click.option("--defaultgroups", required=False, default=False)
1821+
@click.option("--default_groups", required=False, default=False)
18221822
@click.option("--cascade_delete", required=False, default=False)
18231823
@click.option("--only_response", required=False)
18241824
@click.option(
@@ -1992,7 +1992,7 @@ def main(
19921992
list_resource_id = str(uuid.uuid5(uuid.NAMESPACE_DNS, csv_file))
19931993

19941994
current_version = get_resource(list_resource_id, "List")
1995-
method = "create" if current_version == 0 else "update"
1995+
method = "create" if current_version == str(0) else "update"
19961996
resource = [["Supply Inventory List", "current", method, list_resource_id]]
19971997
result_payload = build_payload(
19981998
"List", resource, "json_payloads/product_list_payload.json")

0 commit comments

Comments
 (0)