mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
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:
parent
eccd3be150
commit
f5a216451a
@ -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
|
||||
|
@ -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():
|
||||
|
@ -27,6 +27,7 @@ class ScheduledTaskPlugin(ScheduleMixin, SettingsMixin, InvenTreePlugin):
|
||||
NAME = "ScheduledTasksPlugin"
|
||||
SLUG = "schedule"
|
||||
TITLE = "Scheduled Tasks"
|
||||
VERSION = "0.2.0"
|
||||
|
||||
SCHEDULED_TASKS = {
|
||||
'member': {
|
||||
|
Loading…
Reference in New Issue
Block a user