mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Metadata api fix (#7829)
* Fix for plugin metadata view * Add simple unit test * Bump API version
This commit is contained in:
parent
5a98d1e239
commit
1d19196632
@ -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
|
||||
|
@ -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(
|
||||
'<str:plugin>/',
|
||||
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',
|
||||
),
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user