mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
make deactivaton safe
even if apps were not loaded rigth
This commit is contained in:
parent
8708279629
commit
3d2648ffb2
@ -269,12 +269,17 @@ class PluginAppConfig(AppConfig):
|
|||||||
for plugin_path in settings.INTEGRATION_APPS_PATHS:
|
for plugin_path in settings.INTEGRATION_APPS_PATHS:
|
||||||
models = [] # the modelrefs need to be collected as poping an item in a iter is not welcomed
|
models = [] # the modelrefs need to be collected as poping an item in a iter is not welcomed
|
||||||
app_name = plugin_path.split('.')[-1]
|
app_name = plugin_path.split('.')[-1]
|
||||||
|
try:
|
||||||
|
app_config = apps.get_app_config(app_name)
|
||||||
|
|
||||||
# check all models
|
# check all models
|
||||||
for model in apps.get_app_config(app_name).get_models():
|
for model in app_config.get_models():
|
||||||
# remove model from admin site
|
# remove model from admin site
|
||||||
admin.site.unregister(model)
|
admin.site.unregister(model)
|
||||||
models += [model._meta.model_name]
|
models += [model._meta.model_name]
|
||||||
|
except LookupError:
|
||||||
|
# if an error occurs the app was never loaded right -> so nothing to do anymore
|
||||||
|
break
|
||||||
|
|
||||||
# unregister the models (yes, models are just kept in multilevel dicts)
|
# unregister the models (yes, models are just kept in multilevel dicts)
|
||||||
for model in models:
|
for model in models:
|
||||||
|
Loading…
Reference in New Issue
Block a user