from .payu.forms import CardTokenForm
-class ScheduleForm(NewsletterForm, forms.ModelForm):
+class ScheduleForm(forms.ModelForm, NewsletterForm):
class Meta:
model = models.Schedule
fields = ['monthly', 'amount', 'email']
raise forms.ValidationError('Minimalna kwota to %d zł.' % club.min_amount)
return value
+ def save(self, *args, **kwargs):
+ NewsletterForm.save(self, *args, **kwargs)
+ return super().save(*args, **kwargs)
+
class PayUCardTokenForm(CardTokenForm):
def get_queryset(self, view):
if not newsletter:
return
- try:
- # multiple inheritance mode
- super(NewsletterForm, self).save(*args, **kwargs)
- except AttributeError:
- pass
if not (self.mailing or self.cleaned_data.get(self.mailing_field)):
return
email = self.cleaned_data[self.email_field]
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
import requests
+from django.conf import settings
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}."
+ )
}
MESSAGING_MIN_DAYS = 2
+
+NEWSLETTER_PHPLIST_SUBSCRIBE_URL = None