prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  "Add missing languages" add-on not working
  ### Describe the issue
  
  I have enabled the "Add missing languages" add-on on https://hosted.weblate.org/projects/catima/. However, despite waiting over 24 hours as the documentation on https://docs.weblate.org/en/latest/admin/addons.html#addon-weblate-consistency-languages states, it has not put the different components of the same project in sync.
  
  This is most noticeable when comparing https://hosted.weblate.org/projects/catima/catima/ with https://hosted.weblate.org/projects/catima/android-debug/
  
  ### I already tried
  
  - [X] I've read and searched [the documentation](https://docs.weblate.org/).
  - [X] I've searched for similar issues in this repository.
  
  ### Steps to reproduce the behavior
  
  1. Enable the "Add missing languages" add-on in a project with multiple components where one component has less languages than the other
  2. Wait at least 24 hours as the add-on states
  
  ### Expected behavior
  
  All components have the same languages, missing languages on components get created
  
  ### Screenshots
  
  Android component:
  ![image](https://github.com/WeblateOrg/weblate/assets/1885159/bae7c490-381f-4e13-a025-97c0a1494c01)
  
  Android (Debug) component:
  ![image](https://github.com/WeblateOrg/weblate/assets/1885159/03230fe9-c0a4-44e6-9dbe-ced43868fb69)
  
  
  ### Exception traceback
  
  _No response_
  
  ### How do you run Weblate?
  
  weblate.org service
  
  ### Weblate versions
  
  _No response_
  
  ### Weblate deploy checks
  
  _No response_
  
  ### Additional context
  
  _No response_
  
  </issue>
  <code>
  [start of weblate/addons/consistency.py]
  1 # Copyright © Michal Čihař <michal@weblate.org>
  2 #
  3 # SPDX-License-Identifier: GPL-3.0-or-later
  4 
  5 from django.db.models import Q
  6 from django.utils.translation import gettext_lazy
  7 
  8 from weblate.addons.base import BaseAddon
  9 from weblate.addons.events import EVENT_DAILY, EVENT_POST_ADD
  10 from weblate.addons.tasks import language_consistency
  11 from weblate.lang.models import Language
  12 
  13 
  14 class LangaugeConsistencyAddon(BaseAddon):
  15     events = (EVENT_DAILY, EVENT_POST_ADD)
  16     name = "weblate.consistency.languages"
  17     verbose = gettext_lazy("Add missing languages")
  18     description = gettext_lazy(
  19         "Ensures a consistent set of languages is used for all components "
  20         "within a project."
  21     )
  22     icon = "language.svg"
  23     project_scope = True
  24 
  25     def daily(self, component):
  26         language_consistency.delay(
  27             component.project_id,
  28             list(
  29                 Language.objects.filter(
  30                     Q(translation__component=component) | Q(component=component)
  31                 ).values_list("pk", flat=True)
  32             ),
  33         )
  34 
  35     def post_add(self, translation):
  36         language_consistency.delay(
  37             translation.component.project_id,
  38             [translation.language_id],
  39         )
  40
  [end of weblate/addons/consistency.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/weblate/addons/consistency.py b/weblate/addons/consistency.py
  --- a/weblate/addons/consistency.py
  +++ b/weblate/addons/consistency.py
  @@ -2,13 +2,11 @@
   #
   # SPDX-License-Identifier: GPL-3.0-or-later
   
  -from django.db.models import Q
   from django.utils.translation import gettext_lazy
   
   from weblate.addons.base import BaseAddon
   from weblate.addons.events import EVENT_DAILY, EVENT_POST_ADD
   from weblate.addons.tasks import language_consistency
  -from weblate.lang.models import Language
   
   
   class LangaugeConsistencyAddon(BaseAddon):
  @@ -25,11 +23,7 @@
       def daily(self, component):
           language_consistency.delay(
               component.project_id,
  -            list(
  -                Language.objects.filter(
  -                    Q(translation__component=component) | Q(component=component)
  -                ).values_list("pk", flat=True)
  -            ),
  +            [language.id for language in component.project.languages],
           )
   
       def post_add(self, translation):
  
verification_info: {"golden_diff": "diff --git a/weblate/addons/consistency.py b/weblate/addons/consistency.py\n--- a/weblate/addons/consistency.py\n+++ b/weblate/addons/consistency.py\n@@ -2,13 +2,11 @@\n #\n # SPDX-License-Identifier: GPL-3.0-or-later\n \n-from django.db.models import Q\n from django.utils.translation import gettext_lazy\n \n from weblate.addons.base import BaseAddon\n from weblate.addons.events import EVENT_DAILY, EVENT_POST_ADD\n from weblate.addons.tasks import language_consistency\n-from weblate.lang.models import Language\n \n \n class LangaugeConsistencyAddon(BaseAddon):\n@@ -25,11 +23,7 @@\n     def daily(self, component):\n         language_consistency.delay(\n             component.project_id,\n-            list(\n-                Language.objects.filter(\n-                    Q(translation__component=component) | Q(component=component)\n-                ).values_list(\"pk\", flat=True)\n-            ),\n+            [language.id for language in component.project.languages],\n         )\n \n     def post_add(self, translation):\n", "issue": "\"Add missing languages\" add-on not working\n### Describe the issue\n\nI have enabled the \"Add missing languages\" add-on on https://hosted.weblate.org/projects/catima/. However, despite waiting over 24 hours as the documentation on https://docs.weblate.org/en/latest/admin/addons.html#addon-weblate-consistency-languages states, it has not put the different components of the same project in sync.\r\n\r\nThis is most noticeable when comparing https://hosted.weblate.org/projects/catima/catima/ with https://hosted.weblate.org/projects/catima/android-debug/\n\n### I already tried\n\n- [X] I've read and searched [the documentation](https://docs.weblate.org/).\n- [X] I've searched for similar issues in this repository.\n\n### Steps to reproduce the behavior\n\n1. Enable the \"Add missing languages\" add-on in a project with multiple components where one component has less languages than the other\r\n2. Wait at least 24 hours as the add-on states\n\n### Expected behavior\n\nAll components have the same languages, missing languages on components get created\n\n### Screenshots\n\nAndroid component:\r\n![image](https://github.com/WeblateOrg/weblate/assets/1885159/bae7c490-381f-4e13-a025-97c0a1494c01)\r\n\r\nAndroid (Debug) component:\r\n![image](https://github.com/WeblateOrg/weblate/assets/1885159/03230fe9-c0a4-44e6-9dbe-ced43868fb69)\r\n\n\n### Exception traceback\n\n_No response_\n\n### How do you run Weblate?\n\nweblate.org service\n\n### Weblate versions\n\n_No response_\n\n### Weblate deploy checks\n\n_No response_\n\n### Additional context\n\n_No response_\n", "before_files": [{"content": "# Copyright \u00a9 Michal \u010ciha\u0159 <michal@weblate.org>\n#\n# SPDX-License-Identifier: GPL-3.0-or-later\n\nfrom django.db.models import Q\nfrom django.utils.translation import gettext_lazy\n\nfrom weblate.addons.base import BaseAddon\nfrom weblate.addons.events import EVENT_DAILY, EVENT_POST_ADD\nfrom weblate.addons.tasks import language_consistency\nfrom weblate.lang.models import Language\n\n\nclass LangaugeConsistencyAddon(BaseAddon):\n    events = (EVENT_DAILY, EVENT_POST_ADD)\n    name = \"weblate.consistency.languages\"\n    verbose = gettext_lazy(\"Add missing languages\")\n    description = gettext_lazy(\n        \"Ensures a consistent set of languages is used for all components \"\n        \"within a project.\"\n    )\n    icon = \"language.svg\"\n    project_scope = True\n\n    def daily(self, component):\n        language_consistency.delay(\n            component.project_id,\n            list(\n                Language.objects.filter(\n                    Q(translation__component=component) | Q(component=component)\n                ).values_list(\"pk\", flat=True)\n            ),\n        )\n\n    def post_add(self, translation):\n        language_consistency.delay(\n            translation.component.project_id,\n            [translation.language_id],\n        )\n", "path": "weblate/addons/consistency.py"}]}