From daa0fdf4b35a6512e5286f33595cc41ba34270c4 Mon Sep 17 00:00:00 2001 From: Andy Byers Date: Wed, 28 Jul 2021 11:36:12 +0100 Subject: [PATCH] Updated for 1.4 --- install/settings.json | 17 +++++++++++++++++ logic.py | 2 +- plugin_settings.py | 32 +++++++++++++++++++++----------- 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 install/settings.json diff --git a/install/settings.json b/install/settings.json new file mode 100644 index 0000000..c6128e5 --- /dev/null +++ b/install/settings.json @@ -0,0 +1,17 @@ +[ + { + "group": { + "name": "plugin:eprints" + }, + "setting": { + "description": "Enable eprints.", + "is_translatable": false, + "name": "eprints_enabled", + "pretty_name": "Enable eprints", + "type": "boolean" + }, + "value": { + "default": "" + } + } +] \ No newline at end of file diff --git a/logic.py b/logic.py index e81d968..0834653 100644 --- a/logic.py +++ b/logic.py @@ -56,7 +56,7 @@ def import_articles_to_journal(request): for article in json_content: - section, created = models.Section.objects.language('en').get_or_create( + section, created = models.Section.objects.get_or_create( journal=request.journal, name=capfirst(article.get('type')) ) diff --git a/plugin_settings.py b/plugin_settings.py index 093e713..cfc8fa9 100644 --- a/plugin_settings.py +++ b/plugin_settings.py @@ -1,25 +1,35 @@ +from utils import models, plugins +from utils.install import update_settings + PLUGIN_NAME = 'eprints' DESCRIPTION = 'Imports Eprints articles.' AUTHOR = 'Andy Byers' VERSION = '1.1' SHORT_NAME = 'eprints' MANAGER_URL = 'eprints_index' -JANEWAY_VERSION = "1.3.6" +JANEWAY_VERSION = "1.3.10" -from utils import models +class EprintsPlugin(plugins.Plugin): + plugin_name = PLUGIN_NAME + display_name = PLUGIN_NAME + description = DESCRIPTION + author = AUTHOR + short_name = SHORT_NAME -def install(): - new_plugin, created = models.Plugin.objects.get_or_create(name=SHORT_NAME, version=VERSION, enabled=True) + manager_url = MANAGER_URL + + version = VERSION + janeway_version = "1.4.0" - if created: - print('Plugin {0} installed.'.format(PLUGIN_NAME)) - else: - print('Plugin {0} is already installed.'.format(PLUGIN_NAME)) + is_workflow_plugin = False - models.PluginSetting.objects.get_or_create(name='eprints_enabled', plugin=new_plugin, types='boolean', - pretty_name='Enable eprints', description='Enable eprints', - is_translatable=False) + +def install(): + EprintsPlugin.install() + update_settings( + file_path='plugins/eprints/install/settings.json', + ) def hook_registry():