Skip to content

Commit 0f045f3

Browse files
committed
Clean up build failure emails and title
1 parent 6bf81cd commit 0f045f3

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

readthedocs/projects/tasks.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -657,30 +657,35 @@ def send_notifications(version_pk, build_pk):
657657
build = Build.objects.get(pk=build_pk)
658658

659659
for hook in version.project.webhook_notifications.all():
660-
webhook_notification(version.project, build, hook.url)
660+
webhook_notification(version, build, hook.url)
661661
for email in version.project.emailhook_notifications.all().values_list('email', flat=True):
662-
email_notification(version.project, build, email)
662+
email_notification(version, build, email)
663663

664664

665-
def email_notification(project, build, email):
666-
log.debug(LOG_TEMPLATE.format(project=project.slug, version='',
665+
def email_notification(version, build, email):
666+
log.debug(LOG_TEMPLATE.format(project=version.project.slug, version=version.slug,
667667
msg='sending email to: %s' % email))
668-
context = {'project': project.name,
669-
'build_id': build.pk,
670-
'commit': build.commit[:8],
668+
context = {'version': version,
669+
'project': version.project,
670+
'build': build,
671671
'build_url': 'https://{0}{1}'.format(
672672
getattr(settings, 'PRODUCTION_DOMAIN', 'readthedocs.org'),
673673
build.get_absolute_url())}
674+
if build.commit:
675+
title = _('Failed: {project.name} ({commit})').format(commit=build.commit[:8], **context)
676+
else:
677+
title = _('Failed: {project.name} ({version.verbose_name})').format(**context)
678+
674679
send_email(
675680
email,
676-
_('Failed: {project} ({commit})').format(**context),
681+
title,
677682
template='projects/email/build_failed.txt',
678683
template_html='projects/email/build_failed.html',
679684
context=context
680685
)
681686

682687

683-
def webhook_notification(project, build, hook_url):
688+
def webhook_notification(version, build, hook_url):
684689
data = json.dumps({
685690
'name': project.name,
686691
'slug': project.slug,

readthedocs/templates/projects/email/build_failed.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
{% extends "core/email/common.html" %}
2+
23
{% block top-right %}
3-
{{ project }} build #{{ build_id }}
4+
{{ project.name }} build #{{ build.pk }}
5+
{% endblock %}
6+
7+
{% block salutation %}
8+
Build Failed for {{ project.name }} ({{ version.verbose_name }})
49
{% endblock %}
10+
511
{% block content %}
612
<p>
713
You can see what went wrong here:
814
</p>
915

1016
<p>
11-
<a href="{{ build_url }}">{{ project }} build #{{ build_id }}</a>
17+
<a href="{{ build_url }}">{{ project.name }} build #{{ build.pk }}</a>
1218
-&nbsp;<span style="color: #ff7040;">failed</a>
1319
</p>
1420

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{% extends "core/email/common.txt" %}
2+
{% block salutation %}Build Failed for {{ project.name }} ({{ version.verbose_name }}){% endblock %}
23
{% block content %}
4+
5+
6+
7+
38
You can see what went wrong here:
49
{{ build_url }}
510

611
If you have questions, a good place to start is the FAQ:
712
https://docs.readthedocs.org/en/latest/faq.html
13+
814
{% endblock %}

0 commit comments

Comments
 (0)