Adapt copyright copy to use current year, Add bank account info, Set the correct text on supporters page, HTML Form adapted to Django template, Create forms.py to have all forms, Create Contact Django Form View, Create a HTML template to contact email, Send contact email to info@digitalglarus.ch

This commit is contained in:
Levi 2016-04-07 00:26:50 -05:00
commit f667aae38e
12 changed files with 184 additions and 66 deletions

26
digitalglarus/forms.py Normal file
View file

@ -0,0 +1,26 @@
from django import forms
from .models import Message
from django.template.loader import render_to_string
from django.core.mail import EmailMultiAlternatives
class ContactUsForm(forms.ModelForm):
error_css_class = 'autofocus'
class Meta:
model = Message
fields = ['name', 'email', 'phone_number', 'message']
widgets = {
'name': forms.TextInput(attrs={'class': u'form-control'}),
'email': forms.TextInput(attrs={'class': u'form-control'}),
'phone_number': forms.TextInput(attrs={'class': u'form-control'}),
'message': forms.Textarea(attrs={'class': u'form-control'}),
}
def send_email(self):
text_content = render_to_string('emails/contact.txt', {'data': self.cleaned_data})
html_content = render_to_string('emails/contact.html', {'data': self.cleaned_data})
email = EmailMultiAlternatives('Subject', text_content)
email.attach_alternative(html_content, "text/html")
email.to = ['to@example.com']
email.send()