diff options
author | lxf <sng@luxagraf.net> | 2021-10-28 20:50:06 -0400 |
---|---|---|
committer | lxf <sng@luxagraf.net> | 2021-10-28 20:50:06 -0400 |
commit | 774a6634865a67238837d1edde3a437d0dde8e16 (patch) | |
tree | 25a7cdbd368678abf6c869b76bddb4c81bd4d203 /app/lttr | |
parent | 4bff8bb3ba33dc0164a097c6dd06aa81dc59986b (diff) |
lttr: added a form for people to get postcards
Diffstat (limited to 'app/lttr')
-rw-r--r-- | app/lttr/forms.py | 9 | ||||
-rw-r--r-- | app/lttr/models.py | 12 | ||||
-rw-r--r-- | app/lttr/send.py | 6 | ||||
-rw-r--r-- | app/lttr/urls.py | 5 | ||||
-rw-r--r-- | app/lttr/views.py | 19 |
5 files changed, 48 insertions, 3 deletions
diff --git a/app/lttr/forms.py b/app/lttr/forms.py index e3fb272..5718d6e 100644 --- a/app/lttr/forms.py +++ b/app/lttr/forms.py @@ -2,7 +2,7 @@ from django import forms from django.forms.utils import ValidationError from .validators import validate_email_nouser -from .models import Subscriber +from .models import Subscriber, PostcardSubscriber class SubscribeForm(forms.ModelForm): @@ -98,3 +98,10 @@ class UpdateForm(NewsletterForm): user_activation_code = forms.CharField( label=("Activation code"), max_length=40 ) + + +class PostcardForm(forms.ModelForm): + + class Meta: + model = PostcardSubscriber + fields = ['name', 'address'] diff --git a/app/lttr/models.py b/app/lttr/models.py index 653eded..863d4e4 100644 --- a/app/lttr/models.py +++ b/app/lttr/models.py @@ -468,3 +468,15 @@ newsletter = Newsletter.objects.get(pk=3) n = SendShit(newsletter, mailing, 1) n.send_mailings() ''' + + +class PostcardSubscriber(models.Model): + """ A model for grabbing addresses to send postcards """ + date_created = models.DateTimeField(blank=True, auto_now_add=True, editable=False) + date_updated = models.DateTimeField(blank=True, auto_now=True, editable=False) + address = models.TextField() + name = models.CharField(max_length=120) + + def __str__(self): + return self.name + diff --git a/app/lttr/send.py b/app/lttr/send.py new file mode 100644 index 0000000..cd012e2 --- /dev/null +++ b/app/lttr/send.py @@ -0,0 +1,6 @@ +from lttr.models import Newsletter, NewsletterMailing +from lttr.mailer import SendShit +n = Newsletter.objects.get(pk=tk) +m = NewsletterMailing.objects.get(pk=tk) +s = SendShit(n, m) +s.send_mailings() diff --git a/app/lttr/urls.py b/app/lttr/urls.py index abeac11..d790f0f 100644 --- a/app/lttr/urls.py +++ b/app/lttr/urls.py @@ -6,6 +6,11 @@ app_name = "lttr" urlpatterns = [ path( + 'postcardsubscribe', + views.PostcardSubscribeView.as_view(), + name='postcard_subscribe' + ), + path( '<str:slug>/unsubscribe/<str:activation_code>', views.UnsubscribeRequestView.as_view(), name='newsletter_unsubscribe' diff --git a/app/lttr/views.py b/app/lttr/views.py index 3980fd4..c4414b2 100644 --- a/app/lttr/views.py +++ b/app/lttr/views.py @@ -13,8 +13,8 @@ from django.urls import reverse, reverse_lazy from utils.views import PaginatedListView, LuxDetailView from smtplib import SMTPException -from .models import OldNewsletterMailing, Subscriber, Newsletter -from .forms import SubscribeRequestForm, UpdateForm +from .models import OldNewsletterMailing, Subscriber, Newsletter, PostcardSubscriber +from .forms import SubscribeRequestForm, UpdateForm, PostcardForm ACTIONS = ('subscribe', 'unsubscribe', 'update') @@ -104,3 +104,18 @@ class UnsubscribeRequestView(DetailView): context['subscriber'] = self.get_object() context['newsletter'] = self.kwargs['slug'] return context + +class PostcardSubscribeView(CreateView): + """ + Return a subscribe form for iframe embedding + """ + model = PostcardSubscriber + form_class = PostcardForm + + + def get_template_names(self): + return ["lttr/%s_subscribe.html" % self.slug, 'lttr/subscribe.html'] + + def get_success_url(self): + return reverse_lazy('card:subscribed') + |