Background
There are a number of different authorization methods on the Library Card platform. The access codes method is for the case when we have individual voucher codes or login details that we assign to each editor. When an application is marked as sent, it becomes available in the Send interface for the coordinator to select an access code to assign to it.
We send users an email when their account is approved. We also send them an email when their application is marked as 'Sent'. In the case of access code applications, these two actions can happen very soon after each other - we already have the access codes so there's no need to send the user's details over to some external partner. We can approve their application, and then head over to the Send interface to assign access codes. Ideally, therefore, we should only send the user one email in the access codes case - when their application is marked Sent with the corresponding access code.
Right now, we're not doing that, and the Approved email is confusing. We attempted to consolidate our email sending by merging the logic for access codes with the LINK access method. In the LINK access method we have pre-written instructions for users which can be immediately sent in the Application-approved email. We made the mistake of attempting to do the same thing for access codes; but no access code has been assigned at the point where we send the approval email. As such, users currently receive a confusing email, which tells them to use the "above" access code (there is none) to login. They'll then shortly thereafter receive a separate email which tells them what their access code is.
First email example:
Thank you for applying for access to Ancestry resources through The Wikipedia Library. We are happy to inform you that your application has been approved. Log in with the credentials above at https://www.ancestry.com/. Upon logging in for the first time, please update your password to something more secure. You are welcome to change the username. You can view the collections you're authorized to access at My Library: https://wikipedialibrary.wmflabs.org/users/my_library/
Second email example:
Your approved application to Ancestry has now been finalised. Your access code or login details can be found below: Username: User Password: Password
We need to reorganise the logic for sending these emails so that when a user applies for an access code partner they only receive one email, when their application is marked as sent, that contains all the relevant information.
Application approved email: https://github.com/WikipediaLibrary/TWLight/blob/master/TWLight/emails/templates/emails/approval_notification-body-text.html
Access code sent email: https://github.com/WikipediaLibrary/TWLight/blob/master/TWLight/emails/templates/emails/access_code_email-body-text.html
Users receive user_instructions twice, and we tried to merge the logic for including the access codes, but did so poorly. The approval email is defined in https://github.com/WikipediaLibrary/TWLight/blob/master/TWLight/emails/tasks.py#L319, and get_user_instructions (https://github.com/WikipediaLibrary/TWLight/blob/7a21a98119900f16c028bf1d0db68995134672d2/TWLight/applications/models.py#L302) includes logic for this being a CODES partner.
Acceptance criteria
- When an application to an access code partner is approved, no email is sent.
- When an application to an access code partner is marked as sent, with a corresponding access code attached, an email should be sent.
- The latter email should contain both the access code and any user instructions for using it.