mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Added update notification (#6165)
* added update notification * added more logging and checks
This commit is contained in:
parent
93df90d295
commit
dfaee0ea96
@ -25,6 +25,9 @@ from maintenance_mode.core import (get_maintenance_mode, maintenance_mode_on,
|
|||||||
set_maintenance_mode)
|
set_maintenance_mode)
|
||||||
|
|
||||||
from InvenTree.config import get_setting
|
from InvenTree.config import get_setting
|
||||||
|
from plugin import registry
|
||||||
|
|
||||||
|
from .version import isInvenTreeUpToDate
|
||||||
|
|
||||||
logger = logging.getLogger("inventree")
|
logger = logging.getLogger("inventree")
|
||||||
|
|
||||||
@ -451,6 +454,7 @@ def check_for_updates():
|
|||||||
"""Check if there is an update for InvenTree."""
|
"""Check if there is an update for InvenTree."""
|
||||||
try:
|
try:
|
||||||
import common.models
|
import common.models
|
||||||
|
from common.notifications import trigger_superuser_notification
|
||||||
except AppRegistryNotReady: # pragma: no cover
|
except AppRegistryNotReady: # pragma: no cover
|
||||||
# Apps not yet loaded!
|
# Apps not yet loaded!
|
||||||
logger.info("Could not perform 'check_for_updates' - App registry not ready")
|
logger.info("Could not perform 'check_for_updates' - App registry not ready")
|
||||||
@ -511,6 +515,24 @@ def check_for_updates():
|
|||||||
# Record that this task was successful
|
# Record that this task was successful
|
||||||
record_task_success('check_for_updates')
|
record_task_success('check_for_updates')
|
||||||
|
|
||||||
|
# Send notification if there is a new version
|
||||||
|
if not isInvenTreeUpToDate():
|
||||||
|
logger.warning("InvenTree is not up-to-date, sending notification")
|
||||||
|
|
||||||
|
plg = registry.get_plugin('InvenTreeCoreNotificationsPlugin')
|
||||||
|
if not plg:
|
||||||
|
logger.warning("Cannot send notification - plugin not found")
|
||||||
|
return
|
||||||
|
plg = plg.plugin_config()
|
||||||
|
if not plg:
|
||||||
|
logger.warning("Cannot send notification - plugin config not found")
|
||||||
|
return
|
||||||
|
# Send notification
|
||||||
|
trigger_superuser_notification(
|
||||||
|
plg,
|
||||||
|
f'An update for InvenTree to version {tag} is available',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@scheduled_task(ScheduledTask.DAILY)
|
@scheduled_task(ScheduledTask.DAILY)
|
||||||
def update_exchange_rates(force: bool = False):
|
def update_exchange_rates(force: bool = False):
|
||||||
|
Loading…
Reference in New Issue
Block a user