Commits

Anonymous committed 36e3398 Merge
  • Participants
  • Parent commits 48c6fbd, 9d62114

Comments (0)

Files changed (4)

 # About
 
 Cotidia Contact Form is a Django app that provides a generic contact form as a template tag.
+
+Please look into the docs folder for documentation.

contact_form/docs/settings.md

 ========
 
 	# Who should receive the contact enquiry, must be a python list
-	CONTACT_EMAIL_DELIVER_TO = ['info@example.com']
+	# Contact addresses are localised, 'en' being the default and mandatory local contact to provide
+	CONTACT_EMAIL_DELIVER_TO = {'en':['info@example.com']}
 
 	# The default subject line
 	CONTACT_SUBJECT = _('Contact enquiry')

contact_form/forms.py

 
 class ContactForm(forms.ModelForm):
     name = forms.CharField(label=_('Name'), error_messages={ 'required':_('Please enter your name')})
-    email = forms.EmailField(label=_('Email'), error_messages={'invalid': _('This email is not valid'), 'required':_('Please enter your email')})
+    email = forms.EmailField(label=_('Email'), error_messages={'invalid': _('This email is not valid'), 'required':_('Please enter your email')}, widget=forms.TextInput())
     tel = forms.CharField(label=_('Telephone'), error_messages={ 'required':_('Please enter your telephone number')}, required=False)
     message = forms.CharField(label=_('Message'), error_messages={ 'required':_('Please enter your message')}, widget=forms.Textarea(attrs={'rows':'3', }))
 

contact_form/templatetags/contact_form_tags.py

 from django import forms
 from django.core.mail import EmailMultiAlternatives
+from django.utils import translation
 from django.conf import settings
 from django import template
 register = template.Library()
 	form = ContactForm(initial=initial)
 	success = False
 
+	current_language = translation.get_language()
+
+	recipients = contact_form_settings.CONTACT_EMAIL_DELIVER_TO.get(current_language, contact_form_settings.CONTACT_EMAIL_DELIVER_TO['en'])
+
 	if request.method == 'POST':
 
 
 						subject=contact_form_settings.CONTACT_SUBJECT,
 						body=body,
 						from_email=form.cleaned_data['email'],
-						to=contact_form_settings.CONTACT_EMAIL_DELIVER_TO
+						to=recipients
 				)
 			msg.send()