marconius avatar marconius committed ba40f44 Draft

hard coded email verification into contact forms

Comments (0)

Files changed (3)

satchmo/apps/payment/views/contact.py

             #If a person has their contact info, make sure we populate it in the form
             for item in contact.__dict__.keys():
                 init_data[item] = getattr(contact,item)
+            if contact.email:
+                init_data['email2'] = contact.email
             if contact.shipping_address:
                 for item in contact.shipping_address.__dict__.keys():
                     init_data["ship_"+item] = getattr(contact.shipping_address,item)

satchmo/apps/satchmo_store/accounts/forms.py

 class RegistrationForm(forms.Form):
     """The basic account registration form."""
     title = forms.CharField(max_length=30, label=_('Title'), required=False)
+    email2 = forms.EmailField(label=_('Email address2'),
+        max_length=75, required=True)
     email = forms.EmailField(label=_('Email address'),
         max_length=75, required=True)
     password2 = forms.CharField(label=_('Password (again)'),
     def clean_email(self):
         """Prevent account hijacking by disallowing duplicate emails."""
         email = self.cleaned_data.get('email', None)
+        email2 = self.cleaned_data.get('email2', None)
         if email and User.objects.filter(email__iexact=email).count() > 0:
             raise forms.ValidationError(
                 ugettext("That email address is already in use."))
 
+        if email != email2 :
+            raise forms.ValidationError(
+                ugettext("Two emails do not match."))
         return email
 
     def save(self, request=None, force_new=False, **kwargs):

satchmo/apps/satchmo_store/contact/forms.py

 from django.db.models import Q
 from django.forms.extras.widgets import SelectDateWidget
 from django.utils.translation import ugettext_lazy as _, ugettext
+from django.contrib.localflavor.ca.forms import CAPhoneNumberField, CAPostalCodeField
 from l10n.models import Country
 from livesettings import config_value
 from satchmo_store.contact.models import Contact, AddressBook, PhoneNumber, Organization, ContactRole
         super(ProxyContactForm, self).__init__(*args, **kwargs)
 
 class ContactInfoForm(ProxyContactForm):
+    email2 = forms.EmailField(max_length=75, label=_('Email'), required=False)
     email = forms.EmailField(max_length=75, label=_('Email'), required=False)
     title = forms.CharField(max_length=30, label=_('Title'), required=False)
     first_name = forms.CharField(max_length=30, label=_('First Name'), required=False)
     last_name = forms.CharField(max_length=30, label=_('Last Name'), required=False)
-    phone = forms.CharField(max_length=30, label=_('Phone'), required=False)
+    phone = CAPhoneNumberField(label=_('Phone'), required=False)
     addressee = forms.CharField(max_length=61, label=_('Addressee'), required=False)
     organization = forms.CharField(max_length=50, label=_('Organization'), required=False)
     street1 = forms.CharField(max_length=30, label=_('Street'), required=False)
     def clean_email(self):
         """Prevent account hijacking by disallowing duplicate emails."""
         email = self.cleaned_data.get('email', None)
+        email2 = self.cleaned_data.get('email2', None)
+        if email2 and email != email2:
+            raise forms.ValidationError(
+                ugettext("The two email addresses do no match."))
         if self._contact:
             if self._contact.email and self._contact.email == email:
                 return email
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.