From b2478b418ac670cad800c0b5e535f3fb31f55e6d Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 12 Nov 2021 00:09:05 +0100 Subject: [PATCH] "description" field for plugin Fixes #2293 --- InvenTree/plugin/integration.py | 9 +++++++++ InvenTree/plugin/test_integration.py | 6 ++++++ .../templates/InvenTree/settings/plugin_settings.html | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/InvenTree/plugin/integration.py b/InvenTree/plugin/integration.py index 181576732c..0aaecfd28c 100644 --- a/InvenTree/plugin/integration.py +++ b/InvenTree/plugin/integration.py @@ -271,6 +271,7 @@ class IntegrationPluginBase(MixinBase, plugin.InvenTreePlugin): PLUGIN_TITLE = None AUTHOR = None + DESCRIPTION = None PUBLISH_DATE = None VERSION = None WEBSITE = None @@ -304,6 +305,14 @@ class IntegrationPluginBase(MixinBase, plugin.InvenTreePlugin): name = self.plugin_name() return name + @property + def description(self): + """description of plugin""" + description = getattr(self, 'DESCRIPTION', None) + if not description: + description = self.plugin_name() + return description + @property def author(self): """returns author of plugin - either from plugin settings or git""" diff --git a/InvenTree/plugin/test_integration.py b/InvenTree/plugin/test_integration.py index 53652b7a6f..9493d2a237 100644 --- a/InvenTree/plugin/test_integration.py +++ b/InvenTree/plugin/test_integration.py @@ -163,6 +163,7 @@ class IntegrationPluginBaseTests(TestCase): PLUGIN_TITLE = 'a titel' PUBLISH_DATE = "1111-11-11" AUTHOR = 'AA BB' + DESCRIPTION = 'A description' VERSION = '1.2.3a' WEBSITE = 'http://aa.bb/cc' @@ -185,6 +186,11 @@ class IntegrationPluginBaseTests(TestCase): self.assertEqual(self.plugin_simple.human_name, 'SimplePlugin') self.assertEqual(self.plugin_name.human_name, 'a titel') + # description + self.assertEqual(self.plugin.description, '') + self.assertEqual(self.plugin_simple.description, 'SimplePlugin') + self.assertEqual(self.plugin_name.description, 'A description') + # author self.assertEqual(self.plugin_name.author, 'AA BB') diff --git a/InvenTree/templates/InvenTree/settings/plugin_settings.html b/InvenTree/templates/InvenTree/settings/plugin_settings.html index e78e2f204a..cb5ed85d6d 100644 --- a/InvenTree/templates/InvenTree/settings/plugin_settings.html +++ b/InvenTree/templates/InvenTree/settings/plugin_settings.html @@ -27,6 +27,11 @@ {% trans "Author" %} {{ plugin.author }}{% include "clip.html" %} + + + {% trans "Description" %} + {{ plugin.description }}{% include "clip.html" %} + {% trans "Date" %}