Added login.html, Added login view , Added login form,Created Donation Django Model
This commit is contained in:
parent
d7f7d498f5
commit
da9169c4ce
72 changed files with 30815 additions and 0 deletions
|
|
@ -3,10 +3,37 @@ 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 django.contrib.auth import authenticate
|
||||
from membership.models import CustomUser
|
||||
# from utils.fields import CountryField
|
||||
|
||||
|
||||
class LoginFormMixin(forms.Form):
|
||||
email = forms.CharField(widget=forms.EmailInput())
|
||||
password = forms.CharField(widget=forms.PasswordInput())
|
||||
|
||||
class Meta:
|
||||
fields = ['email', 'password']
|
||||
|
||||
def clean(self):
|
||||
email = self.cleaned_data.get('email')
|
||||
password = self.cleaned_data.get('password')
|
||||
is_auth = authenticate(email=email, password=password)
|
||||
if not is_auth:
|
||||
raise forms.ValidationError("Your username and/or password were incorrect.")
|
||||
return self.cleaned_data
|
||||
|
||||
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 PasswordResetRequestForm(forms.Form):
|
||||
email = forms.CharField(widget=forms.EmailInput())
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue