diff --git a/weblate/addons/models.py b/weblate/addons/models.py index 59fde44ce966..93a8c3aeb5bb 100644 --- a/weblate/addons/models.py +++ b/weblate/addons/models.py @@ -246,7 +246,7 @@ def execute_addon_event( with transaction.atomic(): scope.log_debug("running %s add-on: %s", event.label, addon.name) # Skip unsupported components silently - if addon.component and not addon.addon.can_install(component, None): + if not addon.component and not addon.addon.can_install(component, None): scope.log_debug( "Skipping incompatible %s add-on: %s for component: %s", event.label, @@ -272,7 +272,7 @@ def execute_addon_event( scope.log_error("failed %s add-on: %s: %s", event.label, addon.name, error) report_error(cause=f"add-on {addon.name} failed", project=component.project) # Uninstall no longer compatible add-ons - if not addon.addon.can_install(scope, None): + if not addon.addon.can_install(component, None): scope.log_warning( "uninstalling incompatible %s add-on: %s", event.label, addon.name ) diff --git a/weblate/addons/tests.py b/weblate/addons/tests.py index de8e61e32690..f6eaf600305b 100644 --- a/weblate/addons/tests.py +++ b/weblate/addons/tests.py @@ -1430,3 +1430,22 @@ def test_extract_broken(self) -> None: ) # The error should be there self.assertTrue(self.component.alert_set.filter(name="CDNAddonError").exists()) + + +class SiteWideAddonsTest(ViewTestCase): + def create_component(self): + return self.create_java() + + def test_json(self): + JSONCustomizeAddon.create( + configuration={"indent": 8, "sort": 1, "style": "spaces"}, + ) + # This is not needed in real life as installation will happen + # in a different request so local caching does not apply + self.component.drop_addons_cache() + rev = self.component.repository.last_revision + + self.edit_unit("Hello, world!\n", "Nazdar svete!\n") + self.get_translation().commit_pending("test", None) + + self.assertNotEqual(rev, self.component.repository.last_revision)