Skip to content

Commit

Permalink
Merge pull request #81 from afkiwers/fix_ipn_setup
Browse files Browse the repository at this point in the history
Added options to IPN setting
  • Loading branch information
afkiwers authored Feb 14, 2024
2 parents b51ea23 + edb42d8 commit 01a991f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ The plugin can be found here: [inventree-kicad-plugin](https://pypi.org/project/

## Configure Plugin Settings

After installing the plugin, head over to the Plugin Settings and activate it. Look for **KiCadLibraryPlugin** in the list of available plugins. Once activated, you'll be able to open the plugin and proceed with the setup process.
After installing the plugin, head over to the Plugin Settings and activate it. Look for **KiCadLibraryPlugin** in the list of available plugins.

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/plugin_settings.png)


Once activated, you'll see a new plugin **KiCad Library Endpoint** on the left hand side. Click on it to open the plugin and proceed with the setup process.

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/new_plugin.png)

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_add_change_categories.png)

## Adding Categories to KiCad

Expand Down
Binary file added images/new_plugin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/plugin_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions inventree_kicad/KiCadLibraryPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ class KiCadLibraryPlugin(UrlsMixin, AppMixin, SettingsMixin, SettingsContentMixi
'default': True,
},
'KICAD_INCLUDE_IPN': {
'name': _('Include IPN in part fields'),
'description': _(
'When activated, the IPN is included in the KiCad fields for a part'),
'validator': bool,
'default': False,
'name': _('Include IPN'),
'description': _('When activated, the IPN is included in the KiCad fields for a part'),
'choices': [('0', 'Do not Include'), ('False', 'Include but Hide in Schematic'), ('True', 'Include and Show in Schematic')],
'default': '0',
},
'KICAD_META_DATA_IMPORT_ADD_DATASHEET': {
'name': _('Add datasheet if URL is valid'),
Expand Down
5 changes: 2 additions & 3 deletions inventree_kicad/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from rest_framework import serializers
from rest_framework.reverse import reverse_lazy

from InvenTree.helpers import str2bool
from InvenTree.helpers_model import construct_absolute_url
from part.models import Part, PartCategory, PartParameter

Expand Down Expand Up @@ -276,10 +275,10 @@ def get_custom_fields(self, part, excluded_field_names):
}
}

if str2bool(self.plugin.get_setting('KICAD_INCLUDE_IPN', False)):
if self.plugin.get_setting('KICAD_INCLUDE_IPN', '0') != '0':
fields['IPN'] = {
'value': f'{part.IPN}',
'visible': 'False'
'visible': self.plugin.get_setting('KICAD_INCLUDE_IPN', 'False')
}

for parameter in part.parameters.all():
Expand Down
2 changes: 1 addition & 1 deletion inventree_kicad/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
KICAD_PLUGIN_VERSION = "1.3.15"
KICAD_PLUGIN_VERSION = "1.3.16"

0 comments on commit 01a991f

Please sign in to comment.