Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in product list resource #233

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion importer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 2 additions & 2 deletions importer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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")
Expand Down
Loading