Source

django-informativo / informativo / views.py

Full commit
from django.core.urlresolvers import reverse
from django.views import generic

from informativo import forms
from informativo import models


class SubscribeFormView(generic.edit.CreateView):
    form_class = forms.SubscribeForm
    template_name = 'informativo/subscribe_form.html'
    model = models.Contact

    def get_context_data(self, **kwargs):
        context = super(SubscribeFormView, self).get_context_data(**kwargs)
        context['unsubscribe_form'] = forms.UnsubscribeForm
        return context

    def get_success_url(self):
        return reverse('informativo-subscribed')


class SubscribedView(generic.base.TemplateView):
    template_name = 'informativo/subscribed.html'


class UnsubscribeFormView(generic.edit.FormView):
    form_class = forms.UnsubscribeForm
    template_name = 'informativo/unsubscribe_form.html'
    model = models.Contact

    def form_valid(form):
        response = super(UnsubscribeFormView, self).form_valid(form)
        self.unsubscribe(form.data)
        return response

    def get_success_url(self):
        return reverse('informativo-unsubscribed')

    def unsubscribe(form_data):
        pass #TODO


class UnsubscribedView(generic.base.TemplateView):
    template_name = 'informativo/unsubscribed.html'