We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Exclusão Tramitação - status de tramitação
Ao incluir uma tramitação à matéria, em que esta tramitação tenha seu indicador de tramitação definido nas tabelas auxiliares como fim, a matéria em questão passa de "em tramitação - sim para não" corretamente. Se essa tramitação por ventura for excluída, não seria o caso de alterar novamente a matéria de "em tramitação - não para sim" ?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sapl/materia/receivers.py`
Content:
```
1 from django.dispatch import receiver
2 
3 from sapl.materia.signals import tramitacao_signal
4 from sapl.utils import get_base_url
5 
6 from .email_utils import do_envia_email_tramitacao
7 
8 
9 @receiver(tramitacao_signal)
10 def handle_tramitacao_signal(sender, **kwargs):
11     tramitacao = kwargs.get("post")
12     request = kwargs.get("request")
13     materia = tramitacao.materia
14 
15     do_envia_email_tramitacao(
16         get_base_url(request),
17         materia,
18         tramitacao.status,
19         tramitacao.unidade_tramitacao_destino)
20
```

Path: `sapl/materia/apps.py`
Content:
```
1 from django import apps
2 from django.utils.translation import ugettext_lazy as _
3 
4 
5 class AppConfig(apps.AppConfig):
6     name = 'sapl.materia'
7     label = 'materia'
8     verbose_name = _('Matéria')
9
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/sapl/materia/apps.py b/sapl/materia/apps.py
--- a/sapl/materia/apps.py
+++ b/sapl/materia/apps.py
@@ -6,3 +6,6 @@
     name = 'sapl.materia'
     label = 'materia'
     verbose_name = _('Matéria')
+
+    def ready(self):
+        from . import receivers
\ No newline at end of file
diff --git a/sapl/materia/receivers.py b/sapl/materia/receivers.py
--- a/sapl/materia/receivers.py
+++ b/sapl/materia/receivers.py
@@ -1,5 +1,7 @@
+from django.db.models.signals import post_delete, post_save
 from django.dispatch import receiver
 
+from sapl.materia.models import Tramitacao
 from sapl.materia.signals import tramitacao_signal
 from sapl.utils import get_base_url
 
@@ -17,3 +19,11 @@
         materia,
         tramitacao.status,
         tramitacao.unidade_tramitacao_destino)
+
+
+@receiver(post_delete, sender=Tramitacao)
+def status_tramitacao_materia(sender, instance, **kwargs):
+    if instance.turno == 'F':
+        materia = instance.materia
+        materia.em_tramitacao = True
+        materia.save()

{"golden_diff": "diff --git a/sapl/materia/apps.py b/sapl/materia/apps.py\n--- a/sapl/materia/apps.py\n+++ b/sapl/materia/apps.py\n@@ -6,3 +6,6 @@\n     name = 'sapl.materia'\n     label = 'materia'\n     verbose_name = _('Mat\u00e9ria')\n+\n+    def ready(self):\n+        from . import receivers\n\\ No newline at end of file\ndiff --git a/sapl/materia/receivers.py b/sapl/materia/receivers.py\n--- a/sapl/materia/receivers.py\n+++ b/sapl/materia/receivers.py\n@@ -1,5 +1,7 @@\n+from django.db.models.signals import post_delete, post_save\n from django.dispatch import receiver\n \n+from sapl.materia.models import Tramitacao\n from sapl.materia.signals import tramitacao_signal\n from sapl.utils import get_base_url\n \n@@ -17,3 +19,11 @@\n         materia,\n         tramitacao.status,\n         tramitacao.unidade_tramitacao_destino)\n+\n+\n+@receiver(post_delete, sender=Tramitacao)\n+def status_tramitacao_materia(sender, instance, **kwargs):\n+    if instance.turno == 'F':\n+        materia = instance.materia\n+        materia.em_tramitacao = True\n+        materia.save()\n", "issue": "Exclus\u00e3o Tramita\u00e7\u00e3o - status de tramita\u00e7\u00e3o\nAo incluir uma tramita\u00e7\u00e3o \u00e0 mat\u00e9ria, em que esta tramita\u00e7\u00e3o tenha seu indicador de tramita\u00e7\u00e3o definido nas tabelas auxiliares como fim, a mat\u00e9ria em quest\u00e3o passa de \"em tramita\u00e7\u00e3o - sim para n\u00e3o\" corretamente. Se essa tramita\u00e7\u00e3o por ventura for exclu\u00edda, n\u00e3o seria o caso de alterar novamente a mat\u00e9ria de \"em tramita\u00e7\u00e3o - n\u00e3o para sim\" ?\n", "before_files": [{"content": "from django.dispatch import receiver\n\nfrom sapl.materia.signals import tramitacao_signal\nfrom sapl.utils import get_base_url\n\nfrom .email_utils import do_envia_email_tramitacao\n\n\n@receiver(tramitacao_signal)\ndef handle_tramitacao_signal(sender, **kwargs):\n    tramitacao = kwargs.get(\"post\")\n    request = kwargs.get(\"request\")\n    materia = tramitacao.materia\n\n    do_envia_email_tramitacao(\n        get_base_url(request),\n        materia,\n        tramitacao.status,\n        tramitacao.unidade_tramitacao_destino)\n", "path": "sapl/materia/receivers.py"}, {"content": "from django import apps\nfrom django.utils.translation import ugettext_lazy as _\n\n\nclass AppConfig(apps.AppConfig):\n    name = 'sapl.materia'\n    label = 'materia'\n    verbose_name = _('Mat\u00e9ria')\n", "path": "sapl/materia/apps.py"}], "after_files": [{"content": "from django.db.models.signals import post_delete, post_save\nfrom django.dispatch import receiver\n\nfrom sapl.materia.models import Tramitacao\nfrom sapl.materia.signals import tramitacao_signal\nfrom sapl.utils import get_base_url\n\nfrom .email_utils import do_envia_email_tramitacao\n\n\n@receiver(tramitacao_signal)\ndef handle_tramitacao_signal(sender, **kwargs):\n    tramitacao = kwargs.get(\"post\")\n    request = kwargs.get(\"request\")\n    materia = tramitacao.materia\n\n    do_envia_email_tramitacao(\n        get_base_url(request),\n        materia,\n        tramitacao.status,\n        tramitacao.unidade_tramitacao_destino)\n\n\n@receiver(post_delete, sender=Tramitacao)\ndef status_tramitacao_materia(sender, instance, **kwargs):\n    if instance.turno == 'F':\n        materia = instance.materia\n        materia.em_tramitacao = True\n        materia.save()\n", "path": "sapl/materia/receivers.py"}, {"content": "from django import apps\nfrom django.utils.translation import ugettext_lazy as _\n\n\nclass AppConfig(apps.AppConfig):\n    name = 'sapl.materia'\n    label = 'materia'\n    verbose_name = _('Mat\u00e9ria')\n\n    def ready(self):\n        from . import receivers", "path": "sapl/materia/apps.py"}]}