1. Guillaume Piot
  2. Cotidia Social Share

Commits

Guillaume Piot  committed f8bcb79

Updated bits

  • Participants
  • Parent commits 55bbc2c
  • Branches master

Comments (0)

Files changed (3)

File README.md

View file
 
 	url(r'^share/', include('socialshare.urls', namespace='socialshare')),
 
+Javascript:
+
+The form submission requires the AJAX form Jquery plugin: http://malsup.github.io/min/jquery.form.min.js
+
 The html:
 
 	<a href="http://example.com/page-to-share" class="socialshare email">Share by email</a>

File socialshare/forms.py

View file
 from django.utils.translation import ugettext_lazy as _
 
 class ShareEmailForm(forms.Form):
-	url = forms.URLField(widget=forms.TextInput(attrs={'style':'width:97%', 'readonly':True}))
-	sender_name = forms.CharField(label=_('You'), max_length=50, widget=forms.TextInput(attrs={'placeholder':_('Name')}), error_messages={'required':_('Please enter your name')})
-	sender_email = forms.CharField(label=_('Your email address'), max_length=50, widget=forms.TextInput(attrs={'placeholder':_('Email address')}), error_messages={'required':_('Please enter your email address')})
-	friend_name = forms.CharField(label=_('Your friend'), max_length=50, widget=forms.TextInput(attrs={'placeholder':_('Name')}), error_messages={'required':_('Please enter your friend\'s name')})
-	friend_email = forms.EmailField(label=_('Your friend\'s email address'), max_length=100, widget=forms.TextInput(attrs={'placeholder':_('Email address')}), error_messages={'required':_('Please enter your friend\'s email address')})
+	url = forms.URLField(widget=forms.TextInput(attrs={'style':'width:100%', 'readonly':True, 'class':"form-control"}))
+	sender_name = forms.CharField(label=_('You'), max_length=50, widget=forms.TextInput(attrs={'placeholder':_('Name'), 'class':"form-control"}), error_messages={'required':_('Please enter your name')})
+	sender_email = forms.CharField(label=_('Your email address'), max_length=50, widget=forms.TextInput(attrs={'placeholder':_('Email address'), 'class':"form-control"}), error_messages={'required':_('Please enter your email address')})
+	friend_name = forms.CharField(label=_('Your friend'), max_length=50, widget=forms.TextInput(attrs={'placeholder':_('Name'), 'class':"form-control"}), error_messages={'required':_('Please enter your friend\'s name')})
+	friend_email = forms.EmailField(label=_('Your friend\'s email address'), max_length=100, widget=forms.TextInput(attrs={'placeholder':_('Email address'), 'class':"form-control"}), error_messages={'required':_('Please enter your friend\'s email address')})

File socialshare/views.py

View file
 			text_content = render_to_string('email/share_email.txt', context)
 			html_content = render_to_string('email/share_email.html', context)
 
-			msg = EmailMultiAlternatives(subject, text_content, sender_email, [friend_email])
+			msg = EmailMultiAlternatives(subject, text_content, '%s <%s>' % (sender_name, sender_email), [friend_email])
 			msg.attach_alternative(html_content, "text/html")
 			msg.send()