misc: allow an "empty" value (single dash) for trace emails (#88841) #504

Merged
fpeters merged 1 commits from wip/88841-no-traces into main 2024-04-26 11:38:16 +02:00
3 changed files with 19 additions and 3 deletions

View File

@ -14,7 +14,8 @@ class Migration(migrations.Migration):
name='trace_emails',
field=models.TextField(
blank=True,
help_text='One address per line (empty for site administrators)',
help_text='One address per line (empty for site administrators), '
'a single dash "-" for no mail at all)',
verbose_name='Emails to receive error and critical traces',
),
),

View File

@ -734,7 +734,9 @@ class LoggingParameters(models.Model):
)
trace_emails = models.TextField(
verbose_name=_('Emails to receive error and critical traces'),
help_text=_('One address per line (empty for site administrators)'),
help_text=_(
'One address per line (empty for site administrators, a single dash "-" for no mail at all)'
),
blank=True,
)
requests_max_size = models.PositiveIntegerField(
@ -1072,7 +1074,9 @@ class ProxyLogger:
admins = settings.ADMINS
Outdated
Review

On veut laisser ça un peu caché, ou ajouter une petite mention dans le help_text ? Genre

-         help_text=_('One address per line (empty for site administrators)'),
+         help_text=_('One address per line (empty for site administrators, a single dash "-" for no mail at all)'),

En plus c'est mignon "-" ça fait un petit emoji tendance hello kitty ok bon.

On veut laisser ça un peu caché, ou ajouter une petite mention dans le help_text ? Genre ``` - help_text=_('One address per line (empty for site administrators)'), + help_text=_('One address per line (empty for site administrators, a single dash "-" for no mail at all)'), ``` En plus c'est mignon "-" ça fait un petit emoji tendance hello kitty ok bon.

J'ai ajouté cette note.

J'ai ajouté cette note.
logging_parameters = self.connector.logging_parameters
if logging_parameters.trace_emails:
if logging_parameters.trace_emails == '-':
admins = []
elif logging_parameters.trace_emails:
admins = [('', x) for x in logging_parameters.trace_emails.splitlines()]
with override_settings(ADMINS=admins):
getattr(self._logger, levelname.lower())(message, *args, **kwargs)

View File

@ -134,6 +134,17 @@ def test_trace_emails(app, settings, dummy_csv_datasource, email_handler, mailou
assert mailoutbox[0].to == ['admin@example.net']
assert mailoutbox[idx].to == ['john.doe@example.net']
logging_parameters.trace_emails = '-'
logging_parameters.save()
app.get(
generic_endpoint_url(
connector='csvdatasource', endpoint='query/dummy-query/', slug=dummy_csv_datasource.slug
),
status=500,
)
assert len(mailoutbox) == 2 # no new mail
def test_check_status_no_traceback_email(db, settings, email_handler, mailoutbox):
settings.ADMINS = [('admin', 'admin@example.net')]