mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-02 05:26:45 +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 information."""
|
||||||
|
|
||||||
# InvenTree API version
|
# 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."""
|
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
||||||
|
|
||||||
|
|
||||||
INVENTREE_API_TEXT = """
|
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
|
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 build orders
|
||||||
- Adds new endpoints for managing state of purchase orders
|
- Adds new endpoints for managing state of purchase orders
|
||||||
|
@ -414,6 +414,13 @@ class RegistryStatusView(APIView):
|
|||||||
return Response(result)
|
return Response(result)
|
||||||
|
|
||||||
|
|
||||||
|
class PluginMetadataView(MetadataView):
|
||||||
|
"""Metadata API endpoint for the PluginConfig model."""
|
||||||
|
|
||||||
|
lookup_field = 'key'
|
||||||
|
lookup_url_kwarg = 'plugin'
|
||||||
|
|
||||||
|
|
||||||
plugin_api_urls = [
|
plugin_api_urls = [
|
||||||
path('action/', ActionPluginView.as_view(), name='api-action-plugin'),
|
path('action/', ActionPluginView.as_view(), name='api-action-plugin'),
|
||||||
path('barcode/', include(barcode_api_urls)),
|
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(
|
path(
|
||||||
'<str:plugin>/',
|
'<str:plugin>/',
|
||||||
include([
|
include([
|
||||||
@ -459,7 +466,7 @@ plugin_api_urls = [
|
|||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
'metadata/',
|
'metadata/',
|
||||||
MetadataView.as_view(),
|
PluginMetadataView.as_view(),
|
||||||
{'model': PluginConfig, 'lookup_field': 'key'},
|
{'model': PluginConfig, 'lookup_field': 'key'},
|
||||||
name='api-plugin-metadata',
|
name='api-plugin-metadata',
|
||||||
),
|
),
|
||||||
|
@ -233,7 +233,7 @@ class PluginDetailAPITest(PluginMixin, InvenTreeAPITestCase):
|
|||||||
|
|
||||||
# Activate the 'sample' plugin via the API
|
# Activate the 'sample' plugin via the API
|
||||||
cfg = PluginConfig.objects.filter(key='sample').first()
|
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})
|
url = reverse('api-plugin-detail-activate', kwargs={'plugin': cfg.key})
|
||||||
self.client.patch(url, {}, expected_code=200)
|
self.client.patch(url, {}, expected_code=200)
|
||||||
@ -292,3 +292,14 @@ class PluginDetailAPITest(PluginMixin, InvenTreeAPITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(response.data['value'], '456')
|
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…
x
Reference in New Issue
Block a user