-
Notifications
You must be signed in to change notification settings - Fork 23
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
#2416: portfolio admin notification emails [BOB] #3441
Conversation
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
existing_invitations = PortfolioInvitation.objects.exclude( | ||
portfolio=user_portfolio_permission.portfolio | ||
).filter(email=user_portfolio_permission.user.email) | ||
existing_invitations = PortfolioInvitation.objects.filter(email=user_portfolio_permission.user.email).exclude( | ||
Q(portfolio=user_portfolio_permission.portfolio) | ||
| Q(status=PortfolioInvitation.PortfolioInvitationStatus.RETRIEVED) | ||
) |
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.
this fixes an undocumented bug where retrieved invitations were blocking creation of new invitations
existing_invitations = PortfolioInvitation.objects.exclude(id=portfolio_invitation.id).filter( | ||
email=portfolio_invitation.email | ||
existing_invitations = PortfolioInvitation.objects.filter(email=portfolio_invitation.email).exclude( | ||
Q(id=portfolio_invitation.id) | Q(status=PortfolioInvitation.PortfolioInvitationStatus.RETRIEVED) |
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.
this fixes an undocumented bug where retrieved invitations were blocking creation of new invitations
@dave-kennedy-ecs We're bundling the permission emails with the m5 design review next sprint (3281), so design will review these emails then. |
🥳 Successfully deployed to developer sandbox bob. |
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.
Thorough work overall. Just one small question.
@@ -1642,30 +1648,57 @@ def save_model(self, request, obj, form, change): | |||
Emails sent to requested user / email. | |||
When exceptions are raised, return without saving model. | |||
""" | |||
if not change: # Only send email if this is a new PortfolioInvitation (creation) | |||
try: |
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 like the way you moved the try statement up
): | ||
messages.warning( | ||
self.request, "Could not send email notification to existing organization admins." | ||
) |
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 could be missing something, but don't we need an else after this if-statement? Or does the function somehow terminate before setting the following success message?
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.
No, we don't need an else. In this case, we don't want to raise exceptions when email send attempts fail. But we want views to create messages. So, we are returning a pass/fail boolean from the send_email methods. If it fails, we want to raise a warning. Whether pass or fail, we want to continue after the method completes.
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.
lgtm
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
Ticket
Resolves #2416
Changes
Context for reviewers
Code Review Notes:
Email sending for both addition and removal notification emails is centralized in utility/email_invitations.py
Template files hold the email content
Logic for when to call which emails is in admin.py (for DJA) and views/portfolios.py
Exception handling is also in these views
Most other code is incidental or minor bug fixes
There are many tests!
Setup
Code Review Verification Steps
As the original developer, I have
Satisfied acceptance criteria and met development standards
Ensured code standards are met (Original Developer)
Validated user-facing changes (if applicable)
As a code reviewer, I have
Reviewed, tested, and left feedback about the changes
Validated user-facing changes as a developer
Note: Multiple code reviewers can share the checklists above, a second reviewer should not make a duplicate checklist. All checks should be checked before approving, even those labeled N/A.
As a designer reviewer, I have
Verified that the changes match the design intention
Validated user-facing changes as a designer
References
Screenshots