diff options
Diffstat (limited to 'workshop_app')
-rw-r--r-- | workshop_app/forms.py | 4 | ||||
-rw-r--r-- | workshop_app/models.py | 11 |
2 files changed, 8 insertions, 7 deletions
diff --git a/workshop_app/forms.py b/workshop_app/forms.py index 90ca733..cce6dfc 100644 --- a/workshop_app/forms.py +++ b/workshop_app/forms.py @@ -51,9 +51,9 @@ class UserRegistrationForm(forms.Form): (max_length=32, widget=forms.PasswordInput()) first_name = forms.CharField(max_length=32) last_name = forms.CharField(max_length=32) - phone_number = forms.RegexField(regex=r'^\+?1?\d{9,15}$', + phone_number = forms.RegexField(regex=r'^.{10}$', error_message=("Phone number must be entered \ - in the format: '+999999999'.\ + in the format: '9999999999'.\ Up to 10 digits allowed.")) institute = forms.CharField(max_length=128, help_text='Please write full name of your Institute/Organization') diff --git a/workshop_app/models.py b/workshop_app/models.py index 35a1f38..5e7734c 100644 --- a/workshop_app/models.py +++ b/workshop_app/models.py @@ -11,7 +11,7 @@ position_choices = ( ) department_choices = ( - ("computer", "Computer Science"), + ("computer engineering", "Computer Science"), ("information technology", "Information Technology"), ("civil engineering", "Civil Engineering"), ("electrical engineering", "Electrical Engineering"), @@ -24,6 +24,7 @@ department_choices = ( ("others", "Others"), ) + def has_profile(user): """ check if user has profile """ return True if hasattr(user, 'profile') else False @@ -38,12 +39,12 @@ class Profile(models.Model): institute = models.CharField(max_length=150) department = models.CharField(max_length=150, choices=department_choices) phone_number = models.CharField( - max_length=15, + max_length=10, validators=[RegexValidator( - regex=r'^.{9}$', message=( + regex=r'^.{10}$', message=( "Phone number must be entered \ - in the format: '+99999999'.\ - Up to 15 digits allowed.") + in the format: '9999999999'.\ + Up to 10 digits allowed.") )] ,null=False) position = models.CharField(max_length=32, choices=position_choices, |