diff --git a/src/backend/InvenTree/InvenTree/api_version.py b/src/backend/InvenTree/InvenTree/api_version.py index d8c92d5f25..f4ca3b8293 100644 --- a/src/backend/InvenTree/InvenTree/api_version.py +++ b/src/backend/InvenTree/InvenTree/api_version.py @@ -1,13 +1,16 @@ """InvenTree API version information.""" # InvenTree API version -INVENTREE_API_VERSION = 233 +INVENTREE_API_VERSION = 234 """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" INVENTREE_API_TEXT = """ +v234 - 2024-08-08 : https://github.com/inventree/InvenTree/pull/7829 + - Fixes bug in the plugin metadata endpoint + v233 - 2024-08-04 : https://github.com/inventree/InvenTree/pull/7807 - Adds new endpoints for managing state of build orders - Adds new endpoints for managing state of purchase orders diff --git a/src/backend/InvenTree/plugin/api.py b/src/backend/InvenTree/plugin/api.py index 2c5d3cc864..061c35bb55 100644 --- a/src/backend/InvenTree/plugin/api.py +++ b/src/backend/InvenTree/plugin/api.py @@ -414,6 +414,13 @@ class RegistryStatusView(APIView): return Response(result) +class PluginMetadataView(MetadataView): + """Metadata API endpoint for the PluginConfig model.""" + + lookup_field = 'key' + lookup_url_kwarg = 'plugin' + + plugin_api_urls = [ path('action/', ActionPluginView.as_view(), name='api-action-plugin'), path('barcode/', include(barcode_api_urls)), @@ -438,7 +445,7 @@ plugin_api_urls = [ ) ]), ), - # Lookup for individual plugins (based on 'key', not 'pk') + # Lookup for individual plugins (based on 'plugin', not 'pk') path( '/', include([ @@ -459,7 +466,7 @@ plugin_api_urls = [ ), path( 'metadata/', - MetadataView.as_view(), + PluginMetadataView.as_view(), {'model': PluginConfig, 'lookup_field': 'key'}, name='api-plugin-metadata', ), diff --git a/src/backend/InvenTree/plugin/test_api.py b/src/backend/InvenTree/plugin/test_api.py index bdef4481e3..d5cd8a1a4a 100644 --- a/src/backend/InvenTree/plugin/test_api.py +++ b/src/backend/InvenTree/plugin/test_api.py @@ -233,7 +233,7 @@ class PluginDetailAPITest(PluginMixin, InvenTreeAPITestCase): # Activate the 'sample' plugin via the API cfg = PluginConfig.objects.filter(key='sample').first() - assert cfg is not None + self.assertIsNotNone(cfg) url = reverse('api-plugin-detail-activate', kwargs={'plugin': cfg.key}) self.client.patch(url, {}, expected_code=200) @@ -292,3 +292,14 @@ class PluginDetailAPITest(PluginMixin, InvenTreeAPITestCase): ) self.assertEqual(response.data['value'], '456') + + def test_plugin_metadata(self): + """Test metadata endpoint for plugin.""" + self.user.is_superuser = True + self.user.save() + + cfg = PluginConfig.objects.filter(key='sample').first() + self.assertIsNotNone(cfg) + + url = reverse('api-plugin-metadata', kwargs={'plugin': cfg.key}) + self.get(url, expected_code=200)