feat: Handle incoming user confirmation for newsletter subscription
After a user confirms their intent to subscribe to the Tor newsletter, the donate site must handle that confirmation by performing a few actions:
- Retrieving the token from the URL params
- Using that token as a key to retrieve data from Redis, should it still exist
- Deserializing the data and ensuring it still unpacks into a JSON object that can be parsed as a dict, containing "first_name", "last_name", and "email_address" keys
- Passing off that data to Resque to be sent to CiviCRM
- Iterating the subscriber counter upwards
- Redirecting the user to an appropriate thank-you page - or, in the event that any of the prior steps encountered an error, serving them a Tor newsletter signup form instead
The purpose of this MR is to extend the CiviCRM repository with this functionality. (Note that the contents and functionality of the signup form are intended to be fulfilled by a near-future MR of its own, and so are not included with this commit. Instead, a stub page is included for functional purposes.)
This commit contains nearly all of the content which this MR is intended to contain:
-
tordonate/urls.py
was created andurlpatterns
expanded to hold three routes -/confirm-subscription
, for incoming traffic from newsletter-signup confirmation email,/subscribed/
, for users who successfully authenticate their confirmation by passing a valid token, and/subscribe/
, for users whose link doesn't work for one reason or another. -
tordonate/views.py
was created and expanded to serve three views: Two straightforward template-serving views for/subscribed/
and/subscribe/
, andconfirm_subscription()
, which simply serves the HttpRequest returned byCivicrmRepositoryProtocol.confirm_subscription
. -
tordonate/repository.py
has been expanded to containconfirm_subscription()
, which handles all of the logic described in the above numbered list, with the exception of #5 (closed). - The templates
subscribed.html.jinja
andsubscribe.html.jinja
have been created. -
tordonate/urls.py
was extended to includecivicrm
routes. -
tordonate/apps.py
was modified to accomodate the DI occurring in CiviCRM'sviews.py
.