From 0e546486551be96082426648eb6f778a2d18bf4d Mon Sep 17 00:00:00 2001 From: Wambere Date: Tue, 23 Jul 2024 11:49:13 +0300 Subject: [PATCH 1/2] Fix bug: unexpected argument 'defaultgroups' --- importer/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/importer/main.py b/importer/main.py index 321cce37..398a1adc 100644 --- a/importer/main.py +++ b/importer/main.py @@ -1818,7 +1818,7 @@ def filter(self, record): @click.option("--setup", required=False) @click.option("--group", required=False) @click.option("--roles_max", required=False, default=500) -@click.option("--defaultgroups", required=False, default=False) +@click.option("--default_groups", required=False, default=False) @click.option("--cascade_delete", required=False, default=False) @click.option("--only_response", required=False) @click.option( From ed512ae87b7d2bff9bc7b7cef246be2c990fb209 Mon Sep 17 00:00:00 2001 From: Wambere Date: Tue, 23 Jul 2024 11:52:15 +0300 Subject: [PATCH 2/2] Fix string-int comparison and update documentation --- importer/README.md | 3 ++- importer/main.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/importer/README.md b/importer/README.md index 4b40e77d..d7fff96d 100644 --- a/importer/README.md +++ b/importer/README.md @@ -137,11 +137,12 @@ The coverage report `coverage.html` will be at the working directory - 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 ### 10. Import products from openSRP 1 -- Run `python3 main.py --csv_file csv/import/product.csv --setup products --log_level info` +- Run `python3 main.py --csv_file csv/import/product.csv --setup products --list_resource_id 123 --log_level info` - See example csv [here](/importer/csv/import/product.csv) - 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 - The first two columns __name__ and __active__ is the minimum required - 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 +- 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 ### 11. Import inventories from openSRP 1 - Run `python3 main.py --csv_file csv/import/inventory.csv --setup inventories --log_level info` diff --git a/importer/main.py b/importer/main.py index 398a1adc..703a9359 100644 --- a/importer/main.py +++ b/importer/main.py @@ -1992,7 +1992,7 @@ def main( list_resource_id = str(uuid.uuid5(uuid.NAMESPACE_DNS, csv_file)) current_version = get_resource(list_resource_id, "List") - method = "create" if current_version == 0 else "update" + method = "create" if current_version == str(0) else "update" resource = [["Supply Inventory List", "current", method, list_resource_id]] result_payload = build_payload( "List", resource, "json_payloads/product_list_payload.json")