Skip to content

Commit

Permalink
Merge pull request #180 from sparkmicro/1.0.x
Browse files Browse the repository at this point in the history
1.0.4
  • Loading branch information
eeintech authored Oct 14, 2023
2 parents f3ad51c + bd0f3c9 commit 5049836
Show file tree
Hide file tree
Showing 5 changed files with 258 additions and 245 deletions.
5 changes: 4 additions & 1 deletion kintree/common/part_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def generate_part_number(category: str, part_pk: int, category_code='') -> str:
if settings.CONFIG_IPN.get('IPN_CATEGORY_CODE', False):
if not category_code:
CATEGORY_CODES = config_interface.load_file(settings.CONFIG_CATEGORIES)['CODES']
category_code = CATEGORY_CODES.get(category, '')
try:
category_code = CATEGORY_CODES.get(category, '')
except AttributeError:
category_code = None
if category_code:
ipn_elements.append(category_code)

Expand Down
26 changes: 16 additions & 10 deletions kintree/gui/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,15 @@ def process_category(self, e=None, label=None, value=None):
parent_category = None
if isinstance(self.fields['Category'].value, str):
parent_category = inventree_interface.split_category_tree(self.fields['Category'].value)[0]
self.fields['IPN: Category Code'].options = self.get_code_options()
# Select category code corresponding to selected category
code = config_interface.load_file(settings.CONFIG_CATEGORIES)['CODES'].get(parent_category, None)
if code and not self.fields['Create New Code'].value:
self.fields['IPN: Category Code'].value = code
self.fields['IPN: Category Code'].update()
# Check for category codes
options = self.get_code_options()
if options:
self.fields['IPN: Category Code'].options = options
# Select category code corresponding to selected category
code = config_interface.load_file(settings.CONFIG_CATEGORIES)['CODES'].get(parent_category, None)
if code and not self.fields['Create New Code'].value:
self.fields['IPN: Category Code'].value = code
self.fields['IPN: Category Code'].update()
self.push_data(e)

def process_ipncode(self):
Expand All @@ -667,10 +670,13 @@ def process_ipncode(self):
self.ipncode_row_ref.current.update()

def get_code_options(self):
return [
ft.dropdown.Option(code)
for code in config_interface.load_file(settings.CONFIG_CATEGORIES)['CODES'].values()
]
try:
return [
ft.dropdown.Option(code)
for code in config_interface.load_file(settings.CONFIG_CATEGORIES)['CODES'].values()
]
except AttributeError:
return []

def get_category_options(self, reload=False):
return [
Expand Down
4 changes: 2 additions & 2 deletions kintree/search/digikey_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def test_api(check_content=False) -> bool:
'manufacturer': 'Stackpole Electronics Inc',
'manufacturer_part_number': 'RMCF0402JT10K0',
'product_url': 'https://www.digikey.com/en/products/detail/stackpole-electronics-inc/RMCF0402JT10K0/1758206',
'primary_datasheet': 'https://www.seielect.com/Catalog/SEI-RMCF_RMCP.pdf',
'primary_photo': 'https://media.digikey.com/photos/Stackpole%20Photos/MFG_RMC%20SERIES.jpg',
'primary_datasheet': 'https://www.seielect.com/catalog/sei-rmcf_rmcp.pdf',
'primary_photo': 'https://mm.digikey.com/Volume0/opasdata/d220001/medias/images/2597/MFG_RMC SERIES.jpg',
}

test_part = fetch_part_info('RMCF0402JT10K0')
Expand Down
Loading

0 comments on commit 5049836

Please sign in to comment.