2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 20:16:44 +00:00

Add metadata to plugin configs (#5019)

* add metadata to plugin

* Api version bump

* exclude metadata from admin to fix test
This commit is contained in:
Matthias Mair 2023-06-15 08:17:05 +02:00 committed by GitHub
parent 2322a98068
commit 013d206b91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 2 deletions

View File

@ -2,11 +2,14 @@
# InvenTree API version # InvenTree API version
INVENTREE_API_VERSION = 122 INVENTREE_API_VERSION = 123
""" """
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
v123 -> 2023-06-15 : https://github.com/inventree/InvenTree/pull/5019
- Add Metadata to: Plugin Config
v122 -> 2023-06-14 : https://github.com/inventree/InvenTree/pull/5034 v122 -> 2023-06-14 : https://github.com/inventree/InvenTree/pull/5034
- Adds new BuildLineLabel label type - Adds new BuildLineLabel label type

View File

@ -56,6 +56,7 @@ class PluginConfigAdmin(admin.ModelAdmin):
list_filter = ['active'] list_filter = ['active']
actions = [plugin_activate, plugin_deactivate, ] actions = [plugin_activate, plugin_deactivate, ]
inlines = [PluginSettingInline, ] inlines = [PluginSettingInline, ]
exclude = ['metadata', ]
class NotificationUserSettingAdmin(admin.ModelAdmin): class NotificationUserSettingAdmin(admin.ModelAdmin):

View File

@ -9,6 +9,7 @@ from rest_framework.response import Response
import plugin.serializers as PluginSerializers import plugin.serializers as PluginSerializers
from common.api import GlobalSettingsPermissions from common.api import GlobalSettingsPermissions
from InvenTree.api import MetadataView
from InvenTree.filters import SEARCH_ORDER_FILTER from InvenTree.filters import SEARCH_ORDER_FILTER
from InvenTree.mixins import (CreateAPI, ListAPI, RetrieveUpdateAPI, from InvenTree.mixins import (CreateAPI, ListAPI, RetrieveUpdateAPI,
RetrieveUpdateDestroyAPI, UpdateAPI) RetrieveUpdateDestroyAPI, UpdateAPI)
@ -266,6 +267,9 @@ plugin_api_urls = [
re_path(r'^.*$', PluginDetail.as_view(), name='api-plugin-detail'), re_path(r'^.*$', PluginDetail.as_view(), name='api-plugin-detail'),
])), ])),
# Metadata
re_path('^metadata/', MetadataView.as_view(), {'model': PluginConfig}, name='api-plugin-metadata'),
# Plugin management # Plugin management
re_path(r'^install/', PluginInstall.as_view(), name='api-plugin-install'), re_path(r'^install/', PluginInstall.as_view(), name='api-plugin-install'),
re_path(r'^activate/', PluginActivate.as_view(), name='api-plugin-activate'), re_path(r'^activate/', PluginActivate.as_view(), name='api-plugin-activate'),

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.19 on 2023-06-11 16:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('plugin', '0005_notificationusersetting'),
]
operations = [
migrations.AddField(
model_name='pluginconfig',
name='metadata',
field=models.JSONField(blank=True, help_text='JSON metadata field, for use by external plugins', null=True, verbose_name='Plugin Metadata'),
),
]

View File

@ -10,10 +10,11 @@ from django.db import models
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
import common.models import common.models
import InvenTree.models
from plugin import InvenTreePlugin, registry from plugin import InvenTreePlugin, registry
class PluginConfig(models.Model): class PluginConfig(InvenTree.models.MetadataMixin, models.Model):
"""A PluginConfig object holds settings for plugins. """A PluginConfig object holds settings for plugins.
Attributes: Attributes: