2021-11-26 02:49:40 +00:00
|
|
|
from builtins import object
|
2017-11-03 15:58:24 +00:00
|
|
|
from django.shortcuts import render
|
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):
|
2021-11-26 02:49:40 +00:00
|
|
|
class Meta(object):
|
2010-09-26 21:32:53 +00:00
|
|
|
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()
|
2017-11-03 15:58:24 +00:00
|
|
|
return render(request, 'contacts/subscribe_success.html', {'form': form.cleaned_data})
|
2010-09-26 21:32:53 +00:00
|
|
|
else:
|
|
|
|
form = ContactEntryForm()
|
|
|
|
|
2017-11-03 15:58:24 +00:00
|
|
|
return render(request, 'contacts/subscribe.html', {'form': form})
|