Created reset password email, Added forgot password view, Added forgot password form, Added set new password form, Added set new password view, fixed signup response issue, fixed main menu ungleich button redirect to django-hosting

This commit is contained in:
Levi 2016-06-21 00:10:38 -05:00
commit d8150b6593
13 changed files with 235 additions and 20 deletions

View file

@ -3,9 +3,52 @@ from .models import ContactMessage, BillingAddress
from django.template.loader import render_to_string
from django.core.mail import EmailMultiAlternatives
from django.utils.translation import ugettext_lazy as _
from membership.models import CustomUser
# from utils.fields import CountryField
class PasswordResetRequestForm(forms.Form):
email = forms.CharField(widget=forms.EmailInput())
class Meta:
fields = ['email']
def clean_email(self):
email = self.cleaned_data.get('email')
try:
CustomUser.objects.get(email=email)
return email
except CustomUser.DoesNotExist:
raise forms.ValidationError("User does not exist")
else:
return email
class SetPasswordForm(forms.Form):
"""
A form that lets a user change set their password without entering the old
password
"""
error_messages = {
'password_mismatch': ("The two password fields didn't match."),
}
new_password1 = forms.CharField(label=("New password"),
widget=forms.PasswordInput)
new_password2 = forms.CharField(label=("New password confirmation"),
widget=forms.PasswordInput)
def clean_new_password2(self):
password1 = self.cleaned_data.get('new_password1')
password2 = self.cleaned_data.get('new_password2')
if password1 and password2:
if password1 != password2:
raise forms.ValidationError(
self.error_messages['password_mismatch'],
code='password_mismatch',)
return password2
class BillingAddressForm(forms.ModelForm):
token = forms.CharField(widget=forms.HiddenInput())