Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Email list contributors about facility claims #611

Merged
merged 1 commit into from Jun 19, 2019

Conversation

kellyi
Copy link
Contributor

@kellyi kellyi commented Jun 17, 2019

Overview

  • email list contributors when a facility claim is approved
  • email list contributors when an approved facility claim's profile
    details have been updated
  • update tests to check for facility claim emails to contributors

Connects #578
Connects #577

Testing Instructions

  • serve this branch with the default set of fixtures
  • sign in as c2@example.com and claim a facility
  • sign in as a superuser and approve the facility claim
  • verify that you see email/s to the facility list contributors for a facility that has been claimed
  • sign back in as c2@example.com
  • update the claimed facility profile and save, then verify that you see email/s to the facility list contributors for the facility that has had its claim updated

Checklist

  • fixup! commits have been squashed
  • CI passes after rebase
  • CHANGELOG.md updated with summary of features or fixes, following Keep a Changelog guidelines

@kellyi kellyi force-pushed the ki/claim-a-facility-email branch from eb5a93b to eb42bc4 Compare June 17, 2019 20:16
@kellyi kellyi changed the title WIP Email list contributors about facility claims Email list contributors about facility claims Jun 17, 2019
@kellyi kellyi marked this pull request as ready for review June 17, 2019 20:21
@kellyi kellyi requested a review from jwalgran June 17, 2019 20:21
@jwalgran
Copy link
Contributor

Looking at this now.

Copy link
Contributor

@jwalgran jwalgran left a 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)

@@ -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,
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@@ -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,
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This screenshot shows the arguments and local vars that are visible in rollbar when we submit the stack trace. These values are at the item level, not the occurrence level, so they are not deletable.

Firefox_Screenshot_2019-06-18T21-35-54 219Z

@@ -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):
Copy link
Contributor

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?

Copy link
Contributor Author

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:

https://github.com/open-apparel-registry/open-apparel-registry/pull/611/files#diff-a5f8ed705a64b1fe29a3eeb6439265d3R1406

Copy link
Contributor Author

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 }}
Copy link
Contributor

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.

Copy link
Contributor Author

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 }}
Copy link
Contributor

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.

Copy link
Contributor Author

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 }}
Copy link
Contributor

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.

Copy link
Contributor Author

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 }}
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@jwalgran jwalgran assigned kellyi and jwalgran and unassigned jwalgran Jun 17, 2019
@kellyi kellyi force-pushed the ki/claim-a-facility-email branch from eb42bc4 to 8406351 Compare June 18, 2019 14:14
@jwalgran
Copy link
Contributor

Looking at this now.


if ROLLBAR:
import rollbar
rollbar.report.exc_info(
Copy link
Contributor

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

@@ -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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This screenshot shows the arguments and local vars that are visible in rollbar when we submit the stack trace. These values are at the item level, not the occurrence level, so they are not deletable.

Firefox_Screenshot_2019-06-18T21-35-54 219Z

Copy link
Contributor

@jwalgran jwalgran left a 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.

@kellyi
Copy link
Contributor Author

kellyi commented Jun 18, 2019

There is a typo in the Rollbar exception reporting

Oops, thanks for catching that! I fixed this in af700d9

@jwalgran jwalgran removed their assignment Jun 18, 2019
@kellyi
Copy link
Contributor Author

kellyi commented Jun 19, 2019

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.
@kellyi kellyi force-pushed the ki/claim-a-facility-email branch from af700d9 to 72ce805 Compare June 19, 2019 00:35
@kellyi kellyi merged commit 9259935 into develop Jun 19, 2019
@kellyi kellyi deleted the ki/claim-a-facility-email branch June 19, 2019 00:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants