Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Commit

Permalink
Rename date started to date created
Browse files Browse the repository at this point in the history
Summary: Fixes T33043

Test Plan: VM

Reviewers: kylec

Reviewed By: kylec

Subscribers: kylec, changesbot, dfb-reviews, reviews-dfbgrowth, christoffer

Maniphest Tasks: T33043

Differential Revision: https://tails.corp.dropbox.com/D93500
  • Loading branch information
kajic committed Mar 9, 2015
1 parent 46df8af commit 15f9ac4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
14 changes: 10 additions & 4 deletions changes/listeners/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,22 @@ def get_msg(self, context):
return msg

def get_subject(self, target, label, result):
# Use the first label line for multi line labels.
if label:
lines = label.splitlines()
if len(lines) > 1:
label = u"{}...".format(lines[0])

format_dict = {
'target': target,
'label': label,
'verb': str(result).lower(),
}

if target:
return "{target} {verb} - {label}".format(**format_dict)
return u"{target} {verb} - {label}".format(**format_dict)
else:
return "Build {verb} - {label}".format(**format_dict)
return u"Build {verb} - {label}".format(**format_dict)

def get_collection_context(self, builds):
"""
Expand Down Expand Up @@ -157,7 +163,7 @@ def sort_builds(builds_context):
build = builds[0]
target, target_uri = self.get_build_target(build)

date_started = min([_build.date_created for _build in builds])
date_created = min([_build.date_created for _build in builds])

return {
'title': self.get_subject(target, build.label, result),
Expand All @@ -166,7 +172,7 @@ def sort_builds(builds_context):
'target_uri': target_uri,
'target': target,
'label': build.label,
'date_started': date_started,
'date_created': date_created,
'author': build.author,
'commit_message': build.message or '',
'failing_tests_count': aggregate_count(builds_context, 'failing_tests_count'),
Expand Down
2 changes: 1 addition & 1 deletion templates/listeners/mail/notification.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
<pre class="patch-info">
<a href="{{ target_uri }}" class="dark-link">{% if target %}{{ target }}{% else %}Source{% endif %}: <span class="link-cue">{{ label }}</span></a>
Author: {{ author.name }} &lt;<a href="mailto:{{ author.email }}?subject={{ target }}: {{ label}}">{{ author.email }}</a>&gt;
{% if date_started %}Started: {{ date_started.strftime('%a %b %d %H:%M:%S %Y') }}{% endif %}
Created: {{ date_created.strftime('%a %b %d %H:%M:%S %Y') }}

{{
commit_message|break_long_lines(
Expand Down
2 changes: 1 addition & 1 deletion templates/listeners/mail/notification.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{label}}
{%- endif %}
Author: {{ author.name }} <{{ author.email }}>
{% if date_started %}Started: {{ date_started.strftime('%a %b %d %H:%M:%S %Y') }}{% endif %}
Created: {{ date_created.strftime('%a %b %d %H:%M:%S %Y') }}

{{
commit_message|break_long_lines(
Expand Down
21 changes: 21 additions & 0 deletions tests/changes/listeners/test_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@
from changes.testutils.cases import TestCase


class MailNotificationHandlerTestCase(TestCase):
def test_get_subject(self):
handler = MailNotificationHandler()

self.assertEqual(
'D123 passed - My \u00fcnicode diff',
handler.get_subject('D123', 'My \u00fcnicode diff', Result.passed),
)

self.assertEqual(
'Build passed - My \u00fcnicode diff',
handler.get_subject(None, 'My \u00fcnicode diff', Result.passed),
)

self.assertEqual(
'Build passed - My \u00fcnicode diff...',
handler.get_subject(
None, 'My \u00fcnicode diff\nwith many lines', Result.passed),
)


class FilterRecipientsTestCase(TestCase):
def test_simple(self):
results = filter_recipients(
Expand Down

0 comments on commit 15f9ac4

Please sign in to comment.