mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
plugin hash - reduce error outputs (#5772)
* plugin hash - reduce error outputs - If database is migrating, or not ready, don't log exception - Ref: https://github.com/inventree/inventree-app/actions/runs/6604140572/job/17937959893 * Improve imports * Further import improvements * Typo fix
This commit is contained in:
parent
d03927dea4
commit
2dfe2d97bc
@ -16,24 +16,24 @@ from dj_rest_auth.registration.views import (ConfirmEmailView,
|
||||
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView
|
||||
from sesame.views import LoginView
|
||||
|
||||
from build.api import build_api_urls
|
||||
import build.api
|
||||
import common.api
|
||||
import company.api
|
||||
import label.api
|
||||
import order.api
|
||||
import part.api
|
||||
import plugin.api
|
||||
import report.api
|
||||
import stock.api
|
||||
import users.api
|
||||
from build.urls import build_urls
|
||||
from common.api import admin_api_urls, common_api_urls, settings_api_urls
|
||||
from common.urls import common_urls
|
||||
from company.api import company_api_urls
|
||||
from company.urls import (company_urls, manufacturer_part_urls,
|
||||
supplier_part_urls)
|
||||
from label.api import label_api_urls
|
||||
from order.api import order_api_urls
|
||||
from order.urls import order_urls
|
||||
from part.api import bom_api_urls, part_api_urls
|
||||
from part.urls import part_urls
|
||||
from plugin.api import plugin_api_urls
|
||||
from plugin.urls import get_plugin_urls
|
||||
from report.api import report_api_urls
|
||||
from stock.api import stock_api_urls
|
||||
from stock.urls import stock_urls
|
||||
from users.api import user_urls
|
||||
from web.urls import urlpatterns as platform_urls
|
||||
|
||||
from .api import APISearchView, InfoView, NotFoundView
|
||||
@ -55,23 +55,23 @@ apipatterns = [
|
||||
# Global search
|
||||
path('search/', APISearchView.as_view(), name='api-search'),
|
||||
|
||||
re_path(r'^settings/', include(settings_api_urls)),
|
||||
re_path(r'^part/', include(part_api_urls)),
|
||||
re_path(r'^bom/', include(bom_api_urls)),
|
||||
re_path(r'^company/', include(company_api_urls)),
|
||||
re_path(r'^stock/', include(stock_api_urls)),
|
||||
re_path(r'^build/', include(build_api_urls)),
|
||||
re_path(r'^order/', include(order_api_urls)),
|
||||
re_path(r'^label/', include(label_api_urls)),
|
||||
re_path(r'^report/', include(report_api_urls)),
|
||||
re_path(r'^user/', include(user_urls)),
|
||||
re_path(r'^admin/', include(admin_api_urls)),
|
||||
re_path(r'^settings/', include(common.api.settings_api_urls)),
|
||||
re_path(r'^part/', include(part.api.part_api_urls)),
|
||||
re_path(r'^bom/', include(part.api.bom_api_urls)),
|
||||
re_path(r'^company/', include(company.api.company_api_urls)),
|
||||
re_path(r'^stock/', include(stock.api.stock_api_urls)),
|
||||
re_path(r'^build/', include(build.api.build_api_urls)),
|
||||
re_path(r'^order/', include(order.api.order_api_urls)),
|
||||
re_path(r'^label/', include(label.api.label_api_urls)),
|
||||
re_path(r'^report/', include(report.api.report_api_urls)),
|
||||
re_path(r'^user/', include(users.api.user_urls)),
|
||||
re_path(r'^admin/', include(common.api.admin_api_urls)),
|
||||
|
||||
# Plugin endpoints
|
||||
path('', include(plugin_api_urls)),
|
||||
path('', include(plugin.api.plugin_api_urls)),
|
||||
|
||||
# Common endpoints endpoint
|
||||
path('', include(common_api_urls)),
|
||||
path('', include(common.api.common_api_urls)),
|
||||
|
||||
# OpenAPI Schema
|
||||
re_path('schema/', SpectacularAPIView.as_view(custom_settings={'SCHEMA_PATH_PREFIX': '/api/'}), name='schema'),
|
||||
|
@ -16,10 +16,10 @@ from django.utils.translation import gettext_lazy as _
|
||||
import common.models
|
||||
import InvenTree.helpers
|
||||
import InvenTree.helpers_model
|
||||
import plugin.models
|
||||
from common.settings import currency_code_default
|
||||
from InvenTree import settings, version
|
||||
from plugin import registry
|
||||
from plugin.models import NotificationUserSetting, PluginSetting
|
||||
from plugin.plugin import InvenTreePlugin
|
||||
|
||||
register = template.Library()
|
||||
@ -346,14 +346,14 @@ def setting_object(key, *args, **kwargs):
|
||||
if 'plugin' in kwargs:
|
||||
# Note, 'plugin' is an instance of an InvenTreePlugin class
|
||||
|
||||
plugin = kwargs['plugin']
|
||||
if issubclass(plugin.__class__, InvenTreePlugin):
|
||||
plugin = plugin.plugin_config()
|
||||
plg = kwargs['plugin']
|
||||
if issubclass(plg.__class__, InvenTreePlugin):
|
||||
plg = plg.plugin_config()
|
||||
|
||||
return PluginSetting.get_setting_object(key, plugin=plugin, cache=cache)
|
||||
return plugin.models.PluginSetting.get_setting_object(key, plugin=plg, cache=cache)
|
||||
|
||||
elif 'method' in kwargs:
|
||||
return NotificationUserSetting.get_setting_object(key, user=kwargs['user'], method=kwargs['method'], cache=cache)
|
||||
return plugin.models.NotificationUserSetting.get_setting_object(key, user=kwargs['user'], method=kwargs['method'], cache=cache)
|
||||
|
||||
elif 'user' in kwargs:
|
||||
return common.models.InvenTreeUserSetting.get_setting_object(key, user=kwargs['user'], cache=cache)
|
||||
|
@ -649,7 +649,11 @@ class PluginsRegistry:
|
||||
try:
|
||||
logger.debug("Updating plugin registry hash: %s", str(self.registry_hash))
|
||||
InvenTreeSetting.set_setting("_PLUGIN_REGISTRY_HASH", self.registry_hash, change_user=None)
|
||||
except (OperationalError, ProgrammingError):
|
||||
# Exception if the database has not been migrated yet, or is not ready
|
||||
pass
|
||||
except Exception as exc:
|
||||
# Some other exception, we want to know about it
|
||||
logger.exception("Failed to update plugin registry hash: %s", str(exc))
|
||||
|
||||
def calculate_plugin_hash(self):
|
||||
|
Loading…
Reference in New Issue
Block a user