# HG changeset patch # User Brian Neal # Date 1381973578 18000 # Node ID 0a8942306b04e5f94080e3262637b63022431fe2 # Parent e221c38edf40190611947cef53625d949611e914 Bootstrap work for mailing list page. Also corrected form cleaning logic if fields aren't provided. diff -r e221c38edf40 -r 0a8942306b04 email_list/forms.py --- a/email_list/forms.py Tue Oct 15 21:35:48 2013 -0500 +++ b/email_list/forms.py Wed Oct 16 20:32:58 2013 -0500 @@ -18,10 +18,20 @@ class SubscriberForm(forms.Form): - name = forms.CharField(max_length=64, required=False) - email = forms.EmailField() - location = forms.CharField(max_length=64, required=False) - option = forms.ChoiceField(choices=SUBSCRIBE_OPTS) + name = forms.CharField(required=False, + widget=forms.TextInput(attrs={ + 'class': 'form-control', + 'placeholder': 'Your name (optional)'})) + email = forms.EmailField(widget=forms.TextInput(attrs={ + 'class': 'form-control', + 'type': 'email', + 'placeholder': 'Your email address'})) + location = forms.CharField(required=False, + widget=forms.TextInput(attrs={ + 'class': 'form-control', + 'placeholder': 'City, State (optional)'})) + option = forms.ChoiceField(choices=SUBSCRIBE_OPTS, + widget=forms.Select(attrs={'class': 'form-control'})) def clean(self): """ @@ -29,16 +39,21 @@ a validation error if not. """ - email = self.cleaned_data['email'] + cleaned_data = super(SubscriberForm, self).clean() + email = cleaned_data.get('email') + option = cleaned_data.get('option') - if self.cleaned_data['option'] == 'sub': + if not email or not option: + return cleaned_data + + if option == 'sub': # is the user already subscribed (active)? try: subscriber = Subscriber.objects.get(email=email) except Subscriber.DoesNotExist: subscriber = Subscriber(email=email, - name=self.cleaned_data['name'], - location=self.cleaned_data['location']) + name=cleaned_data['name'], + location=cleaned_data['location']) else: if subscriber.is_active(): raise forms.ValidationError(ALREADY_SUBSCRIBED) @@ -52,7 +67,7 @@ # save the subscriber away for a future process() call self.subscriber = subscriber - return self.cleaned_data + return cleaned_data def is_subscribe(self): """ @@ -65,7 +80,7 @@ def process(self): """ Call this function if is_valid() returns True. It carries out the user's - subscription request. + subscription request. """ if self.is_subscribe(): @@ -121,8 +136,8 @@ email_template = 'email_list/email_unsubscribe.txt' msg = render_to_string(email_template, { - 'band': band, - 'url': url, + 'band': band, + 'url': url, 'band_domain': config['BAND_DOMAIN'], }) diff -r e221c38edf40 -r 0a8942306b04 madeira/templates/base.html --- a/madeira/templates/base.html Tue Oct 15 21:35:48 2013 -0500 +++ b/madeira/templates/base.html Wed Oct 16 20:32:58 2013 -0500 @@ -10,6 +10,7 @@ + {# block custom_css %}{% endblock #} @@ -70,16 +71,15 @@ -
+
Madeira Logo
-
+
{% block content %} {% endblock %} -