1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.conf import settings
8 def subscribe(email, newsletter):
9 list_id = newsletter.phplist_id
12 "emailconfirm": email,
13 f"list[{list_id}]": "signup",
15 "subscribe": "Subscribe",
17 if settings.NEWSLETTER_PHPLIST_SUBSCRIBE_URL:
18 response = requests.post(
19 settings.NEWSLETTER_PHPLIST_SUBSCRIBE_URL,
22 response.raise_for_status()
24 print("Newsletter not configured, "
25 "NEWSLETTER_PHPLIST_SUBSCRIBE_URL not set. "
26 f"Trying to subscribe email: {email} to newsletter: {list_id}."