Plugin schedule fix (#4295)

* Cleanup old info message (seems out of place)

* Wrap called function in quotes

- Doesn't work if you pass the function object itself

* Fix path to called method

This must have been broken for a while?
This commit is contained in:
Oliver 2023-02-02 23:36:19 +11:00 committed by GitHub
parent eccd3be150
commit f5a216451a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 5 deletions

View File

@ -53,6 +53,3 @@ class PluginAppConfig(AppConfig):
if not registry.git_is_modern: # pragma: no cover # simulating old git seems not worth it for coverage
log_error(_('Your environment has an outdated git version. This prevents InvenTree from loading plugin details.'), 'load')
else:
logger.info("Plugins not enabled - skipping loading sequence") # pragma: no cover

View File

@ -12,7 +12,6 @@ import InvenTree.helpers
from plugin.helpers import (MixinImplementationError, MixinNotImplementedError,
render_template, render_text)
from plugin.models import PluginConfig, PluginSetting
from plugin.registry import registry
from plugin.urls import PLUGIN_BASE
logger = logging.getLogger('inventree')
@ -153,12 +152,14 @@ class ScheduleMixin:
for key, task in self.scheduled_tasks.items():
task_name = self.get_task_name(key)
obj = {
'name': task_name,
'schedule_type': task['schedule'],
'minutes': task.get('minutes', None),
'repeats': task.get('repeats', -1),
}
func_name = task['func'].strip()
if '.' in func_name:
@ -167,7 +168,7 @@ class ScheduleMixin:
else:
"""Non-dotted notation indicates that we wish to call a 'member function' of the calling plugin. This is managed by the plugin registry itself."""
slug = self.plugin_slug()
obj['func'] = registry.call_plugin_function
obj['func'] = 'plugin.registry.call_plugin_function'
obj['args'] = f"'{slug}', '{func_name}'"
if Schedule.objects.filter(name=task_name).exists():

View File

@ -27,6 +27,7 @@ class ScheduledTaskPlugin(ScheduleMixin, SettingsMixin, InvenTreePlugin):
NAME = "ScheduledTasksPlugin"
SLUG = "schedule"
TITLE = "Scheduled Tasks"
VERSION = "0.2.0"
SCHEDULED_TASKS = {
'member': {