When a partner is moved from an access method to Bundle we do some processing in https://github.com/WikipediaLibrary/TWLight/blob/fe6369f1365ad8f53b630a009583ed3ba4811d7b/TWLight/users/signals.py#L72 to update authorizations accordingly.
When the partner is set to the waitlist status and is moved to Bundle, it creates duplicate Bundle authorizations for users. This shouldn't happen.
Steps to reproduce this bug
- Create and approve two applications for different partners
- Change both partners' status to Waitlistedor Not Available and authorization_method to Bundle
- Change only one partner's status to Available
- Log out of your account and then login again
- A repeated bundle authorization appears and the partner is repeated in the My Library UI. The query below returns duplicates for the partner you just changed to Available:
SELECT users_authorization.user_id, users_authorization_partners.partner_id, COUNT(users_authorization_partners.partner_id) AS auth_count FROM users_authorization_partners INNER JOIN resources_partner ON users_authorization_partners.partner_id = resources_partner.id INNER JOIN users_authorization ON users_authorization_partners.authorization_id = users_authorization.id WHERE resources_partner.authorization_method = 3 GROUP BY users_authorization.user_id, users_authorization_partners.partner_id HAVING auth_count > 1;