From ad416952ef98a99b98e7f13c8e41871239d74fcc Mon Sep 17 00:00:00 2001 From: Sergi Blanco-Cuaresma Date: Sat, 4 Jul 2020 21:52:47 -0400 Subject: [PATCH] More readable email format (#12) * More readable email format * Fixed unit test --- myadsp/templates/email.html | 34 +++++++------ myadsp/templates/one_col.html | 48 ++++++++++++++---- myadsp/templates/two_col.html | 94 +++++++++++++++++++++++++++-------- myadsp/tests/test_utils.py | 18 +++---- 4 files changed, 139 insertions(+), 55 deletions(-) diff --git a/myadsp/templates/email.html b/myadsp/templates/email.html index 78c8aed..1daefef 100644 --- a/myadsp/templates/email.html +++ b/myadsp/templates/email.html @@ -45,30 +45,36 @@ - +
- +
-
- +
+ - - + + + + -
- Astrophysics Data System + +

Astrophysics Data System

-

myADS Personal Notification Service

-

{{ frequency.capitalize() }} email ({{ date }})

+
+  
+

myADS - {{ frequency.capitalize() }} email ({{ date }})

+
{% block payload %} {% endblock payload %} +
- Search ADS   myADS settings  + + myADS notification settings
@@ -76,11 +82,11 @@

{

- +

This message was sent to {{ email_address }}.

-

© SAO/NASA Astrophysics Data System
60 Garden Street
Cambridge, MA, USA

+

© SAO/NASA Astrophysics Data System
60 Garden Street
Cambridge, MA, USA

@@ -91,4 +97,4 @@

{

- \ No newline at end of file + diff --git a/myadsp/templates/one_col.html b/myadsp/templates/one_col.html index ed24e2d..f791dbc 100644 --- a/myadsp/templates/one_col.html +++ b/myadsp/templates/one_col.html @@ -1,26 +1,52 @@ {% extends "email.html" %} {% block payload %} - +
- @@ -28,4 +54,4 @@

+ {% for p in payload %} -

{{ p.name }}

+

{{ p.name }}

{% if p.results|length > 0 %} + {% for r in p.results %} - {% if (r.bibstem[0] == 'arXiv') and ('arxiv_id' in r) %} -

{{ _get_title(r) }}

-

{{ _get_first_author_formatted(r, num_authors=3) }} ({{ r.arxiv_id }})

- {% else %} -

{{ _get_title(r) }}

-

{{ _get_first_author_formatted(r, num_authors=3) }} ({{ r.bibcode }})

- {% endif %} + + + + + + + + + + + + {% endfor %} +
+ + {% if (r.bibstem[0] == 'arXiv') and ('arxiv_id' in r) %} +

+ {{ r.bibcode }} +

+ {% else %} +

+ {{ r.bibcode }} +

+ {% endif %} +
+ +

{{ _get_title(r) }}

+
+ +

{{ _get_first_author_formatted(r, num_authors=1) }}

+

 

+
{% else %}

No new articles found

{% endif %} +

 

{% endfor %}
-{% endblock payload %} \ No newline at end of file +{% endblock payload %} diff --git a/myadsp/templates/two_col.html b/myadsp/templates/two_col.html index 3bf8a95..944c1a9 100644 --- a/myadsp/templates/two_col.html +++ b/myadsp/templates/two_col.html @@ -1,48 +1,102 @@ {% extends "email.html" %} {% block payload %} - +
- -
+ -
+ {% for p in left_payload %} -

{{ p.name }}

+

{{ p.name }}

{% if p.results|length > 0 %} + {% for r in p.results %} -

{{ _get_title(r) }}

- {% if (r.bibstem[0] == 'arXiv') and ('arxiv_id' in r) %} -

{{ _get_first_author_formatted(r, num_authors=1) }} ({{ r.arxiv_id }})

- {% else %} -

{{ _get_first_author_formatted(r, num_authors=1) }} ({{ r.bibcode}})

- {% endif %} + + + + + + + + + + + + {% endfor %} +
+ + {% if (r.bibstem[0] == 'arXiv') and ('arxiv_id' in r) %} +

+ {{ r.bibcode }} +

+ {% else %} +

+ {{ r.bibcode }} +

+ {% endif %} +
+ +

{{ _get_title(r) }}

+
+ +

{{ _get_first_author_formatted(r, num_authors=1) }}

+

 

+
{% else %}

No new articles found

{% endif %} +

 

{% endfor %}
+ - @@ -50,4 +104,4 @@

+ {% for p in right_payload %} -

{{ p.name }}

+

{{ p.name }}

{% if p.results|length > 0 %} + {% for r in p.results %} -

{{ _get_title(r) }}

- {% if (r.bibstem[0] == 'arXiv') and ('arxiv_id' in r) %} -

{{ _get_first_author_formatted(r, num_authors=1) }} ({{ r.arxiv_id }})

- {% else %} -

{{ _get_first_author_formatted(r, num_authors=1) }} ({{ r.bibcode}})

- {% endif %} + + + + + + + + + + + + {% endfor %} +
+ + {% if (r.bibstem[0] == 'arXiv') and ('arxiv_id' in r) %} +

+ {{ r.bibcode }} +

+ {% else %} +

+ {{ r.bibcode }} +

+ {% endif %} +
+ +

{{ _get_title(r) }}

+
+ +

{{ _get_first_author_formatted(r, num_authors=1) }}

+

 

+
{% else %}

No new articles found

{% endif %} +

 

{% endfor %}
-{% endblock payload %} \ No newline at end of file +{% endblock payload %} diff --git a/myadsp/tests/test_utils.py b/myadsp/tests/test_utils.py index b5f1faa..feddde3 100644 --- a/myadsp/tests/test_utils.py +++ b/myadsp/tests/test_utils.py @@ -566,21 +566,19 @@ def test_payload_to_html(self): formatted_payload = utils.payload_to_html(payload, col=1, email_address="test@tester.com") split_payload = formatted_payload.split('\n') - self.assertIn(u'templateColumnContainer"', split_payload[69]) - self.assertEqual(split_payload[74].strip(), - u'

Query 1

') - self.assertIn(u'href="https://ui.adsabs.harvard.edu/abs/2012yCat..51392620N/abstract?utm_source=myads&utm_medium=email&utm_campaign=type:general&utm_term=123&utm_content=rank:1"', split_payload[78]) + self.assertIn(u'templateColumnContainer"', split_payload[77]) + self.assertEqual(split_payload[79].strip(), + u'

Query 1

') + self.assertIn(u'href="https://ui.adsabs.harvard.edu/abs/2012yCat..51392620N/abstract?utm_source=myads&utm_medium=email&utm_campaign=type:general&utm_term=123&utm_content=rank:1"', split_payload[98]) formatted_payload = utils.payload_to_html(payload, col=2) split_payload = formatted_payload.split('\n') - self.assertIn(u'class="leftColumnContent"', split_payload[72]) - self.assertEqual(split_payload[74].strip(), - u'

Query 1

') - self.assertIn(u'href="https://ui.adsabs.harvard.edu/abs/2012yCat..51392620N/abstract?utm_source=myads&utm_medium=email&utm_campaign=type:general&utm_term=123&utm_content=rank:1"', split_payload[77]) + self.assertIn(u'class="leftColumnContent"', split_payload[77]) + self.assertEqual(split_payload[79].strip(), + u'

Query 1

') + self.assertIn(u'href="https://ui.adsabs.harvard.edu/abs/2012yCat..51392620N/abstract?utm_source=myads&utm_medium=email&utm_campaign=type:general&utm_term=123&utm_content=rank:1"', split_payload[98]) formatted_payload = utils.payload_to_html(payload, col=3) self.assertIsNone(formatted_payload)