Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing templates #46

Merged
merged 10 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/python_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,19 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade wheel setuptools pip
python -m pip install --upgrade wheel setuptools==57 pip==24.0
pip install -U -r requirements.txt
pip install -U -r dev-requirements.txt

- name: Test with pytest
run: |
py.test

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v2
with:
name: coverage-myads
path: .coverage


coveralls:

needs: build
Expand All @@ -70,7 +69,7 @@ jobs:
python -m pip install --upgrade wheel setuptools pip
pip install coverage==5.2.1
pip install coveralls==2.2.0
- uses: actions/download-artifact@master
- uses: actions/download-artifact@v2
with:
name: coverage-myads

Expand Down
2 changes: 1 addition & 1 deletion myadsp/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class myADSTemplate(Email):
"""

msg_plain = """
SAO/NASA ADS: myADS Personal Notification Service Results
SAO ADS/SciX: myADS Personal Notification Service Results

{payload}
"""
Expand Down
19 changes: 16 additions & 3 deletions myadsp/templates/email.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,21 @@
<td align="center" valign="top" style="font-family:Arial;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="emailBody" style="">
<tr>
<td align="center" valign="center" background="https://ui.adsabs.harvard.edu/styles/img/background.jpg" style="width:100%; background-color: #150E35; padding: 10px;" >
<p><img src="https://ui.adsabs.harvard.edu/styles/img/ads_logo.png" alt="Astrophysics Data System" style="width: 50%; color: #ffffff; font-size: 34px; font-family: Arial;"/></p>
<td align="center" valign="top" id="m_4393282051944905389m_-5269006104307297584templateHeader" style="background:#222222 url(&quot;https://scixplorer.org/styles/img/newsletter-background.png&quot;) no-repeat center/cover;background-color:#222222;background-image:url(https://scixplorer.org/styles/img/newsletter-background.png);background-repeat:no-repeat;background-position:center;background-size:cover;border-top:0;border-bottom:0;padding-top:153px;padding-bottom:153px">

<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse:collapse;max-width:600px!important">
<tbody><tr>
<td valign="top" style="background:transparent none no-repeat center/cover;background-color:transparent;background-image:none;background-repeat:no-repeat;background-position:center;background-size:cover;border-top:0;border-bottom:0;padding-top:0;padding-bottom:0"></td>
</tr>
</tbody></table>

</td>

</tr>
<tr>
<td valign="top" style="padding: 80px; text-align: center;">
<img align="center" alt="ADS logo" src="https://scixplorer.org/styles/img/ads-logo-full-h.jpg" style="width: 43%; max-width: 43%; display: inline; vertical-align: bottom; float:left; padding-left: 15%;">
<img align="center" alt="Scix logo" src="https://scixplorer.org/styles/img/scix-logo-abbr-h.jpg" style="width: 26%; max-width: 26%; display: inline; vertical-align: bottom; padding-top: 10px; padding-right: 16%;">
</td>
</tr>
<tr>
Expand Down Expand Up @@ -86,7 +99,7 @@ <h3 style="margin-top: 0;margin-right: 0;margin-bottom: 10px;margin-left: 0;">my
<tr>
<td align="center" valign="top">
<p> This message was sent to {{ email_address }}. </p>
<p> &copy; SAO/NASA <a href="https://ui.adsabs.harvard.edu" style="text-decoration: underline; color: #999999">Astrophysics Data System</a> <br> 60 Garden Street <br> Cambridge, MA, USA</p>
<p> &copy; SAO <a href="https://ui.adsabs.harvard.edu" style="text-decoration: underline; color: #999999">Astrophysics Data System/Science Explorer</a> <br> 60 Garden Street <br> Cambridge, MA, USA</p>
</td>
</tr>
</table>
Expand Down
24 changes: 16 additions & 8 deletions myadsp/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,30 +579,38 @@ def test_get_first_author_formatted(self):
def test_payload_to_plain(self):

formatted_payload = utils.payload_to_plain(payload)

split_payload = formatted_payload.split('\n')
self.assertEqual(split_payload[0].strip(), 'Query 1 (https://ui.adsabs.harvard.edu/search/q=bibstem%3Aarxiv?utm_source=myads&utm_medium=email&utm_campaign=type:general&utm_term=123&utm_content=queryurl)')
self.assertEqual(split_payload[1].strip(), '"VizieR Online Data Catalog: Spectroscopy of M81 globular ' +
'clusters," Nantais, J and Huchra, J (2012yCat..51392620N)')

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[77])
self.assertEqual(split_payload[79].strip(),

self.assertIn(u'templateColumnContainer"', split_payload[87])


self.assertEqual(split_payload[92].strip(),
u'<h3><a href="https://ui.adsabs.harvard.edu/search/q=bibstem%3Aarxiv?utm_source=myads&amp;utm_medium=email&amp;utm_campaign=type:general&amp;utm_term=123&amp;utm_content=queryurl" title="" style="text-decoration: none; color: #000000; font-weight: bold;">Query 1</a></h3>')
self.assertIn(u'href="https://ui.adsabs.harvard.edu/abs/2012yCat..51392620N/abstract?utm_source=myads&amp;utm_medium=email&amp;utm_campaign=type:general&amp;utm_term=123&amp;utm_content=rank:1"', split_payload[98])


self.assertIn(u'href="https://ui.adsabs.harvard.edu/abs/2012yCat..51392620N/abstract?utm_source=myads&amp;utm_medium=email&amp;utm_campaign=type:general&amp;utm_term=123&amp;utm_content=rank:1"', split_payload[111])

formatted_payload = utils.payload_to_html(payload, col=2)

split_payload = formatted_payload.split('\n')

self.assertIn(u'class="leftColumnContent"', split_payload[77])
self.assertEqual(split_payload[79].strip(),
self.assertIn(u'class="leftColumnContent"', split_payload[90])


self.assertEqual(split_payload[92].strip(),
u'<h3><a href="https://ui.adsabs.harvard.edu/search/q=bibstem%3Aarxiv?utm_source=myads&amp;utm_medium=email&amp;utm_campaign=type:general&amp;utm_term=123&amp;utm_content=queryurl" title="" style="text-decoration: none; color: #000000; font-weight: bold;">Query 1</a></h3>')
self.assertIn(u'href="https://ui.adsabs.harvard.edu/abs/2012yCat..51392620N/abstract?utm_source=myads&amp;utm_medium=email&amp;utm_campaign=type:general&amp;utm_term=123&amp;utm_content=rank:1"', split_payload[98])

self.assertIn(u'href="https://ui.adsabs.harvard.edu/abs/2012yCat..51392620N/abstract?utm_source=myads&amp;utm_medium=email&amp;utm_campaign=type:general&amp;utm_term=123&amp;utm_content=rank:1"', split_payload[111])

formatted_payload = utils.payload_to_html(payload, col=3)
self.assertIsNone(formatted_payload)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ alembic==0.9.1
psycopg2==2.8.3
Jinja2==2.11.2
portalocker==1.7.1
markupsafe<=2.0.1
markupsafe<=2.0.1
3 changes: 2 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ def notifications_status_update(user_emails=None, active=False):
else:
arxiv_complete = False
try:
arxiv_complete = _arxiv_ingest_complete(sleep_delay=300,
arxiv_complete = _arxiv_ingest_complete(date=args.since_date,
sleep_delay=300,
sleep_timeout=config.get('SLEEP_TIMEOUT', 43200),
admin_email=args.admin_email)
except Exception as e:
Expand Down
Loading