check if you the plugins really need to be reloaded

This commit is contained in:
Matthias 2021-11-16 00:12:58 +01:00
parent 3b0a004d6e
commit 1794fb8865
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -9,10 +9,17 @@ import plugin.models as models
def plugin_update(queryset, new_status: bool): def plugin_update(queryset, new_status: bool):
"""general function for bulk changing plugins""" """general function for bulk changing plugins"""
apps_changed = False
# run through all plugins in the queryset as the save method needs to be overridden
for model in queryset: for model in queryset:
if model.active is not new_status:
model.active = new_status model.active = new_status
apps_changed = True
model.save(no_reload=True) model.save(no_reload=True)
# reload plugins if they changed
if apps_changed:
app = apps.get_app_config('plugin') app = apps.get_app_config('plugin')
app.reload_plugins() app.reload_plugins()