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

Add facility field changes to contributor notification emails #649

Merged
merged 4 commits into from Jul 12, 2019

Conversation

jwalgran
Copy link
Contributor

@jwalgran jwalgran commented Jul 4, 2019

Overview

Add a list of updated field values to contributor email notifications.

Connects #635

Testing Instructions

  • Claim a facility and approve the claim.
  • Browse the facility profile page at http://localhost:6543/claimed/{id}/ and change some fields:
    • Update Facility Name to "Changed Name"
    • Update Phone Number to "Changed Phone Number"
    • Turn OFF the Publicly Visible switch next to Phone Number
    • Update Website to "change.org"
  • Restart ./scripts/server to ensure that emails are displayed in the console.
  • Save the changes. Verify that the email printed to the console includes the following. (Verify both the plain text and HTML versions)
The following details have been changed:


  - Facility name: Changed Name
  - Facility website: change.org
  • Change all the field values on the form, turning on all publicly visible switches.
  • Save the form and verify that the email printed to the console shows all the field changes (Verify both the plain text and HTML versions)
The following details have been changed:


  - Description: Changed Description 2
  - Facility name: Changed Name 2
  - Address: Changed Address 2
  - Facility phone number: Changed Phone 2
  - Facility website: change-2.org
  - Minimum order quantity: Changed Quantity 2
  - Average lead time: Changed Lead 2
  - Contact person: Changed Contact 2
  - Contact email: changed-email@example.com
  - Office official name: Changed Office 2
  - Office address: Changed Office Address 2
  - Office country code: DM
  - Office phone number: Changed Office Phone 2
  - Parent company: Brand E

Checklist

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

@jwalgran jwalgran force-pushed the jcw/report-facility-changes branch 2 times, most recently from 9ec1543 to 1231cbb Compare July 9, 2019 18:44
@jwalgran jwalgran marked this pull request as ready for review July 9, 2019 18:56
@jwalgran jwalgran requested a review from kellyi July 9, 2019 18:56
@jwalgran
Copy link
Contributor Author

jwalgran commented Jul 9, 2019

This PR includes changing one instance of .update to .save which partially resolves #648.

@jwalgran jwalgran force-pushed the jcw/report-facility-changes branch from 1231cbb to 6e179ce Compare July 9, 2019 19:59
@kellyi
Copy link
Contributor

kellyi commented Jul 10, 2019

Heads up that there is a merge conflict in one of the email template files.

@jwalgran jwalgran force-pushed the jcw/report-facility-changes branch from 6e179ce to 6d1860f Compare July 10, 2019 14:46
@jwalgran
Copy link
Contributor Author

Rebased on develop and resolved the conflict.

help_text='A description of the facility')
verification_method = models.TextField(
null=False,
blank=True,
verbose_name='Verification method',
Copy link
Contributor

Choose a reason for hiding this comment

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

Very trivial but I just read that the Django doc recommend not capitalizing the first letter of these verbose name fields since Django will capitalize them as it needs: https://docs.djangoproject.com/en/2.2/topics/db/models/#verbose-field-names

However, if it doesn't matter feel free to ignore this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will update these to be consistent with the Django docs and your new fields in #650. I will also make the required update to make sure that we do the capitalization when preparing the email context object.

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 fixups 55bd009, 8932d49, and 227fd9a

'office_country_code',
'office_phone_number',
'parent_company',
)
Copy link
Contributor

Choose a reason for hiding this comment

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

#650 will have a few new fields to add to this list, but it should be easy to adjust.

Copy link
Contributor

@kellyi kellyi left a comment

Choose a reason for hiding this comment

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

👍 This is working well. If it's possible to wait on merging this, we could consider waiting to do so until #650 is in, which would save a lot of having to rebase migrations.

Screen Shot 2019-07-10 at 1 59 27 PM

@jwalgran
Copy link
Contributor Author

I agree, and will hold on this until #650 is done so I can incorporate the additional fields.

@jwalgran jwalgran force-pushed the jcw/report-facility-changes branch from 227fd9a to e8344a9 Compare July 11, 2019 17:58
We are adding these names to support sending emails that summarize the changes
made to a facility. We will only be reporting changes to some of these files,
but we are adding `verbose_name` to all of the fields for consistency.
When notifying contributors of changes to a facility profile made by an approved
claimant, we want to include a list of the values that were changed. This method
provides the raw data for creating that list and has several important features.

- Fields to be reported on are whitelisted to prevent the future addition of a
  private field from accidentally leaking to the public.
- There are field values conditionally restricted from public view and this
  method checks those conditions before reporting changes.
- One value is foreign key to `Contributor` and this method handles serializing
  it to a single string value by using the name of the contributor.
@jwalgran jwalgran force-pushed the jcw/report-facility-changes branch from e8344a9 to 73da0a6 Compare July 11, 2019 21:56
When notifying contributors when facility claimants change the profile of a
facility we want to include the specific public details that were changed.

The non-standard position of the `endfor` in the plain text email template is
intentional and ensures that extra blank lines are not included.

When capitalizing the verbose name, we are manually uppercasing the first letter
because Python's built-in `capitalize` method changes all characters but the
first to lower case, which is not what we want in the case of a verbose name
like "facility name in English."
@jwalgran jwalgran force-pushed the jcw/report-facility-changes branch from 73da0a6 to d62ba88 Compare July 12, 2019 15:40
@jwalgran
Copy link
Contributor Author

I retested this after rebasing and adding support for the new fields added in #650.

I changed all the fields on a claim but did not enable any switches. I got this expected list in the email:

- Description: change desc
- Facility name in English: change name
- Facility name in native language: change nâme native
- Address: change addres
- Minimum order quantity: change min
- Average lead time: change lead
- Facility workers count: 1
- Percentage of female workers: 1
- Facility type: Cut and Sew / RMG
- Parent company: Auditor A

I switched on the public fields and changed their values and got this expected list in the email:

- Facility phone number: change phone 2
- Facility website: change2.web
- Contact person: change contact 2
- Contact email: change.contact.2@email.com
- Office official name: change office 2
- Office address: change office address 2
- Office country code: AX
- Office phone number: change office phone 2

@jwalgran jwalgran changed the title Report facility changes Add facility fields changed to contributor notification emails Jul 12, 2019
@jwalgran jwalgran changed the title Add facility fields changed to contributor notification emails Add facility field changes to contributor notification emails Jul 12, 2019
@jwalgran
Copy link
Contributor Author

Thanks for the review. Will merge after CI passes.

@jwalgran jwalgran merged commit 4104c60 into develop Jul 12, 2019
@jwalgran jwalgran deleted the jcw/report-facility-changes branch July 12, 2019 15:53
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