prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Terminology is not updated when term units are updated
  the terminology stemmer listens to `submission.post_save` - but submissions are always `bulk_created` so it doesn't seem to get triggered
  
  </issue>
  <code>
  [start of pootle/apps/pootle_terminology/receivers.py]
  1 # -*- coding: utf-8 -*-
  2 #
  3 # Copyright (C) Pootle contributors.
  4 #
  5 # This file is a part of the Pootle project. It is distributed under the GPL3
  6 # or later license. See the LICENSE file for a copy of the license and the
  7 # AUTHORS file for copyright and authorship information.
  8 
  9 from django.db.models.signals import post_save
  10 from django.dispatch import receiver
  11 
  12 from pootle.core.delegate import terminology
  13 from pootle_statistics.models import Submission, SubmissionFields
  14 from pootle_store.constants import TRANSLATED
  15 from pootle_store.models import Unit
  16 
  17 
  18 @receiver(post_save, sender=Unit)
  19 def handle_unit_save(**kwargs):
  20     unit = kwargs["instance"]
  21     if not kwargs.get("created"):
  22         return
  23     if unit.state != TRANSLATED:
  24         return
  25     is_terminology = (
  26         unit.store.name.startswith("pootle-terminology")
  27         or (unit.store.translation_project.project.code
  28             == "terminology"))
  29     if not is_terminology:
  30         return
  31     terminology.get(Unit)(unit).stem()
  32 
  33 
  34 @receiver(post_save, sender=Submission)
  35 def handle_submission_save(**kwargs):
  36     sub = kwargs["instance"]
  37     if sub.type != SubmissionFields.TARGET:
  38         return
  39     unit = sub.unit
  40     if unit.state != TRANSLATED:
  41         return
  42     is_terminology = (
  43         unit.store.name.startswith("pootle-terminology")
  44         or (unit.store.translation_project.project.code
  45             == "terminology"))
  46     if not is_terminology:
  47         return
  48     terminology.get(Unit)(unit).stem()
  49
  [end of pootle/apps/pootle_terminology/receivers.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/pootle/apps/pootle_terminology/receivers.py b/pootle/apps/pootle_terminology/receivers.py
  --- a/pootle/apps/pootle_terminology/receivers.py
  +++ b/pootle/apps/pootle_terminology/receivers.py
  @@ -34,7 +34,7 @@
   @receiver(post_save, sender=Submission)
   def handle_submission_save(**kwargs):
       sub = kwargs["instance"]
  -    if sub.type != SubmissionFields.TARGET:
  +    if sub.field != SubmissionFields.TARGET:
           return
       unit = sub.unit
       if unit.state != TRANSLATED:
  
verification_info: {"golden_diff": "diff --git a/pootle/apps/pootle_terminology/receivers.py b/pootle/apps/pootle_terminology/receivers.py\n--- a/pootle/apps/pootle_terminology/receivers.py\n+++ b/pootle/apps/pootle_terminology/receivers.py\n@@ -34,7 +34,7 @@\n @receiver(post_save, sender=Submission)\n def handle_submission_save(**kwargs):\n     sub = kwargs[\"instance\"]\n-    if sub.type != SubmissionFields.TARGET:\n+    if sub.field != SubmissionFields.TARGET:\n         return\n     unit = sub.unit\n     if unit.state != TRANSLATED:\n", "issue": "Terminology is not updated when term units are updated\nthe terminology stemmer listens to `submission.post_save` - but submissions are always `bulk_created` so it doesn't seem to get triggered\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nfrom django.db.models.signals import post_save\nfrom django.dispatch import receiver\n\nfrom pootle.core.delegate import terminology\nfrom pootle_statistics.models import Submission, SubmissionFields\nfrom pootle_store.constants import TRANSLATED\nfrom pootle_store.models import Unit\n\n\n@receiver(post_save, sender=Unit)\ndef handle_unit_save(**kwargs):\n    unit = kwargs[\"instance\"]\n    if not kwargs.get(\"created\"):\n        return\n    if unit.state != TRANSLATED:\n        return\n    is_terminology = (\n        unit.store.name.startswith(\"pootle-terminology\")\n        or (unit.store.translation_project.project.code\n            == \"terminology\"))\n    if not is_terminology:\n        return\n    terminology.get(Unit)(unit).stem()\n\n\n@receiver(post_save, sender=Submission)\ndef handle_submission_save(**kwargs):\n    sub = kwargs[\"instance\"]\n    if sub.type != SubmissionFields.TARGET:\n        return\n    unit = sub.unit\n    if unit.state != TRANSLATED:\n        return\n    is_terminology = (\n        unit.store.name.startswith(\"pootle-terminology\")\n        or (unit.store.translation_project.project.code\n            == \"terminology\"))\n    if not is_terminology:\n        return\n    terminology.get(Unit)(unit).stem()\n", "path": "pootle/apps/pootle_terminology/receivers.py"}]}