Compare commits
2 commits
master
...
bugfix/lda
Author | SHA1 | Date | |
---|---|---|---|
|
ddd90e650b | ||
|
e46729ee04 |
3 changed files with 32 additions and 3 deletions
|
@ -8,6 +8,7 @@ from utils.forms import LoginFormMixin, SignupFormMixin, BillingAddressForm
|
||||||
|
|
||||||
from .models import MembershipType, MembershipOrder
|
from .models import MembershipType, MembershipOrder
|
||||||
from .models import Booking, BookingOrder
|
from .models import Booking, BookingOrder
|
||||||
|
from membership.models import validate_name
|
||||||
|
|
||||||
|
|
||||||
class LoginForm(LoginFormMixin):
|
class LoginForm(LoginFormMixin):
|
||||||
|
@ -19,7 +20,8 @@ class SignupForm(SignupFormMixin):
|
||||||
confirm_password = forms.CharField(widget=forms.PasswordInput())
|
confirm_password = forms.CharField(widget=forms.PasswordInput())
|
||||||
password = forms.CharField(widget=forms.PasswordInput())
|
password = forms.CharField(widget=forms.PasswordInput())
|
||||||
name = forms.CharField(label='name',
|
name = forms.CharField(label='name',
|
||||||
widget=forms.TextInput(attrs={'placeholder': 'Full name'}))
|
widget=forms.TextInput(attrs={'placeholder': 'Full name'}),
|
||||||
|
validators=[validate_name])
|
||||||
|
|
||||||
|
|
||||||
class MembershipBillingForm(BillingAddressForm):
|
class MembershipBillingForm(BillingAddressForm):
|
||||||
|
|
|
@ -6,9 +6,10 @@ import tempfile
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth import authenticate
|
from django.contrib.auth import authenticate
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from membership.models import CustomUser
|
from membership.models import CustomUser, validate_name
|
||||||
from .models import UserHostingKey, GenericProduct
|
from .models import UserHostingKey, GenericProduct
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -164,6 +165,14 @@ class HostingUserSignupForm(forms.ModelForm):
|
||||||
raise forms.ValidationError("Passwords don't match")
|
raise forms.ValidationError("Passwords don't match")
|
||||||
return confirm_password
|
return confirm_password
|
||||||
|
|
||||||
|
def clean_name(self):
|
||||||
|
name = self.cleaned_data.get('name')
|
||||||
|
try:
|
||||||
|
validate_name(name)
|
||||||
|
except ValidationError as ve:
|
||||||
|
raise forms.ValidationError(_("Improper Name"))
|
||||||
|
return name
|
||||||
|
|
||||||
|
|
||||||
class UserHostingKeyForm(forms.ModelForm):
|
class UserHostingKeyForm(forms.ModelForm):
|
||||||
private_key = forms.CharField(widget=forms.HiddenInput(), required=False)
|
private_key = forms.CharField(widget=forms.HiddenInput(), required=False)
|
||||||
|
|
|
@ -3,8 +3,9 @@ from django.contrib.auth import authenticate
|
||||||
from django.core.mail import EmailMultiAlternatives
|
from django.core.mail import EmailMultiAlternatives
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
from membership.models import CustomUser
|
from membership.models import CustomUser, validate_name
|
||||||
from .models import ContactMessage, BillingAddress, UserBillingAddress
|
from .models import ContactMessage, BillingAddress, UserBillingAddress
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +31,15 @@ class SignupFormMixin(forms.ModelForm):
|
||||||
raise forms.ValidationError("Passwords don't match")
|
raise forms.ValidationError("Passwords don't match")
|
||||||
return confirm_password
|
return confirm_password
|
||||||
|
|
||||||
|
def clean_name(self):
|
||||||
|
name = self.cleaned_data.get('name')
|
||||||
|
try:
|
||||||
|
validate_name(name)
|
||||||
|
except ValidationError as ve:
|
||||||
|
raise forms.ValidationError(_("Improper Name"))
|
||||||
|
return name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LoginFormMixin(forms.Form):
|
class LoginFormMixin(forms.Form):
|
||||||
email = forms.CharField(widget=forms.EmailInput())
|
email = forms.CharField(widget=forms.EmailInput())
|
||||||
|
@ -165,6 +175,14 @@ class BillingAddressFormSignup(BillingAddressForm):
|
||||||
except CustomUser.DoesNotExist:
|
except CustomUser.DoesNotExist:
|
||||||
return email
|
return email
|
||||||
|
|
||||||
|
def clean_name(self):
|
||||||
|
name = self.cleaned_data.get('name')
|
||||||
|
try:
|
||||||
|
validate_name(name)
|
||||||
|
except ValidationError as ve:
|
||||||
|
raise forms.ValidationError(_("Improper Name"))
|
||||||
|
return name
|
||||||
|
|
||||||
|
|
||||||
class UserBillingAddressForm(forms.ModelForm):
|
class UserBillingAddressForm(forms.ModelForm):
|
||||||
user = forms.ModelChoiceField(queryset=CustomUser.objects.all(),
|
user = forms.ModelChoiceField(queryset=CustomUser.objects.all(),
|
||||||
|
|
Loading…
Reference in a new issue