2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 04:25:42 +00:00

Plugin helper function (#8220)

* Add helper function for constructing URL to static file

* Fix PluginListTable

- Allow uninstallation of plugin
- Allow deletion of plugin config

* Move helper method to InvenTreePlugin class

* Bump API version info
This commit is contained in:
Oliver
2024-09-30 23:39:38 +10:00
committed by GitHub
parent cbe4569416
commit e9640f4f15
4 changed files with 55 additions and 17 deletions

View File

@ -1,14 +1,17 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 261
INVENTREE_API_VERSION = 262
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
261 - 2024-09;26 : https://github.com/inventree/InvenTree/pull/8184
262 - 2024-09-30 : https://github.com/inventree/InvenTree/pull/8220
- Tweak permission requirements for uninstalling plugins via API
261 - 2024-09-26 : https://github.com/inventree/InvenTree/pull/8184
- Fixes for BuildOrder API serializers
v260 - 2024-09-26 : https://github.com/inventree/InvenTree/pull/8190

View File

@ -21,11 +21,11 @@ from InvenTree.filters import SEARCH_ORDER_FILTER
from InvenTree.mixins import (
CreateAPI,
ListAPI,
RetrieveDestroyAPI,
RetrieveUpdateAPI,
RetrieveUpdateDestroyAPI,
UpdateAPI,
)
from InvenTree.permissions import IsSuperuser
from InvenTree.permissions import IsSuperuser, IsSuperuserOrReadOnly
from plugin import registry
from plugin.base.action.api import ActionPluginView
from plugin.base.barcodes.api import barcode_api_urls
@ -143,7 +143,7 @@ class PluginList(ListAPI):
search_fields = ['key', 'name']
class PluginDetail(RetrieveUpdateDestroyAPI):
class PluginDetail(RetrieveDestroyAPI):
"""API detail endpoint for PluginConfig object.
get:
@ -158,6 +158,7 @@ class PluginDetail(RetrieveUpdateDestroyAPI):
queryset = PluginConfig.objects.all()
serializer_class = PluginSerializers.PluginConfigSerializer
permission_classes = [IsSuperuserOrReadOnly]
lookup_field = 'key'
lookup_url_kwarg = 'plugin'

View File

@ -438,3 +438,11 @@ class InvenTreePlugin(VersionMixin, MixinBase, MetaBase):
self.package = package
# endregion
def plugin_static_file(self, *args):
"""Construct a path to a static file within the plugin directory."""
import os
from django.conf import settings
return '/' + os.path.join(settings.STATIC_URL, 'plugins', self.SLUG, *args)