Skip to content

Commit

Permalink
Merge b2c0ae3 into 529ba06
Browse files Browse the repository at this point in the history
  • Loading branch information
nad2000 committed Dec 3, 2019
2 parents 529ba06 + b2c0ae3 commit 7c23773
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion orcid_hub/templates/email/funding_invitation.html
@@ -1,5 +1,5 @@
<h2 class="display-2">Authenticate your funding in your ORCID record</h2>
<p>{{org_name}} would like to write a funding information to your ORCID record</p>
<p>{{org_name}} would like to write funding information to your ORCID record</p>
<p>If you would like to allow this, or if you don't currently have an ORCID record but would like to <br/>
create one and have this funding information added to it, please click on the following link:</p>
<p><a href="{{ invitation_url }}">{{ invitation_url }}</a><p>
Expand Down
2 changes: 1 addition & 1 deletion orcid_hub/templates/email/funding_task_completed.html
Expand Up @@ -7,6 +7,6 @@ <h2 class="display-2">Funding Process Update</h2>
<p>You can export a json of the results by clicking this link:
<a href="{{export_url}}">{{export_url}}</a></p>

<p>If you've prefer the file in an alternative format, just visit the Hub and navigate to
<p>If you would prefer the file in an alternative format, just visit the Hub and navigate to
Affiliations&gt;Uploaded Tasks and view this task. From this page, you can select an export
from any of a wide range of data formats</p>
2 changes: 1 addition & 1 deletion orcid_hub/templates/email/peer_review_invitation.html
@@ -1,5 +1,5 @@
<h2 class="display-2">Authenticate your Peer Review in your ORCID record</h2>
<p>{{org_name}} would like to write a Peer Review information to your ORCID record</p>
<p>{{org_name}} would like to write your Peer Review activity to your ORCID record</p>
<p>If you would like to allow this, or if you don't currently have an ORCID record but would like to <br/>
create one and have this Peer Review information added to it, please click on the following link:</p>
<p><a href="{{ invitation_url }}">{{ invitation_url }}</a><p>
Expand Down
7 changes: 3 additions & 4 deletions orcid_hub/templates/email/researcher_invitation.html
@@ -1,10 +1,9 @@
<h2 class="display-2">Authenticate your affiliation in your ORCID record</h2>
<p>{{org_name}} would like to write an affiliation to the education/employment part of your ORCID record</p>
<p>{{org_name}} would like to write an affiliation to your ORCID record. An affiliation is one of the following: employment / education / qualification / invited position / distinction / membership / service. </p>
<p>If you would like to allow this, or if you don't currently have an ORCID record but would like to <br/>
create one and have this affilation added to it, please click on the following link:</p>
create one and have this affiliation added to it, please click on the following link:</p>
<p><a href="{{ invitation_url }}">{{ invitation_url }}</a><p>
Once you click this link, you'll be taken to ORCID to sign in to, or create, your ORCID record.
Once you've granted permission, you'll be automatically taken to the Hub.
Note no further action from you is needed.
In the next minute or so, the affiliation will be shown in your ORCID record with {{org_name}} as the source.
</p>
In the next minute or so, the affiliation will be shown in your ORCID record with {{org_name}} as the source.</p>
8 changes: 4 additions & 4 deletions orcid_hub/templates/email/resource_invitation.html
@@ -1,10 +1,10 @@
<h2 class="display-2">Authenticate your Research Resourece in your ORCID record</h2>
<p>{{org_name}} would like to write a Research Resourece information to your ORCID record</p>
<h2 class="display-2">Authenticate your Research Resource in your ORCID record</h2>
<p>{{org_name}} would like to write a Research Resource information to your ORCID record</p>
<p>If you would like to allow this, or if you don't currently have an ORCID record but would like to <br/>
create one and have this Research Resourece information added to it, please click on the following link:</p>
create one and have this Research Resource information added to it, please click on the following link:</p>
<p><a href="{{ invitation_url }}">{{ invitation_url }}</a><p>
Once you click this link, you'll be taken to ORCID to sign in to, or create, your ORCID record.
Once you've granted permission, you'll be automatically taken to the Hub.
Note no further action from you is needed.
In the next minute or so, the Research Resourece information will be shown in your ORCID record with {{org_name}} as the source.
In the next minute or so, the Research Resource information will be shown in your ORCID record with {{org_name}} as the source.
</p>
2 changes: 1 addition & 1 deletion orcid_hub/templates/email/task_completed.html
Expand Up @@ -8,6 +8,6 @@ <h2 class="display-2">{{ subject or "Affiliation Process Update" }}</h2>
<p>You can export a csv and/or JSON of the results with both ORCID iD and put codes by clicking this link:
<a href="{{export_url}}">{{export_url}}</a></p>

<p>If you've prefer the file in an alternative format, just visit the Hub and navigate to
<p>If you would prefer the file in an alternative format, just visit the Hub and navigate to
Tasks>Uploaded Tasks and view this task. From this page, you can select an export
from any of a wide range of data formats</p>
2 changes: 1 addition & 1 deletion orcid_hub/templates/email/task_expiration.html
Expand Up @@ -2,7 +2,7 @@ <h2 class="display-2">Batch Task Update</h2>

<p>Processing of uploaded batch process data file <strong>{{task.filename}}</strong>
with {{task.row_count}} uploaded at <strong>{{task.create_at|isodate}}</strong>
will expire in one week and will deleted form the database.
will expire in one week and will deleted from the database.
</p>
{% if error_count > 0 %}
There were {{error_count}} error(s).</p>
Expand Down
2 changes: 1 addition & 1 deletion orcid_hub/templates/email/work_task_completed.html
Expand Up @@ -7,6 +7,6 @@ <h2 class="display-2">{{task_name}} Process Update</h2>
<p>You can export a json of the results by clicking this link:
<a href="{{export_url}}">{{export_url}}</a></p>

<p>If you've prefer the file in an alternative format, just visit the Hub and navigate to
<p>If you would prefer the file in an alternative format, just visit the Hub and navigate to
Affiliations&gt;Uploaded Tasks and view this task. From this page, you can select an export
from any of a wide range of data formats</p>
11 changes: 7 additions & 4 deletions orcid_hub/utils.py
Expand Up @@ -2337,13 +2337,13 @@ def notify_about_update(user, event_type="UPDATED"):


@rq.job(timeout=300)
def invoke_webhook_handler(org_id,
def invoke_webhook_handler(org_id=None,
orcid=None,
created_at=None,
updated_at=None,
message=None,
event_type="UPDATED",
attempts=5):
attempts=5, *args, **kwargs):
"""Propagate 'updated' event to the organisation event handler URL."""
if not message:
url = app.config["ORCID_BASE_URL"] + orcid
Expand All @@ -2364,8 +2364,11 @@ def invoke_webhook_handler(org_id,
message["email"] = user.email
if user.eppn:
message["eppn"] = user.eppn

org = Organisation.get(id=org_id)
if org_id:
org = Organisation.get(id=org_id)
else:
org = User.select().where(User.orcid == orcid).first().organisation
org_id = org.id
url = org.webhook_url
if org.webhook_append_orcid:
if not url.endswith('/'):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_webhooks.py
Expand Up @@ -386,6 +386,10 @@ def test_webhook_invokation(client, mocker):
with pytest.raises(Exception):
utils.invoke_webhook_handler(org.id, attempts=1, message=message)

# Test backward compatibility
with pytest.raises(Exception):
utils.invoke_webhook_handler(orcid=user.orcid, attempts=2, message=message, legacy_kwarg="abc123")


def test_org_webhook_api(client, mocker):
"""Test Organisation webhooks."""
Expand Down

0 comments on commit 7c23773

Please sign in to comment.