Email list contributors about facility claims #611
Conversation
eb5a93b
to
eb42bc4
Compare
Looking at this now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I manually tested both notification and verified that they worked correctly. I made a few suggestions and I opened a draft issue to cover opting out of these notifications (#614)
src/django/api/views.py
Outdated
@@ -1641,7 +1646,8 @@ def get_claimed_details(self, request, pk=None): | |||
) | |||
|
|||
updated_claim = FacilityClaim.objects.get(pk=pk) | |||
|
|||
send_claim_update_notice_to_list_contributors(request, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider wrapping this notification in a try block and posting the exception to Rollbar without raising. It may be confusing for the claimant to get a failure message after we successfully committed their change to the database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. This is in 8406351
I don't know the full range of exceptions that can get thrown when sending an email, so I just used except Exception
for the try/except blog. In order to be parsimonious about what data get sent to Rollbar I only logged the facility claim id, although I don't know what is included in sys.exc_info()
so it may be that that needs to go too.
src/django/api/views.py
Outdated
@@ -1473,6 +1475,9 @@ def approve_claim(self, request, pk=None): | |||
|
|||
send_claim_facility_approval_email(request, claim) | |||
|
|||
send_approved_claim_notice_to_list_contributors(request, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider wrapping this notification in a try block and posting the exception to Rollbar without raising. It may be confusing for the superuser to get a failure message after we successfully committed their approval to the database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. This is in 8406351
I don't know the full range of exceptions that can get thrown when sending an email, so I just used except Exception
for the try/except blog. In order to be parsimonious about what data get sent to Rollbar I only logged the facility claim id, although I don't know what is included in sys.exc_info()
so it may be that that needs to go too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1686,6 +1710,33 @@ def test_approved_facility_claim_info_is_in_details_response(self): | |||
|
|||
self.assertEqual(response_data['description'], 'new_description') | |||
|
|||
@override_switch('claim_a_facility', active=True) | |||
def test_updating_claim_profile_sends_email_to_contributor(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we include a test for update notification but exclude a test for approval notification for a specific reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, the approval test is there-is but it's really subtle and probably could be denotated more clearly. It is essentially this line, which checks that there are now 2 emails in the outbox on approval rather than just 1:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than creating a new test I revised the test here to adjust its name and to add a comment about len(mail.outbox) == 2
: 436301d
|
||
The facility is: | ||
|
||
- Facility: {{ facility_name }}, {{ facility_address }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider including the full facility country name in these notifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 0d3d6a2
</p> | ||
<ul> | ||
<li> | ||
Facility: {{ facility_name }}, {{ facility_address }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider including the full facility country name in these notifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this in 0d3d6a2 and also added the full country name to the previous set of facility claim emails.
</p> | ||
<ul> | ||
<li> | ||
Facility: {{ facility_name }}, {{ facility_address }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider including the full facility country name in these notifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this in 0d3d6a2 and also added the full country name to the previous set of facility claim emails.
|
||
The facility is: | ||
|
||
- Facility: {{ facility_name }}, {{ facility_address }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider including the full facility country name in these notifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I added this in 0d3d6a2 and also added the full country name to the previous set of facility claim emails.
eb42bc4
to
8406351
Compare
Looking at this now. |
src/django/api/views.py
Outdated
|
||
if ROLLBAR: | ||
import rollbar | ||
rollbar.report.exc_info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo. report.exc_info
-> report_exc_info
src/django/api/views.py
Outdated
@@ -1473,6 +1475,9 @@ def approve_claim(self, request, pk=None): | |||
|
|||
send_claim_facility_approval_email(request, claim) | |||
|
|||
send_approved_claim_notice_to_list_contributors(request, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo in the Rollbar exception reporting but the other changes look good.
Oops, thanks for catching that! I fixed this in af700d9 |
Thanks for all your help with this! I'm going to squash and then merge. |
- email list contributors when a facility claim is approved - email list contributors when an approved facility claim's profile details have been updated - add tests for contributor emails - catch exceptions thrown when trying to email contributors about facility claim approvals and profile changes, sending only the Facility Claim ID to Rollbar. Afterward, continue sending a response as usual.
af700d9
to
72ce805
Compare
Overview
details have been updated
Connects #578
Connects #577
Testing Instructions
Checklist
fixup!
commits have been squashed