Mercurial > public > madeira
changeset 101:0a8942306b04
Bootstrap work for mailing list page.
Also corrected form cleaning logic if fields aren't provided.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 16 Oct 2013 20:32:58 -0500 |
parents | e221c38edf40 |
children | 91a229ee9a84 |
files | email_list/forms.py madeira/templates/base.html madeira/templates/email_list/subscribe_form.html static/css/theme.css |
diffstat | 4 files changed, 47 insertions(+), 331 deletions(-) [+] |
line wrap: on
line diff
--- 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'], })
--- 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 @@ <link href="{{ STATIC_URL }}bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen"> <link href="{{ STATIC_URL }}bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" media="screen"> +<link href="{{ STATIC_URL }}css/theme.css" rel="stylesheet" media="screen"> {# block custom_css %}{% endblock #} <link rel="shortcut icon" href="{{ STATIC_URL }}images/favicon.ico" /> </head> @@ -70,16 +71,15 @@ </div> </div> -<div class="jumbotron"> +<header> <div class="container"> <img src="{{ STATIC_URL }}images/header-logo.jpg" class="img-responsive" alt="Madeira Logo" /> </div> -</div> +</header> <div class="container"> {% block content %} {% endblock %} - <hr> <footer class="well well-lg"> <p class="text-right">
--- a/madeira/templates/email_list/subscribe_form.html Tue Oct 15 21:35:48 2013 -0500 +++ b/madeira/templates/email_list/subscribe_form.html Wed Oct 16 20:32:58 2013 -0500 @@ -4,21 +4,26 @@ <h1>Madeira Mailing List</h1> <p>Get on the Madeira mailing list to receive updates about upcoming shows, releases, and website updates. This is a low volume list. We do not share your email address with anyone.</p> -<fieldset><legend>Mailing List</legend> - <form method="post" action=".">{% csrf_token %} +<div class="row"> +<div class="col-md-8 col-md-offset-2"> +<fieldset><legend>Mailing List Subscription</legend> + <form method="post" action="." role="form">{% csrf_token %} {% if form.non_field_errors %} <div>{{ form.non_field_errors }}</div> {% endif %} - <table border="0" class="input-form"> {% for field in form %} - <tr> - <th>{{ field.label_tag }}{% if field.field.required %}*{% endif %}:</th> - <td>{{ field }} - {% if field.errors %}{{ field.errors }}{% endif %}</td> - </tr> + <div class="form-group"> + {{ field.label_tag }}{% if field.field.required %}*{% endif %}: + {% if field.errors %} + <div class="alert alert-danger">{{ field.errors }}</div> + {% endif %} + {{ field }} + </div> {% endfor %} - <tr><td><input type="submit" name="Submit" value="Submit" class="submit-button" /></td></tr> - </table> + <button type="submit" class="btn btn-default">Submit</button> + <p class="help-block">Fields marked with a * are required.</p> </form> </fieldset> +</div> +</div> {% endblock %}
--- a/static/css/theme.css Tue Oct 15 21:35:48 2013 -0500 +++ b/static/css/theme.css Wed Oct 16 20:32:58 2013 -0500 @@ -1,308 +1,4 @@ body { - font-family: arial, helvetica, sans-serif; - color: #EF7D21; - background-color: #213442; - font-size: 1.0em; + padding-top: 50px; + padding-bottom: 20px; } - -.centered { text-align: center; } - -a:link { - color: #6B969C; - text-decoration: none; -} - -a:visited { - color: #6B969C; - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -h1, h3 { - color: #EF7D21; -} - -h1 { - font: italic 32px georgia, 'times new roman', sans-serif; - margin: 0px; - padding: 0 0 10px 0; -} - -.headline1 { - font: italic 32px georgia, 'times new roman', sans-serif; - margin: 0px; - padding: 0 0 10px 0; -} - -h2 { - font: italic 20px verdana, tahoma, arial, sans-serif; - padding-top: 5px; - margin-top: 1.5em; - color: #6B969C; - border-top: solid 1px #6B969C; -} - -div.madeira-photo-list { - margin: 2em; - text-align: center; -} - -div.madeira-photo-list img { - border: thin dotted #6B969C; - padding: 2px; - margin: 5px; -} - -a.img-link:link { text-decoration: none; background-color: transparent; } -a.img-link:visited { text-decoration: none; background-color: transparent; } -a.img-link:hover { text-decoration: none; background-color: transparent; } - -.header { - margin-top: 10px; - margin-left: 5px; -} - -.photobkgnd { - margin: 3em; - z-index: 3; - background-color: #888888; - padding: 5px; -} - -.newsflash { - margin: 20px 1em; - border: 3px solid #6B969C; - padding: 5px; - background-color: #2e414f; - color: #EF7D21; -} - -/* -** f'in IE doesn't seem to honor my padding and the float doesn't work. -** solution: make an invisible border...lame. -** It's fine in Firefox. -*/ -.floatLeftBox { - /* padding: 0 1em 1em 0; I wish I could just use this */ - float: left; - border-right: 0.5em solid #213442; - border-bottom: 0.5em solid #213442; -} - -.clearMe { - clear: left; -} - -.cdCoverFloatList { - margin-left: 260px; - text-align: left; -} - -/* For internal links (within the same page) */ -.intLink { - margin-top: 2em; - font-size: small; -} - -label.normal { - width: 9em; - float: left; - text-align: right; - margin: 0 1em 10px 0; - clear: both; - font-weight: bold; -} - -.form-box { - color: black; - background: #ccc; - border-top: black solid 2px; - border-left: black solid 2px; - border-bottom: #eee solid 2px; - border-right: #eee solid 2px; - margin-bottom: 5px; -} - -.form-radio { - margin-left: 10em; -} - -.form-comment { - font-style: italic; - font-size: x-small; - margin-left: 10em; - margin-bottom: 10px; -} - -.submit-button { - color: black; - background: #6B969C; - border: 2px outset; - padding: 3px; -} - -table.input-form th { - vertical-align: top; -} - -ul.errorlist { - margin: 0 0 0 1em; - padding: 2px; -} -.errorlist li { - color: red; -} - -fieldset { - border: 1px solid teal; - margin-top: 2em; -} - -legend { - background: #6B969C; - color: black; - border: 1px solid black; - padding: 2px 12px 2px 12px; -} - -#footer { - clear: both; - list-style-type: none; - margin-top: 30px; - padding-top: 1em; - border-top: solid 1px #6B969C; - font-size: small; - font-style: italic; - text-align: right; -} - -#navleft ul { - margin: 0 0 0 0; - padding: 0 0 0 0; - font: 12px verdana, tahoma, arial, sans-serif; - font: bold 15px georgia, 'times new roman', sans-serif; - list-style-type: none; - display: inline; -} - -#navleft li { - margin: 0px 0 0; - display: inline; -} - -#navleft a { - display: block; - padding: 2px 2px 2px 10px; - border: 1px solid #000000; - background: #6B969C; - color: #EF7D21; - text-decoration: none; -} - -#navleft a:link, #navleft a:active, #navleft a:visited { - color: #213442; -} - -#navleft a:hover { - border: 1px solid #000000; - background: #213442 url(../images/brick.gif); - color: #213442; -} - -div.article-source { - font-style: italic; - padding-bottom: 2px; - margin-bottom: 5px; -} - -div.center-block { - margin: 10px 30px 10px 30px; - border: 1px solid #6B969C; - padding: 3px; -} - -div.center-block h2 { - font: italic 20px verdana, tahoma, arial, sans-serif; - padding-top: 1px; - margin-top: 1px; - color: #6B969C; - border-top: none; - text-align: center; -} - -div.thumb-box { - margin: 20px 1em; - border: 3px solid #6B969C; - padding: 5px; - background-color: #2e414f; - color: #EF7D21; -} - -div.thumb-box img { - border: thin dotted #6B969C; - padding: 2px; - margin: 5px; -} - -div.thumb-box h2 { - font: italic 20px verdana, tahoma, arial, sans-serif; - padding-top: 1px; - margin-top: 1px; - color: #6B969C; - border-top: none; - text-align: center; -} - -table {width:auto;} - -table.flyers { width: 100% } - -table.image-table { - display: inline; - margin: 0 5px 20px 0; -} - -table.image-table caption { - font-size: x-small; - caption-side: top; - text-align: center; - background-color: #213442; -} - -#slideshow { - width: 600px; - height: 200px; -} - -.quotes h2 { - font: italic 20px verdana, tahoma, arial, sans-serif; - padding-top: 0px; - margin-top: 0em; - color: #EF7D21; - border-top: none; -} -.quotes blockquote { - color: #EF7D21; - font-style: italic; - font-family:'Courier New', Courier, monospace; - padding:10px; -} -.quotes blockquote.odd { - border: 1px dotted #6B969C; - -moz-box-shadow: 3px 3px 4px #000; - -webkit-box-shadow: 3px 3px 4px #000; - box-shadow: 3px 3px 4px #000; - /* For IE 8 */ - -ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000')"; - /* For IE 5.5 - 7 */ - filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000'); -} -.quotes blockquote .citation { - font-style: normal; - font-size: smaller; - font-family: arial, helvetica, sans-serif; - padding:20px; -}