X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/64d26c022dc182339b33c3cd8e4ef1978b150573..0c502550a4f04aa016df8729af2ae2f85c0b495a:/src/newsletter/subscribe.py diff --git a/src/newsletter/subscribe.py b/src/newsletter/subscribe.py index d7a8a2795..16a27a793 100644 --- a/src/newsletter/subscribe.py +++ b/src/newsletter/subscribe.py @@ -2,6 +2,7 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # import requests +from django.conf import settings def subscribe(email, newsletter): @@ -13,9 +14,15 @@ def subscribe(email, newsletter): "htmlemail": 1, "subscribe": "Subscribe", } - response = requests.post( - 'https://mailing.mdrn.pl/?p=subscribe', - data=data, - ) - response.raise_for_status() + if settings.NEWSLETTER_PHPLIST_SUBSCRIBE_URL: + response = requests.post( + settings.NEWSLETTER_PHPLIST_SUBSCRIBE_URL, + data=data, + ) + response.raise_for_status() + else: + print("Newsletter not configured, " + "NEWSLETTER_PHPLIST_SUBSCRIBE_URL not set. " + f"Trying to subscribe email: {email} to newsletter: {list_id}." + )