2010-09-26 21:32:53 +00:00
|
|
|
from django.shortcuts import render_to_response
|
2015-12-01 02:49:50 +00:00
|
|
|
from conservancy import context_processors as context_processors
|
|
|
|
from django.template import RequestContext
|
2010-09-26 21:32:53 +00:00
|
|
|
from django import forms
|
2015-03-09 01:16:33 +00:00
|
|
|
from conservancy.apps.contacts.models import ContactEntry
|
2010-09-26 21:32:53 +00:00
|
|
|
from django.forms import ModelForm
|
|
|
|
|
|
|
|
def subscribe(request):
|
|
|
|
"""Mailing list subscription form
|
|
|
|
"""
|
|
|
|
|
|
|
|
class ContactEntryForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = ContactEntry
|
|
|
|
|
2010-09-26 21:54:29 +00:00
|
|
|
ContactEntryForm.base_fields['subscribe_conservancy'].label = 'Receive Software Freedom Conservancy updates'
|
2010-09-26 21:32:53 +00:00
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
form = ContactEntryForm(request.POST)
|
|
|
|
if form.is_valid():
|
|
|
|
form.save()
|
|
|
|
return render_to_response('contacts/subscribe_success.html',
|
2015-12-01 02:49:50 +00:00
|
|
|
{'form': form.cleaned_data}, context_instance=RequestContext(request))
|
2010-09-26 21:32:53 +00:00
|
|
|
else:
|
|
|
|
form = ContactEntryForm()
|
|
|
|
|
|
|
|
return render_to_response('contacts/subscribe.html',
|
2015-12-01 02:49:50 +00:00
|
|
|
{'form': form}, context_instance=RequestContext(request))
|