Skip to content

Commit

Permalink
Add external link attachment support for datasheets
Browse files Browse the repository at this point in the history
  • Loading branch information
30350n committed Dec 11, 2023
1 parent c9fe3f3 commit ad3dda2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion inventree_part_import/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ def get_config(reload=False):
prompt("how do you want to handle datasheets?")
datasheets_choices = [
"upload (upload file attachments for parts)",
"link (add external link attachments to parts)",
"false (do not add datasheets for parts)",
]
datasheets_values = ["upload", False]
datasheets_values = ["upload", "link", False]
datasheets_index = select(datasheets_choices, deselected_prefix=" ", selected_prefix="> ")

_CONFIG_LOADED = {
Expand Down
2 changes: 2 additions & 0 deletions inventree_part_import/part_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def import_supplier_part(self, supplier: Company, api_part: ApiPart):
match get_config().get("datasheets"):
case "upload":
upload_datasheet(part, api_part.datasheet_url)
case "link":
part.addLinkAttachment(api_part.datasheet_url, comment="datasheet")
case None | False:
pass
case invalid_mode:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies = [
"cutie",
"digikey-api>=1.0",
"fake-useragent",
"inventree>=0.12",
"inventree>=0.13.2",
"isocodes",
"mouser>=0.1.5",
"platformdirs",
Expand Down

0 comments on commit ad3dda2

Please sign in to comment.