From 685d3df6d19a46b4bb614a5d068c223b65ddfab6 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 12 Nov 2021 00:46:47 +0100 Subject: [PATCH] Enable / Disable Plugins Fixes #2292 --- InvenTree/plugin/admin.py | 9 +++++ InvenTree/plugin/migrations/0001_initial.py | 23 +++++++++++ InvenTree/plugin/migrations/__init__.py | 0 InvenTree/plugin/models.py | 42 +++++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 InvenTree/plugin/admin.py create mode 100644 InvenTree/plugin/migrations/0001_initial.py create mode 100644 InvenTree/plugin/migrations/__init__.py create mode 100644 InvenTree/plugin/models.py diff --git a/InvenTree/plugin/admin.py b/InvenTree/plugin/admin.py new file mode 100644 index 0000000000..69ac29a679 --- /dev/null +++ b/InvenTree/plugin/admin.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.contrib import admin + +import plugin.models as models + + +admin.site.register(models.PluginConfig, admin.ModelAdmin) diff --git a/InvenTree/plugin/migrations/0001_initial.py b/InvenTree/plugin/migrations/0001_initial.py new file mode 100644 index 0000000000..1dd7032f69 --- /dev/null +++ b/InvenTree/plugin/migrations/0001_initial.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.5 on 2021-11-11 23:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='PluginConfig', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('key', models.CharField(help_text='Key of plugin', max_length=255, unique=True, verbose_name='Key')), + ('name', models.CharField(blank=True, help_text='PluginName of the plugin', max_length=255, null=True, verbose_name='Name')), + ('active', models.BooleanField(default=False, help_text='Is the plugin active', verbose_name='Active')), + ], + ), + ] diff --git a/InvenTree/plugin/migrations/__init__.py b/InvenTree/plugin/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/InvenTree/plugin/models.py b/InvenTree/plugin/models.py new file mode 100644 index 0000000000..2aa587d8a4 --- /dev/null +++ b/InvenTree/plugin/models.py @@ -0,0 +1,42 @@ +""" +Plugin model definitions +""" + +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.utils.translation import gettext_lazy as _ +from django.db import models + + +class PluginConfig(models.Model): + """ A PluginConfig object holds settings for plugins. + + It is used to designate a Part as 'subscribed' for a given User. + + Attributes: + key: slug of the plugin - must be unique + name: PluginName of the plugin - serves for a manual double check if the right plugin is used + active: Should the plugin be loaded? + """ + + key = models.CharField( + unique=True, + max_length=255, + verbose_name=_('Key'), + help_text=_('Key of plugin'), + ) + + name = models.CharField( + null=True, + blank=True, + max_length=255, + verbose_name=_('Name'), + help_text=_('PluginName of the plugin'), + ) + + active = models.BooleanField( + default=False, + verbose_name=_('Active'), + help_text=_('Is the plugin active'), + )