Skip to content

Commit

Permalink
Fix new file mattermost notification format
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault committed Oct 7, 2024
1 parent a1befbc commit 547f0be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,5 @@
"DJANGO_ENVERGO_AMENAGEMENT_DOMAIN", default="envergo.beta.gouv.fr"
)
ENVERGO_HAIE_DOMAIN = env("DJANGO_ENVERGO_HAIE_DOMAIN", default="haie.beta.gouv.fr")

OPS_MATTERMOST_HANDLERS = env.list("DJANGO_OPS_MATTERMOST_HANDLERS", default=[])
18 changes: 12 additions & 6 deletions envergo/evaluations/management/commands/new_files_admin_alert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from datetime import timedelta
from itertools import groupby
from textwrap import dedent

from django.conf import settings
from django.core.management.base import BaseCommand
from django.db.models import F
from django.urls import reverse
Expand Down Expand Up @@ -35,10 +37,14 @@ def handle(self, *args, **options):
groups = groupby(files, key=lambda file: file.request)
for request, files in groups:
url = reverse("admin:evaluations_request_change", args=[request.id])
message = f"""
Une demande d'avis a été mise à jour.
Adresse : {request.address}
{len(list(files))} nouveaux fichiers ont été ajoutés.
[Admin django](https://envergo.beta.gouv.fr/{url})
"""
message = dedent(
f"""\
Une demande d'avis a été mise à jour.
Adresse : {request.address}
{len(list(files))} nouveaux fichiers ont été ajoutés.
[Admin django](https://envergo.beta.gouv.fr/{url})
ping {", ".join(settings.OPS_MATTERMOST_HANDLERS)}
"""
)
notify(message)

0 comments on commit 547f0be

Please sign in to comment.