Skip to content
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

fix: move remaining emails to dotdigital #2295

Merged
merged 39 commits into from
May 3, 2024

Conversation

evemartin
Copy link
Contributor

@evemartin evemartin commented May 2, 2024

This PR includes the emails for when a teacher is released from school, when a user has already been registered with an email, and when a teacher is invited. There are two separate teacher invite emails, one for when the recipient already has an account and one for when they don't.


This change is Reviewable

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 8 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @evemartin)


portal/views/teacher/dashboard.py line 175 at r1 (raw file):

                )

                if account_exists:

You can simplify this.

  1. In one line, get the campaign ID you need depending on account_exists.
  2. Call send_dotdigital_email with the ID variable you created earlier

portal/views/teacher/dashboard.py line 604 at r1 (raw file):

        registration_link = f"{request.build_absolute_uri(reverse('invited_teacher', kwargs={'token': token}))} "

        if invite.is_expired:

Same here 🙂

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 5 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @evemartin)


portal/views/teacher/dashboard.py line 604 at r2 (raw file):

        campaign_id = (
            campaign_ids["invite_teacher_without_account"]
            if invite.is_expired

wait, I'm confused about this actually. Why does the invite type for a teacher with or without an account depend on whether the invite has expired? 🤔

Copy link
Contributor Author

@evemartin evemartin left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @faucomte97)


portal/views/teacher/dashboard.py line 175 at r1 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

You can simplify this.

  1. In one line, get the campaign ID you need depending on account_exists.
  2. Call send_dotdigital_email with the ID variable you created earlier

Thank you!! I've fixed this now :)


portal/views/teacher/dashboard.py line 604 at r1 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

Same here 🙂

Also fixed :)


portal/views/teacher/dashboard.py line 604 at r2 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

wait, I'm confused about this actually. Why does the invite type for a teacher with or without an account depend on whether the invite has expired? 🤔

To be honest, I'm not sure - originally I did it this way because the code snippet below is the way the check was before, where the not (invite.is_expired) gets used to determine which invite is sent later, but now that you bring it up I'm not sure why it's the case. The email being sent here is for resending an invite, does anything happen when an invite is sent to a teacher the first time?

Code snippet (i):

message = email_messages.inviteTeacherEmail(request, invite.school, token, not (invite.is_expired))

Code snippet (ii):

def inviteTeacherEmail(request, schoolName, token, account_exists):
    url = f"{request.build_absolute_uri(reverse('invited_teacher', kwargs={'token': token}))} "

    if account_exists:
        message = (
            f"A teacher at the school '{schoolName}' has invited you to join Code for Life. 🎉 Unfortunately, you "
            f"already have an account with this email address, so you will need to either delete it first or change "
            f"the email registered to your other account. After that, you can complete the registration process, by "
            f"following the link below.\n\n"
            f"{url}"
        )
    else:
        message = (
            f"A teacher at the school '{schoolName}' has invited you to join Code for Life. 🎉 To complete the "
            f"registration process, please create a password by following the link below.\n\n"
            f"{url}"
        )

    return {"subject": f"You've been invited to join Code for Life", "message": message}

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 5 files at r4, 3 of 3 files at r5, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @evemartin)


portal/tests/test_independent_student.py line 232 at r5 (raw file):


        page = self.go_to_homepage()
        page = page.go_to_signup_page()

You can combine these two lines

Code quote:

        page = self.go_to_homepage()
        page = page.go_to_signup_page()

portal/views/teacher/dashboard.py line 604 at r2 (raw file):

Previously, evemartin wrote…

To be honest, I'm not sure - originally I did it this way because the code snippet below is the way the check was before, where the not (invite.is_expired) gets used to determine which invite is sent later, but now that you bring it up I'm not sure why it's the case. The email being sent here is for resending an invite, does anything happen when an invite is sent to a teacher the first time?

I think there was a mistake with how this function was originally built.

  1. on line 594, the invite's expiry is reset to be in 30 days' time so beyond this point, is_expired is always going to be False.
  2. on line 596, the code gets a teacher variable which isn't used anywhere.
  3. I think what was meant to happen is simply that, instead using invite.is_expired which doesn't make sense, the campaign ID should be gotten depending on teacher.exists(), which then means the teacher variable gets used in the code.

Copy link
Contributor Author

@evemartin evemartin left a comment

Choose a reason for hiding this comment

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

Reviewable status: 7 of 10 files reviewed, 2 unresolved discussions (waiting on @faucomte97)


portal/tests/test_independent_student.py line 232 at r5 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

You can combine these two lines

I've fixed this in the latest push!!


portal/views/teacher/dashboard.py line 604 at r2 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

I think there was a mistake with how this function was originally built.

  1. on line 594, the invite's expiry is reset to be in 30 days' time so beyond this point, is_expired is always going to be False.
  2. on line 596, the code gets a teacher variable which isn't used anywhere.
  3. I think what was meant to happen is simply that, instead using invite.is_expired which doesn't make sense, the campaign ID should be gotten depending on teacher.exists(), which then means the teacher variable gets used in the code.

That makes much more sense, I have also fixed this in the latest push!

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @evemartin)

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @evemartin)

@faucomte97 faucomte97 merged commit 3abb334 into master May 3, 2024
5 checks passed
@faucomte97 faucomte97 deleted the move-remaining-emails-to-dotdigital branch May 3, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants